Documentation ¶
Index ¶
- Variables
- type Account
- type Client
- func (c *Client) CreateAccount(a *Account) error
- func (c *Client) CreateTransaction(createdBy *User, involved []User, amount float64) error
- func (c *Client) CreateUser(u *User) error
- func (c *Client) FindAccountBetween(u1 *User, u2 *User) (*Account, error)
- func (c *Client) FindAccounts(u *User) ([]*Account, error)
- func (c *Client) FindUser(p PlatformName, id string) (*User, error)
- func (c *Client) FindUserByUsernam(p PlatformName, username string) (*User, error)
- func (c *Client) GetAccount(id uuid.UUID) (*Account, error)
- func (c *Client) GetAllTransactionsByUser(u *User, filterUser *User) ([]*Transaction, error)
- func (c *Client) GetTransaction(id string) (*Transaction, error)
- func (c *Client) GetUser(id uuid.UUID) (*User, error)
- func (c *Client) ListUsers() ([]*User, error)
- func (c *Client) NewTransaction(creator *User, subject *User, amount float64) error
- type PlatformName
- type Transaction
- type User
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // Id of this account Id uuid.UUID `json:"id" pg:",pk,type:uuid,default:uuid_generate_v4()"` CreatorId uuid.UUID `json:"creator_id" pg:"type:uuid,notnull"` // Creator is who owns this account, and what the balance is reflective of Creator *User `json:"creator"` SubjectId uuid.UUID `json:"subject_id" pg:"type:uuid,notnull"` // Subject is who this account includes, who is related to it, etc. Subject *User `json:"subject"` // Balance is the current balance of this account Balance float64 `json:"balance" pg:"default:0"` // CreatedAt is when this account was created CreatedAt time.Time `json:"created_at" pg:"default:now(),notnull"` // UpdatedAt is when this account was last updated (any fields modified update this) UpdatedAt time.Time `json:"updated_at" pg:"default:now(),notnull"` }
Account is a user's account
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CreateAccount ¶
CreateAccount creates an account
func (*Client) CreateTransaction ¶
CreateUser creates a new transaction in the database
func (*Client) CreateUser ¶
CreateUser creates a user in the database
func (*Client) FindAccountBetween ¶
FindAccountBetween finds an account between a user
func (*Client) FindAccounts ¶
FindAccounts finds all accounts owned by a user
func (*Client) FindUser ¶
func (c *Client) FindUser(p PlatformName, id string) (*User, error)
FindUser finds a user by their social ID
func (*Client) FindUserByUsernam ¶
func (c *Client) FindUserByUsernam(p PlatformName, username string) (*User, error)
FindUserByUsername finds a user by their social ID
func (*Client) GetAccount ¶
GetAccount returns an account
func (*Client) GetAllTransactionsByUser ¶
func (c *Client) GetAllTransactionsByUser(u *User, filterUser *User) ([]*Transaction, error)
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction(id string) (*Transaction, error)
GetTransaction by ID
type Transaction ¶
type Transaction struct { // Id of the User Id uuid.UUID `json:"id" pg:",pk,type:uuid,default:uuid_generate_v4()"` // CreatedBy is the user who created this transaction CreatedBy uuid.UUID `pg:"created_by,type:uuid" json:"created_by"` // Account is a userID -> accountID mapping of accounts that // were hit during this transaction Accounts map[uuid.UUID]uuid.UUID `pg:"accounts" json:"account_id"` // Amount that this transaction was for, split across all involved users Amount float64 `json:"amount" pg:"amount"` CreatedAt time.Time `json:"created_at" pg:"default:now(),notnull"` }
Transaction is a user transaction
func (*Transaction) String ¶
func (t *Transaction) String() string
type User ¶
type User struct { // Id of the User Id uuid.UUID `json:"id" pg:",pk,type:uuid,default:uuid_generate_v4()"` // PlatformIds are IDs on various platforms this user belongs in PlatformIds map[PlatformName]string `pg:"platform_ids,notnull" json:"platform_ids"` PlatformUsernames map[PlatformName]string `pg:"platform_usernames,notnull" json:"platform_usernames"` CreatedAt time.Time `json:"created_at" pg:"default:now(),notnull"` UpdatedAt time.Time `json:"updated_at" pg:"default:now(),notnull"` }
User is an account owner
Click to show internal directories.
Click to hide internal directories.