walletapi

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: GPL-3.0 Imports: 15 Imported by: 0

README

walletapi

Example GO lang wallet API Simple api for creating endpoints to wallet type API REST calls, and DB connection and logic for managing balance.

see: https://pkg.go.dev/github.com/Kerensky585/walletapi

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DbConn *gorm.DB
)
View Source
var (
	Router *gin.Engine
)

Functions

func DbController

func DbController(settingsJson string) bool

Read stting file specified and openthe DB connection of File or Remote DB If tables do not exist in the DB file provided create them.

func GenerateToken added in v0.1.7

func GenerateToken(header string, payload map[string]string, secret string) (string, error)

Function for generating the tokens.

func InitEndPoints

func InitEndPoints() (success bool)

Initialise end point routes

func ValidateDebitBalance

func ValidateDebitBalance(amount decimal.Decimal, decBalance decimal.Decimal) (bool, error)

Logic to vlaidate the business logic contratints on the wallet balance and amounts

func ValidatePositiveAmount

func ValidatePositiveAmount(amount decimal.Decimal) (bool, error)

Non negative vaules only are allowed by this function

func ValidateToken added in v0.1.7

func ValidateToken(token string, secret string) (bool, error)

This helps in validating the token

Types

type Wallet added in v0.1.7

type Wallet struct {
	gorm.Model
	WID     string          `json:"wid"`
	UID     string          `json:"name"`
	Balance decimal.Decimal `json:"balance"`
}

Struct to represent a very basic wallet Entity - use to create out schema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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