nwlib

package module
v0.0.0-...-6f38a8f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2018 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 GetAPIVersion

func GetAPIVersion() string

GetAPIVersion api version

func GetEnv

func GetEnv(params ...string) string

GetEnv get environment variable with default fall back

func GetRootDir

func GetRootDir() string

GetRootDir root dir

func LoadAWSConfig

func LoadAWSConfig() aws.Config

LoadAWSConfig set default aws config

func LoadDotEnv

func LoadDotEnv()

LoadDotEnv load .env file. TODO: remove in favor of Lambda ENV

func PublishSNS

func PublishSNS(arn string, message string) error

PublishSNS publish message to SNS topic

func PublishSlack

func PublishSlack(webhook string, message string, channel string) error

PublishSlack publish message to Slack

func SuccessResp

func SuccessResp(w http.ResponseWriter, message interface{})

SuccessResp success response helper for api

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
}

Account wrapper struct for plaid.Account

type DynamoDBClient

type DynamoDBClient struct {
	*dynamodb.DynamoDB
}

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) 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) GetTransactions

func (d DynamoDBClient) GetTransactions(username string, accountID string) ([]Transaction, error)

GetTransactions return all transactions from db for a username

func (DynamoDBClient) Set

func (d DynamoDBClient) Set(table string, partitionKey string, sortKey string, valMap map[string]string) error

Set key / val to db

func (DynamoDBClient) SetAccount

func (d DynamoDBClient) SetAccount(username string, itemID string, 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

type KMSClient

type KMSClient struct {
	*kms.KMS
}

KMSClient kms client struct

func NewKMSClient

func NewKMSClient() *KMSClient

NewKMSClient new instance of the kms client

func (KMSClient) Decrypt

func (k KMSClient) Decrypt(token string) (string, error)

Decrypt decrypt kms token

func (KMSClient) Encrypt

func (k KMSClient) Encrypt(token string) (string, error)

Encrypt key

type Networth

type Networth struct {
	Networth    float64 `json:"networth"`
	Assets      float64 `json:"assets"`
	Liabilities float64 `json:"liabilities"`
	DateTime    string  `json:"sort"`
}

Networth struct

type PlaidClient

type PlaidClient struct {
	*plaid.Client
}

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 {
	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"`
}

Token holds the structure single token

type Tokens

type Tokens struct {
	Tokens []*Token `json:"tokens"`
}

Tokens holds the structure multiple tokens

type Transaction

type Transaction struct {
	plaid.Transaction
}

Transaction struct

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"],
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL