Documentation
¶
Index ¶
- Constants
- type Customer
- type DBModel
- func (m *DBModel) AddUser(u User, hash string) error
- func (m *DBModel) Authenticate(email, password string) (int, error)
- func (m *DBModel) DeleteUser(id int) error
- func (m *DBModel) EditUser(u User) error
- func (m *DBModel) GetAllOrders() ([]*Order, error)
- func (m *DBModel) GetAllOrdersPaginated(pageSize, page int) ([]*Order, int, int, error)
- func (m *DBModel) GetAllSubscriptions() ([]*Order, error)
- func (m *DBModel) GetAllSubscriptionsPaginated(pageSize, page int) ([]*Order, int, int, error)
- func (m *DBModel) GetAllUsers() ([]*User, error)
- func (m *DBModel) GetOneUser(id int) (User, error)
- func (m *DBModel) GetOrderByID(id int) (Order, error)
- func (m *DBModel) GetUserByEmail(email string) (User, error)
- func (m *DBModel) GetUserForToken(token string) (*User, error)
- func (m *DBModel) GetWidget(id int) (Widget, error)
- func (m *DBModel) InsertCustomer(c Customer) (int, error)
- func (m *DBModel) InsertOrder(order Order) (int, error)
- func (m *DBModel) InsertToken(t *Token, u User) error
- func (m *DBModel) InsertTransaction(txn Transaction) (int, error)
- func (m *DBModel) UpdateOrderStatus(id, statusID int) error
- func (m *DBModel) UpdatePasswordForUser(u User, hash string) error
- type Models
- type Order
- type Status
- type Token
- type Transaction
- type TransactionStatus
- type User
- type Widget
Constants ¶
const (
ScopeAuthentication = "authentication"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Customer ¶
type Customer struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}
Customer is the type for users
type DBModel ¶
DBModel is the type for database connection values
func (*DBModel) DeleteUser ¶
func (*DBModel) GetAllOrders ¶
GetAllOrders returns a slice of all orders
func (*DBModel) GetAllOrdersPaginated ¶
GetAllOrdersPaginated returns a slice of a subset of orders
func (*DBModel) GetAllSubscriptions ¶
func (*DBModel) GetAllSubscriptionsPaginated ¶
func (*DBModel) GetAllUsers ¶
func (*DBModel) GetUserByEmail ¶
GetUserByEmail get an user by email
func (*DBModel) InsertCustomer ¶
InsertCustomer insert a new order and returns its id
func (*DBModel) InsertOrder ¶
InsertOrder insert a new order and returns its id
func (*DBModel) InsertTransaction ¶
func (m *DBModel) InsertTransaction(txn Transaction) (int, error)
InsertTransaction insert a new transaction and returns its id
func (*DBModel) UpdateOrderStatus ¶
UpdateOrderStatus updates the status of an order by id
type Order ¶
type Order struct {
ID int `json:"id"`
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"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
Widget Widget `json:"widget"`
Transaction Transaction `json:"transaction"`
Customer Customer `json:"customer"`
}
Order is the type for orders
type Status ¶
type Status struct {
ID int `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}
Status is the type for order statuses
type Token ¶
type Token struct {
PlainText string `json:"token"`
UserID int64 `json:"-"`
Hash []byte `json:"-"`
Expiry time.Time `json:"expiry"`
Scope string `json:"-"`
}
Token is the type for authentication tokens
type Transaction ¶
type Transaction struct {
ID int `json:"id"`
Amount int `json:"amount"`
Currency string `json:"currency"`
LastFour string `json:"last_four"`
PaymentMethod string `json:"payment_method"`
PaymentIntent string `json:"payment_intent"`
ExpiryMonth int `json:"expiry_month"`
ExpiryYear int `json:"expiry_year"`
BankReturnCode string `json:"bank_return_code"`
TransactionStatusID int `json:"transaction_status_id"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}
Transaction is the type for transactions
type TransactionStatus ¶
type TransactionStatus struct {
ID int `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}
TransactionStatus is the type for transaction statuses
type User ¶
type User struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Email string `json:"email"`
Password string `json:"password"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}
User is the type for users
type Widget ¶
type Widget struct {
ID int `json:"id"`
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"`
CreatedAt time.Time `json:"-"`
UpdatedAt time.Time `json:"-"`
}
Widget is the type for widgets