Documentation ¶
Index ¶
- Variables
- func ErrorResp(w http.ResponseWriter, message interface{})
- func GetEnv(params ...string) string
- func LoadAWSConfig() aws.Config
- func PublishSNS(arn string, message string) error
- func PublishSlack(webhook string, message string, channel string) error
- func SuccessResp(w http.ResponseWriter, message interface{})
- func SyncAccounts(plaidClient *PlaidClient, db *DynamoDBClient, token *Token) error
- func SyncNetworth(db *DynamoDBClient, username string) error
- type APIResponse
- type Account
- type DynamoDBClient
- func (d DynamoDBClient) GetAccounts(username string) ([]Account, error)
- func (d DynamoDBClient) GetAllUsers() ([]Token, error)
- func (d DynamoDBClient) GetNetworth(username string) (Networth, error)
- func (d DynamoDBClient) GetNetworthByDateRange(username string, startDate string, endDate string) ([]Networth, error)
- func (d DynamoDBClient) GetToken(kms *KMSClient, username, itemID string) (Token, error)
- func (d DynamoDBClient) GetTokenByItemID(kms *KMSClient, itemID string) (Token, error)
- func (d DynamoDBClient) GetTokens(kms *KMSClient, username string) ([]Token, error)
- func (d DynamoDBClient) GetTokensWithError(username string) ([]Token, error)
- func (d DynamoDBClient) GetTransactions(username string, accountID string) ([]Transaction, error)
- func (d DynamoDBClient) GetUsernameByItemID(itemID string) (string, error)
- func (d DynamoDBClient) SetAccount(token *Token, account *plaid.Account) error
- func (d DynamoDBClient) SetNetworth(username string, networth float64, assets float64, liabilities float64) error
- func (d DynamoDBClient) SetToken(username string, token *Token) error
- func (d DynamoDBClient) SetTransaction(username string, transaction plaid.Transaction) error
- func (d DynamoDBClient) SetWebhook(webhook Webhook) error
- func (d DynamoDBClient) UpdateTokenError(token *Token) error
- type KMSClient
- type Networth
- type PlaidClient
- type SlackBody
- type Token
- type Transaction
- type Webhook
- type WebhookError
Constants ¶
This section is empty.
Variables ¶
var AWSRegion = GetEnv("AWS_REGION", "us-east-1")
AWSRegion default aws region
Functions ¶
func ErrorResp ¶
func ErrorResp(w http.ResponseWriter, message interface{})
ErrorResp error response helper for api
func PublishSNS ¶
PublishSNS publish message to SNS topic
func PublishSlack ¶
PublishSlack publish message to Slack
func SuccessResp ¶
func SuccessResp(w http.ResponseWriter, message interface{})
SuccessResp success response helper for api
func SyncAccounts ¶
func SyncAccounts(plaidClient *PlaidClient, db *DynamoDBClient, token *Token) error
SyncAccounts - get latest accounts from Plaid
func SyncNetworth ¶
func SyncNetworth(db *DynamoDBClient, username string) error
SyncNetworth save net worth to db for current datetime
Types ¶
type APIResponse ¶
type APIResponse struct {
Data interface{} `json:"data"`
}
APIResponse api reponse
type Account ¶
type Account struct { plaid.Account InstitutionID string `json:"institution_id"` InstitutionName string `json:"institution_name"` }
Account wrapper struct for plaid.Account
type DynamoDBClient ¶
DynamoDBClient db client struct
func NewDynamoDBClient ¶
func NewDynamoDBClient() *DynamoDBClient
NewDynamoDBClient new dynamodb client
func (DynamoDBClient) GetAccounts ¶
func (d DynamoDBClient) GetAccounts(username string) ([]Account, error)
GetAccounts return all accounts from db for a username
func (DynamoDBClient) GetAllUsers ¶
func (d DynamoDBClient) GetAllUsers() ([]Token, error)
GetAllUsers - get all users
func (DynamoDBClient) GetNetworth ¶
func (d DynamoDBClient) GetNetworth(username string) (Networth, error)
GetNetworth return Networth struct
func (DynamoDBClient) GetNetworthByDateRange ¶
func (d DynamoDBClient) GetNetworthByDateRange(username string, startDate string, endDate string) ([]Networth, error)
GetNetworthByDateRange return net worth based on date
func (DynamoDBClient) GetToken ¶
func (d DynamoDBClient) GetToken(kms *KMSClient, username, itemID string) (Token, error)
� - return decrypted token based on username and item_id
func (DynamoDBClient) GetTokenByItemID ¶
func (d DynamoDBClient) GetTokenByItemID(kms *KMSClient, itemID string) (Token, error)
GetTokenByItemID - return decrypted token based on item_id
func (DynamoDBClient) GetTokens ¶
func (d DynamoDBClient) GetTokens(kms *KMSClient, username string) ([]Token, error)
GetTokens - return all tokens decrypted from db for a username
func (DynamoDBClient) GetTokensWithError ¶
func (d DynamoDBClient) GetTokensWithError(username string) ([]Token, error)
GetTokensWithError - return all tokens with error
func (DynamoDBClient) GetTransactions ¶
func (d DynamoDBClient) GetTransactions(username string, accountID string) ([]Transaction, error)
GetTransactions return all transactions from db for a username
func (DynamoDBClient) GetUsernameByItemID ¶
func (d DynamoDBClient) GetUsernameByItemID(itemID string) (string, error)
GetUsernameByItemID - return username based on item_id
func (DynamoDBClient) SetAccount ¶
func (d DynamoDBClient) SetAccount(token *Token, account *plaid.Account) error
SetAccount save account to db
func (DynamoDBClient) SetNetworth ¶
func (d DynamoDBClient) SetNetworth(username string, networth float64, assets float64, liabilities float64) error
SetNetworth value as of today date and current timestamp
func (DynamoDBClient) SetToken ¶
func (d DynamoDBClient) SetToken(username string, token *Token) error
SetToken save token to db
func (DynamoDBClient) SetTransaction ¶
func (d DynamoDBClient) SetTransaction(username string, transaction plaid.Transaction) error
SetTransaction save transaction to db
func (DynamoDBClient) SetWebhook ¶
func (d DynamoDBClient) SetWebhook(webhook Webhook) error
SetWebhook save webhook to db
func (DynamoDBClient) UpdateTokenError ¶
func (d DynamoDBClient) UpdateTokenError(token *Token) error
UpdateTokenError update error field for token
type Networth ¶
type Networth struct { Networth float64 `json:"networth"` Assets float64 `json:"assets"` Liabilities float64 `json:"liabilities"` DateTime string `json:"sort"` UpdatedAt string `json:"updated_at"` }
Networth struct
type PlaidClient ¶
PlaidClient plaid client
func NewPlaidClient ¶
func NewPlaidClient(clientID string, secret string, publicKey string, environment string) *PlaidClient
NewPlaidClient new Plaid client
type SlackBody ¶
type SlackBody struct { Text string `json:"text"` Username string `json:"username"` IconURL string `json:"icon_url"` Channel string `json:"channel"` }
SlackBody struct
type Token ¶
type Token struct { ID string `json:"id"` Sort string `json:"sort"` ItemID string `json:"item_id"` AccessToken string `json:"access_token"` AccountID string `json:"account_id"` InstitutionID string `json:"institution_id"` InstitutionName string `json:"institution_name"` Accounts []string `json:"accounts"` Username string `json:"username"` Error string `json:"error"` }
Token holds the structure single token
type Webhook ¶
type Webhook struct { WebhookType string `json:"webhook_type"` // "TRANSACTIONS", WebhookCode string `json:"webhook_code"` // INITIAL_UPDATE HISTORICAL_UPDATE DEFAULT_UPDATE TRANSACTIONS_REMOVED ItemID string `json:"item_id"` // "wz666MBjYWTp2PDzzggYhM6oWWmBb", Error WebhookError `json:"error"` // null, NewTransactions int `json:"new_transactions"` //19 RemovedTransactions []string `json:"removed_transactions"` // ["yBVBEwrPyJs8GvR77N7QTxnGg6wG74H7dEDN6", "kgygNvAVPzSX9KkddNdWHaVGRVex1MHm3k9no"], Username string `json:"username"` }
Webhook body
type WebhookError ¶
type WebhookError struct { DisplayMessage string `json:"display_message"` //: "The provided credentials were not correct. Please try again.", ErrorCode string `json:"error_code"` //: "ITEM_LOGIN_REQUIRED", ErrorMessage string `json:"error_message"` //: "the provided credentials were not correct", ErrorType string `json:"error_type"` //: "ITEM_ERROR", Status int `json:"status"` //: 400 }
WebhookError struct contains error fields from webhook