working but should scroll emails
parent
dac2114af0
commit
c4cf4dfbd6
|
|
@ -16,6 +16,7 @@ type Config struct {
|
|||
TodoAddr string
|
||||
TodoToken string
|
||||
TodoList string
|
||||
TodoTag string
|
||||
Storage storage.DB
|
||||
}
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ func NewConfig() Config {
|
|||
as.Append(args.STRING, "todopass", "todo pass", "gJtEXbbLHLf54yS9EdujtVN2n6Y")
|
||||
as.Append(args.STRING, "todotoken", "todo token", "")
|
||||
as.Append(args.STRING, "todolist", "todo list", "")
|
||||
as.Append(args.STRING, "todotag", "todo tag", "expense")
|
||||
|
||||
as.Append(args.STRING, "authaddr", "auth addr", "https://auth.remote.blapointe.com")
|
||||
as.Append(args.STRING, "store", "store type", "map")
|
||||
|
|
@ -100,6 +102,7 @@ func NewConfig() Config {
|
|||
TodoAddr: as.GetString("todoaddr"),
|
||||
TodoToken: token,
|
||||
TodoList: list,
|
||||
TodoTag: as.GetString("todotag"),
|
||||
Storage: storage,
|
||||
}
|
||||
return config
|
||||
|
|
|
|||
7
main.go
7
main.go
|
|
@ -3,7 +3,6 @@ package main
|
|||
import (
|
||||
"local/sandbox/contact/contact"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
@ -13,12 +12,6 @@ func main() {
|
|||
From: config.EmailUser,
|
||||
Password: config.EmailPass,
|
||||
}
|
||||
log.Println(emailer)
|
||||
|
||||
//{45b6895c6dd6345f46e6e15dd2c61f03 Chase 12.86 GOOGLE *GSUITE_blapo [Wed, 1 Apr 2020 10:14:11 -0400 (EDT)]}
|
||||
log.Println(Upload(config, NewTransaction("11.11", "vendor", time.Now().String(), Bank(0))))
|
||||
|
||||
return
|
||||
emails, err := emailer.Read()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
|
|||
19
upload.go
19
upload.go
|
|
@ -1,20 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"local/oauth2"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Upload(config Config, transaction *Transaction) error {
|
||||
params := url.Values{
|
||||
"list": {"2548023766"},
|
||||
"title": {"test task: " + time.Now().String()},
|
||||
"tag": {"expense"},
|
||||
"list": {config.TodoList},
|
||||
"title": {fmt.Sprintf("%v: %s @ %s @ %s", transaction.Bank, transaction.Amount, transaction.Account, transaction.Date)},
|
||||
"tag": {config.TodoTag},
|
||||
}
|
||||
req, err := http.NewRequest("POST", config.TodoAddr+"/ajax.php?newTask", strings.NewReader(params.Encode()))
|
||||
if err != nil {
|
||||
|
|
@ -26,6 +25,10 @@ func Upload(config Config, transaction *Transaction) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
log.Printf("%+v\n\n%+v", req, resp)
|
||||
return errors.New("not impl")
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
b, _ := ioutil.ReadAll(resp.Body)
|
||||
return fmt.Errorf("bad status from todo: %v: %s", resp.StatusCode, b)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue