working but should scroll emails
parent
dac2114af0
commit
c4cf4dfbd6
|
|
@ -16,6 +16,7 @@ type Config struct {
|
||||||
TodoAddr string
|
TodoAddr string
|
||||||
TodoToken string
|
TodoToken string
|
||||||
TodoList string
|
TodoList string
|
||||||
|
TodoTag string
|
||||||
Storage storage.DB
|
Storage storage.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,6 +32,7 @@ func NewConfig() Config {
|
||||||
as.Append(args.STRING, "todopass", "todo pass", "gJtEXbbLHLf54yS9EdujtVN2n6Y")
|
as.Append(args.STRING, "todopass", "todo pass", "gJtEXbbLHLf54yS9EdujtVN2n6Y")
|
||||||
as.Append(args.STRING, "todotoken", "todo token", "")
|
as.Append(args.STRING, "todotoken", "todo token", "")
|
||||||
as.Append(args.STRING, "todolist", "todo list", "")
|
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, "authaddr", "auth addr", "https://auth.remote.blapointe.com")
|
||||||
as.Append(args.STRING, "store", "store type", "map")
|
as.Append(args.STRING, "store", "store type", "map")
|
||||||
|
|
@ -100,6 +102,7 @@ func NewConfig() Config {
|
||||||
TodoAddr: as.GetString("todoaddr"),
|
TodoAddr: as.GetString("todoaddr"),
|
||||||
TodoToken: token,
|
TodoToken: token,
|
||||||
TodoList: list,
|
TodoList: list,
|
||||||
|
TodoTag: as.GetString("todotag"),
|
||||||
Storage: storage,
|
Storage: storage,
|
||||||
}
|
}
|
||||||
return config
|
return config
|
||||||
|
|
|
||||||
7
main.go
7
main.go
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"local/sandbox/contact/contact"
|
"local/sandbox/contact/contact"
|
||||||
"log"
|
"log"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -13,12 +12,6 @@ func main() {
|
||||||
From: config.EmailUser,
|
From: config.EmailUser,
|
||||||
Password: config.EmailPass,
|
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()
|
emails, err := emailer.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
||||||
19
upload.go
19
upload.go
|
|
@ -1,20 +1,19 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"local/oauth2"
|
"local/oauth2"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Upload(config Config, transaction *Transaction) error {
|
func Upload(config Config, transaction *Transaction) error {
|
||||||
params := url.Values{
|
params := url.Values{
|
||||||
"list": {"2548023766"},
|
"list": {config.TodoList},
|
||||||
"title": {"test task: " + time.Now().String()},
|
"title": {fmt.Sprintf("%v: %s @ %s @ %s", transaction.Bank, transaction.Amount, transaction.Account, transaction.Date)},
|
||||||
"tag": {"expense"},
|
"tag": {config.TodoTag},
|
||||||
}
|
}
|
||||||
req, err := http.NewRequest("POST", config.TodoAddr+"/ajax.php?newTask", strings.NewReader(params.Encode()))
|
req, err := http.NewRequest("POST", config.TodoAddr+"/ajax.php?newTask", strings.NewReader(params.Encode()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -26,6 +25,10 @@ func Upload(config Config, transaction *Transaction) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Printf("%+v\n\n%+v", req, resp)
|
defer resp.Body.Close()
|
||||||
return errors.New("not impl")
|
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