stub wip fidelity
parent
1139fef0ab
commit
f6fc366dd4
3
bank.go
3
bank.go
|
|
@ -7,10 +7,13 @@ const (
|
||||||
Citi Bank = iota + 1
|
Citi Bank = iota + 1
|
||||||
UCCU Bank = iota + 1
|
UCCU Bank = iota + 1
|
||||||
BankOfAmerica Bank = iota + 1
|
BankOfAmerica Bank = iota + 1
|
||||||
|
Fidelity Bank = iota + 1
|
||||||
)
|
)
|
||||||
|
|
||||||
func (b Bank) String() string {
|
func (b Bank) String() string {
|
||||||
switch b {
|
switch b {
|
||||||
|
case Fidelity:
|
||||||
|
return "Fidelity"
|
||||||
case BankOfAmerica:
|
case BankOfAmerica:
|
||||||
return "BankOfAmerica"
|
return "BankOfAmerica"
|
||||||
case Chase:
|
case Chase:
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ type Config struct {
|
||||||
EmailUser string
|
EmailUser string
|
||||||
EmailPass string
|
EmailPass string
|
||||||
EmailIMAP string
|
EmailIMAP string
|
||||||
|
EmailLimit int
|
||||||
TodoAddr string
|
TodoAddr string
|
||||||
TodoToken string
|
TodoToken string
|
||||||
TodoList string
|
TodoList string
|
||||||
|
|
@ -49,6 +50,7 @@ func NewConfig() Config {
|
||||||
as.Append(args.STRING, "emailuser", "email username", "breellocaldev@gmail.com")
|
as.Append(args.STRING, "emailuser", "email username", "breellocaldev@gmail.com")
|
||||||
as.Append(args.STRING, "emailpass", "email password", "diblloewfncwssof")
|
as.Append(args.STRING, "emailpass", "email password", "diblloewfncwssof")
|
||||||
as.Append(args.STRING, "emailimap", "email imap", "imap.gmail.com:993")
|
as.Append(args.STRING, "emailimap", "email imap", "imap.gmail.com:993")
|
||||||
|
as.Append(args.INT, "emaillimit", "email limit", 0)
|
||||||
|
|
||||||
as.Append(args.STRING, "uploader", "todo, ledger, pttodo", "todo")
|
as.Append(args.STRING, "uploader", "todo, ledger, pttodo", "todo")
|
||||||
|
|
||||||
|
|
@ -87,6 +89,7 @@ func NewConfig() Config {
|
||||||
EmailUser: as.GetString("emailuser"),
|
EmailUser: as.GetString("emailuser"),
|
||||||
EmailPass: as.GetString("emailpass"),
|
EmailPass: as.GetString("emailpass"),
|
||||||
EmailIMAP: as.GetString("emailimap"),
|
EmailIMAP: as.GetString("emailimap"),
|
||||||
|
EmailLimit: as.GetInt("emaillimit"),
|
||||||
TodoAddr: as.GetString("todoaddr"),
|
TodoAddr: as.GetString("todoaddr"),
|
||||||
TodoTag: as.GetString("todotag"),
|
TodoTag: as.GetString("todotag"),
|
||||||
AccountsPattern: as.GetString("accounts"),
|
AccountsPattern: as.GetString("accounts"),
|
||||||
|
|
|
||||||
1
main.go
1
main.go
|
|
@ -12,6 +12,7 @@ func main() {
|
||||||
IMAP: config.EmailIMAP,
|
IMAP: config.EmailIMAP,
|
||||||
From: config.EmailUser,
|
From: config.EmailUser,
|
||||||
Password: config.EmailPass,
|
Password: config.EmailPass,
|
||||||
|
Limit: config.EmailLimit,
|
||||||
}
|
}
|
||||||
emails, err := emailer.Read()
|
emails, err := emailer.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
12
scrape.go
12
scrape.go
|
|
@ -15,6 +15,7 @@ type scraper interface {
|
||||||
scrape(*mail.Message) ([]*Transaction, error)
|
scrape(*mail.Message) ([]*Transaction, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type fidelityScraper struct{}
|
||||||
type bankOfAmericaScraper struct{}
|
type bankOfAmericaScraper struct{}
|
||||||
type chaseScraper struct{}
|
type chaseScraper struct{}
|
||||||
type citiScraper struct{}
|
type citiScraper struct{}
|
||||||
|
|
@ -37,6 +38,9 @@ func buildScraper(m *mail.Message, banks map[Bank]bool) (scraper, error) {
|
||||||
if strings.Contains(from, "Chase") && banks[Chase] {
|
if strings.Contains(from, "Chase") && banks[Chase] {
|
||||||
return newChaseScraper(), nil
|
return newChaseScraper(), nil
|
||||||
}
|
}
|
||||||
|
if strings.Contains(from, "Fidelity") && banks[Fidelity] {
|
||||||
|
return newFidelityScraper(), nil
|
||||||
|
}
|
||||||
if strings.Contains(from, "Bank of America") && banks[BankOfAmerica] {
|
if strings.Contains(from, "Bank of America") && banks[BankOfAmerica] {
|
||||||
return newBankOfAmericaScraper(), nil
|
return newBankOfAmericaScraper(), nil
|
||||||
}
|
}
|
||||||
|
|
@ -49,6 +53,10 @@ func buildScraper(m *mail.Message, banks map[Bank]bool) (scraper, error) {
|
||||||
return nil, errors.New("unknown sender: " + from)
|
return nil, errors.New("unknown sender: " + from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newFidelityScraper() scraper {
|
||||||
|
return &fidelityScraper{}
|
||||||
|
}
|
||||||
|
|
||||||
func newBankOfAmericaScraper() scraper {
|
func newBankOfAmericaScraper() scraper {
|
||||||
return &bankOfAmericaScraper{}
|
return &bankOfAmericaScraper{}
|
||||||
}
|
}
|
||||||
|
|
@ -210,6 +218,10 @@ func (c *uccuScraper) scrape(m *mail.Message) ([]*Transaction, error) {
|
||||||
return []*Transaction{transaction}, nil
|
return []*Transaction{transaction}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *fidelityScraper) scrape(m *mail.Message) ([]*Transaction, error) {
|
||||||
|
panic(nil)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *bankOfAmericaScraper) scrape(m *mail.Message) ([]*Transaction, error) {
|
func (c *bankOfAmericaScraper) scrape(m *mail.Message) ([]*Transaction, error) {
|
||||||
subject := fmt.Sprint(m.Header["Subject"])
|
subject := fmt.Sprint(m.Header["Subject"])
|
||||||
if strings.Contains(subject, "Credit card transaction") {
|
if strings.Contains(subject, "Credit card transaction") {
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,41 @@ func TestScrapeBofAPayment(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestScrapeFidelityWithdrawal(t *testing.T) {
|
||||||
|
b, err := ioutil.ReadFile("./testdata/fidelity.withdrawal.txt")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
message := &mail.Message{
|
||||||
|
Header: map[string][]string{
|
||||||
|
"Subject": []string{"Credit card transaction exceeds alert limit you set"},
|
||||||
|
},
|
||||||
|
Body: bytes.NewReader(b),
|
||||||
|
}
|
||||||
|
bofa := &bankOfAmericaScraper{}
|
||||||
|
|
||||||
|
gots, err := bofa.scrape(message)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(gots) != 1 {
|
||||||
|
t.Fatal(len(gots))
|
||||||
|
}
|
||||||
|
got := gots[0]
|
||||||
|
want := Transaction{
|
||||||
|
ID: got.ID,
|
||||||
|
Bank: BankOfAmerica,
|
||||||
|
Amount: "75.08",
|
||||||
|
Vendor: "PAYPAL GIBBDOGENTE MA",
|
||||||
|
Date: "[]",
|
||||||
|
Account: BankOfAmerica.String(),
|
||||||
|
}
|
||||||
|
if *got != want {
|
||||||
|
t.Fatalf("want:\n\t%+v, got\n\t%+v", want, *got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestScrapeBofACharge(t *testing.T) {
|
func TestScrapeBofACharge(t *testing.T) {
|
||||||
b, err := ioutil.ReadFile("./testdata/bofa.charge.txt")
|
b, err := ioutil.ReadFile("./testdata/bofa.charge.txt")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
|
||||||
|
For account ending in 5576:
|
||||||
|
Money was withdrawn from your account through a direct debit in the amount of $1.00 by CHASE CREDIT CRD.
|
||||||
|
|
||||||
|
If you authorized this transaction, no action is needed.
|
||||||
|
If you did not authorize this transaction, please contact us immediately at 800-343-3548.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Important information:
|
||||||
|
Fidelity automatically emails certain alerts to customers who have provided
|
||||||
|
an email address. You can see the terms which govern these alerts at
|
||||||
|
https://alertable.fidelity.com/alerts/help/agreement.html. If you would
|
||||||
|
prefer to not receive these alerts, please change your preferences at
|
||||||
|
https://scs.fidelity.com/customeronly/alerts.shtml.
|
||||||
|
This new alerts service will not affect delivery of paper communications
|
||||||
|
you are scheduled to receive.
|
||||||
|
|
||||||
|
To stop receipt of alerts, modify your preferences on the Existing Alerts page
|
||||||
|
at https://scs.fidelity.com/customeronly/fens.shtml, or temporarily
|
||||||
|
stop/restart alerts at
|
||||||
|
https://scs.fidelity.com/customeronly/fens_alertstatus.shtml.
|
||||||
|
|
||||||
|
Fidelity offers access to a broader range of third-party research at
|
||||||
|
http://personal.fidelity.com/research/stocks/content/stocksindex.shtml.
|
||||||
|
Fidelity is not recommending or endorsing any third-party research by making it
|
||||||
|
available to its customers or by notifying customers of its availability.
|
||||||
|
|
||||||
|
Review Fidelity's Terms of Use for Third Party Content and Research at
|
||||||
|
http://activequote.fidelity.com/rtrnews/terms.html.
|
||||||
|
|
||||||
|
If your email has changed, please update your email address
|
||||||
|
at https://scs.fidelity.com/customeronly/fens_profile.shtml to continue to
|
||||||
|
receive your alerts.
|
||||||
|
|
||||||
|
Read Fidelity's Commitment to Privacy
|
||||||
|
at http://personal.fidelity.com/global/search/content/privacy.html.tvsr.
|
||||||
|
|
||||||
|
Visit Fidelity's Home Page
|
||||||
|
http://www.fidelity.com/
|
||||||
|
|
||||||
|
Fidelity Brokerage Services LLC, Member NYSE, SIPC, 900 Salem Street, Smithfield, RI 02917
|
||||||
|
|
||||||
|
EMAIL REF# 537048
|
||||||
|
|
||||||
|
Copyright 2022 FMR LLC
|
||||||
|
All rights reserved. Important Legal Information
|
||||||
|
at http://personal.fidelity.com/misc/legal/legal.html.tvsr.
|
||||||
|
|
||||||
Loading…
Reference in New Issue