shared

package
v0.0.0-...-122a5d2 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDynamoDBClient

func NewDynamoDBClient() (*dynamodb.DynamoDB, error)

NewDynamoDBClient creates a new DynamoDB client.

func PutTransactions

func PutTransactions(svc *dynamodb.DynamoDB, transactions []Transaction) error

PutTransactions uses BatchWriteItem to put multiple transactions into DynamoDB.

Types

type Metrics

type Metrics struct {
	Balance             float64        `json:"balance"`
	PositiveAverage     float64        `json:"positiveAverage"`
	NegativeAverage     float64        `json:"negativeAverage"`
	TransactionsByMonth map[string]int `json:"transactionsByMonth"`
	Transactions        []Transaction  `json:"transactions"`
}

Metrics represents the calculated metrics for transactions.

func CalculateMetrics

func CalculateMetrics(transactions []Transaction) (Metrics, error)

type Transaction

type Transaction struct {
	Email         string  `json:"email"`
	Amount        float64 `json:"amount"`
	Month         string  `json:"month"`
	TransactionID string  `json:"transactionId"`
}

func QueryTransactionsByEmail

func QueryTransactionsByEmail(svc dynamodbiface.DynamoDBAPI, email string) ([]Transaction, error)

QueryTransactionsByEmail queries DynamoDB for transactions by email.

func (*Transaction) GenerateTransactionID

func (t *Transaction) GenerateTransactionID()

Jump to

Keyboard shortcuts

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