Documentation
¶
Index ¶
- Constants
- type Customer
- type DBEntity
- type DBModel
- func (m *DBModel) Authenticate(email, password string) (int, error)
- func (m *DBModel) DeleteUser(u User) error
- func (m *DBModel) GetAllOrders(pageSize, pageNo int) ([]*Order, int, error)
- func (m *DBModel) GetAllSubscriptions(pageSize, pageNo int) ([]*Order, int, error)
- func (m *DBModel) GetAllUsers(pageSize, page int) ([]*User, int, error)
- func (m *DBModel) GetCustomer(id int) (Customer, error)
- func (m *DBModel) GetOrder(id int) (Order, error)
- func (m *DBModel) GetTransaction(id int) (Transaction, error)
- func (m *DBModel) GetTransactionByPI(pi string) (Transaction, error)
- func (m *DBModel) GetUserByEmail(email string) (User, error)
- func (m *DBModel) GetUserByID(id int) (User, error)
- func (m *DBModel) GetUserForToken(token string) (*User, error)
- func (m *DBModel) GetWidget(id int) (Widget, error)
- func (m *DBModel) InsertCustomer(customer Customer) (int, error)
- func (m *DBModel) InsertOrder(order Order) (int, error)
- func (m *DBModel) InsertToken(t *SToken, u User) (int, error)
- func (m *DBModel) InsertTransaction(txn Transaction) (int, error)
- func (m *DBModel) InsertUser(u User) (int, error)
- func (m *DBModel) UpdateOrderStatus(id, statusID int) error
- func (m *DBModel) UpdatePasswordForUser(u User, hash string) error
- func (m *DBModel) UpdateUser(u User) error
- type IDBEntity
- type Models
- type Order
- type SToken
- type Status
- type Token
- type Transaction
- type TransactionStatus
- type User
- type VTTransactionData
- type Widget
Constants ¶
const (
ScopeAuthentication = "authentication"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Customer ¶
type Customer struct { DBEntity FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` }
Customer is a type for customers
type DBEntity ¶
type DBEntity struct { ID int `model-copy:"ignore" json:"id" gorm:"primaryKey"` CreatedAt time.Time `model-copy:"ignore" json:"-"` UpdatedAt time.Time `model-copy:"ignore" json:"-"` }
func (*DBEntity) SetCreated ¶
func (e *DBEntity) SetCreated()
func (*DBEntity) SetUpdated ¶
func (e *DBEntity) SetUpdated()
type DBModel ¶
DBModel is the type for database connection values
func (*DBModel) DeleteUser ¶
DeleteUser removes user from DB
func (*DBModel) GetAllOrders ¶
func (*DBModel) GetAllSubscriptions ¶
func (*DBModel) GetAllUsers ¶
GetAllUsers fetches list of users from the DB ordered by LastName and FirstName
func (*DBModel) GetCustomer ¶
GetCustomer fetches Customer from DB by id
func (*DBModel) GetTransaction ¶
func (m *DBModel) GetTransaction(id int) (Transaction, error)
GetTransaction fetches Transaction from DB by id
func (*DBModel) GetTransactionByPI ¶
func (m *DBModel) GetTransactionByPI(pi string) (Transaction, error)
GetTransactionByPI fetches Transaction from DB by Payment Intent ID
func (*DBModel) GetUserByEmail ¶
GetUserByEmail gets a user by email address
func (*DBModel) GetUserByID ¶
GetUserByID fetches one user from DB by id
func (*DBModel) InsertCustomer ¶
InsertCustomer inserts new order and returns it's id
func (*DBModel) InsertOrder ¶
InsertOrder inserts new order and returns it's id
func (*DBModel) InsertTransaction ¶
func (m *DBModel) InsertTransaction(txn Transaction) (int, error)
InsertTransaction inserts new transaction and returns it's id
func (*DBModel) InsertUser ¶
InsertUser adds a new user to DB
func (*DBModel) UpdateOrderStatus ¶
func (*DBModel) UpdatePasswordForUser ¶
func (*DBModel) UpdateUser ¶
UpdateUser updates user's record in DB
type Order ¶
type Order struct { DBEntity WidgetID int `json:"widget_id"` TransactionID int `json:"transaction_id"` CustomerID int `json:"customer_id"` StatusID int `json:"status_id"` Quantity int `json:"quantity"` Amount int `json:"amount"` Widget Widget `json:"widget"` Transaction Transaction `json:"transaction"` Customer Customer `json:"customer"` }
Order is the type for all orders
type SToken ¶
type SToken struct { PlainText string `json:"token"` UserID int64 `json:"-"` Hash []byte `json:"-"` Expiry time.Time `json:"expiry"` Scope string `json:"-"` }
SToken is a type for authentication tokens
type Token ¶
type Token struct { DBEntity UserID int Name string Email string Expiry time.Time TokenHash []byte }
Token is a type for saving tokens (SToken) to DB
type Transaction ¶
type Transaction struct { DBEntity Amount int `json:"amount"` Currency string `json:"currency"` LastFour string `json:"last_four"` ExpiryMonth int `json:"expiry_month"` ExpiryYear int `json:"expiry_year"` PaymentIntent string `json:"payment_intent"` PaymentMethod string `json:"payment_method"` BankReturnCode string `json:"bank_return_code"` TransactionStatusID int `json:"transaction_status_id"` }
Transactionis a type for transactions
type TransactionStatus ¶
TransactionStatus is a type for transaction statuses
type User ¶
type User struct { DBEntity FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` Password string `model-copy:"ignore" json:"password"` }
User is a type for users
type VTTransactionData ¶
type VTTransactionData struct { PaymentAmount int `json:"amount"` PaymentCurrency string `json:"currency"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Email string `json:"email"` PaymentIntent string `json:"payment_intent"` PaymentMethod string `json:"payment_method"` BankReturnCode string `json:"bank_return_code"` ExpiryMonth int `json:"expiry_month"` ExpiryYear int `json:"expiry_year"` LastFour string `json:"last_four"` }
type Widget ¶
type Widget struct { DBEntity Name string `json:"name"` Description string `json:"description"` InventoryLevel int `json:"inventory_level"` Price int `json:"price"` Image string `json:"image"` IsRecurring bool `json:"is_recurring"` PlanID string `json:"plan_id"` }
Widget is the type for all widgets