Documentation ¶
Index ¶
- Variables
- func Register(m interface{})
- type AccessRole
- type AccessToken
- type AccountRepo
- type Asset
- type AssetsRepo
- type AuthService
- type AuthToken
- type AuthUser
- type BankAccount
- type Base
- type CoinStatement
- type ListQuery
- type LoginResponseWithToken
- type Pagination
- type PlaidAuthToken
- type RBACService
- type ReferralCodeVerifyResponse
- type RefreshToken
- type Reward
- type Role
- type RoleRepo
- type User
- type UserRepo
- type UserReward
- type Verification
Constants ¶
This section is empty.
Variables ¶
var Models []interface{}
Models hold registered models in-memory
Functions ¶
Types ¶
type AccessRole ¶
type AccessRole int8
AccessRole represents access role type
const ( // SuperAdminRole has all permissions SuperAdminRole AccessRole = iota + 1 // AdminRole has admin specific permissions AdminRole // UserRole is a standard user UserRole )
type AccessToken ¶
type AccountRepo ¶
type AccountRepo interface { Create(*User) (*User, error) CreateAndVerify(*User) (*Verification, error) CreateForgotToken(*User) (*Verification, error) CreateNewOTP(*User) (*Verification, error) CreateWithMobile(*User) error CreateWithMagic(*User) (int, error) ResetPassword(*User) error ChangePassword(*User) error UpdateAvatar(*User) error Activate(*User) error FindVerificationToken(string) (*Verification, error) FindVerificationTokenByUser(*User) (*Verification, error) DeleteVerificationToken(*Verification) error }
AccountRepo represents account database interface (the repository)
type Asset ¶
type Asset struct { Base ID string `json:"id"` Class string `json:"class"` Exchange string `json:"exchange"` Symbol string `json:"symbol"` Name string `json:"name"` Status string `json:"status"` Tradable bool `json:"tradable"` Marginable bool `json:"marginable"` Shortable bool `json:"shortable"` EasyToBorrow bool `json:"easy_to_borrow"` Fractionable bool `json:"fractionable"` IsWatchlisted bool `json:"is_watchlisted"` }
type AssetsRepo ¶
type AuthService ¶
AuthService represents authentication service interface
type AuthToken ¶
type AuthToken struct { Token string `json:"token"` Expires string `json:"expires"` RefreshToken string `json:"refresh_token"` }
AuthToken holds authentication token details with refresh token
type AuthUser ¶
type AuthUser struct { ID int Username string Email string Role AccessRole }
AuthUser represents data stored in JWT token for user
type BankAccount ¶
type BankAccount struct { Base ID int `json:"id"` UserID int `json:"user_id"` AccessToken string `json:"access_token"` AccountID string `json:"account_id"` BankName string `json:"bank_name"` AccountName string `json:"account_name"` Status bool `json:"status"` }
Verification stores randomly generated tokens that can be redeemed
type Base ¶
type Base struct { CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `json:"deleted_at,omitempty"` }
Base contains common fields for all tables
func (*Base) BeforeInsert ¶
BeforeInsert hooks into insert operations, setting createdAt and updatedAt to current time
func (*Base) BeforeUpdate ¶
BeforeUpdate hooks into update operations, setting updatedAt to current time
type CoinStatement ¶
type CoinStatement struct { Base ID int `json:"id"` UserID int `json:"user_id"` Coins int `json:"coins"` Type string `json:"type"` Reason string `json:"reason"` Status bool `json:"status"` }
Verification stores randomly generated tokens that can be redeemed
type LoginResponseWithToken ¶
type LoginResponseWithToken struct { Token string `json:"token"` Expires string `json:"expires"` RefreshToken string `json:"refresh_token"` User User `json:"user"` }
LoginResponseWithToken holds authentication token details with refresh token
type Pagination ¶
Pagination holds pagination's data
type PlaidAuthToken ¶
type PlaidAuthToken struct {
LinkToken string `json:"link_token"`
}
type RBACService ¶
type RBACService interface { EnforceRole(*gin.Context, AccessRole) bool EnforceUser(*gin.Context, int) bool AccountCreate(*gin.Context, int) bool IsLowerRole(*gin.Context, AccessRole) bool }
RBACService represents role-based access control service interface
type ReferralCodeVerifyResponse ¶
type ReferralCodeVerifyResponse struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` Username string `json:"username"` ReferralCode string `json:"referral_code"` }
ReferralCodeVerifyResponse
type RefreshToken ¶
RefreshToken holds authentication token details
type Role ¶
type Role struct { ID int `json:"id"` AccessLevel AccessRole `json:"access_level"` Name string `json:"name"` }
Role model
type RoleRepo ¶
type RoleRepo interface {
CreateRoles() error
}
RoleRepo represents the database interface
type User ¶
type User struct { Base ID int `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Username string `json:"username"` Password string `json:"-"` Email string `json:"email"` Mobile string `json:"mobile"` CountryCode string `json:"country_code"` Address string `json:"address"` LastLogin *time.Time `json:"last_login,omitempty"` Verified bool `json:"verified"` Active bool `json:"active"` Token string `json:"-"` Role *Role `json:"role,omitempty"` RoleID int `json:"-"` AccountID string `json:"account_id"` AccountNumber string `json:"account_number"` AccountCurrency string `json:"account_currency"` AccountStatus string `json:"account_status"` DOB string `json:"dob"` City string `json:"city"` State string `json:"state"` Country string `json:"country"` TaxIDType string `json:"tax_id_type"` TaxID string `json:"tax_id"` FundingSource string `json:"funding_source"` EmploymentStatus string `json:"employment_status"` InvestingExperience string `json:"investing_experience"` AnotherBrokerage string `json:"another_brokerage"` DeviceID string `json:"device_id"` ProfileCompletion string `json:"profile_completion"` BIO string `json:"bio"` FacebookURL string `json:"facebook_url"` TwitterURL string `json:"twitter_url"` InstagramURL string `json:"instagram_url"` PublicPortfolio string `json:"public_portfolio"` EmployerName string `json:"employer_name"` Occupation string `json:"occupation"` UnitApt string `json:"unit_apt"` ZipCode string `json:"zip_code"` StockSymbol string `json:"stock_symbol"` BrokerageFirmName string `json:"brokerage_firm_name"` BrokerageFirmEmployeeName string `json:"brokerage_firm_employee_name"` BrokerageFirmEmployeeRelationship string `json:"brokerage_firm_employee_relationship"` Avatar string `json:"avatar"` ReferredBy string `json:"referred_by"` ReferralCode string `json:"referral_code"` WatchlistID string `json:"watchlist_id"` PerAccountLimit float64 `json:"per_account_limit"` }
User represents user domain model
func (*User) UpdateLastLogin ¶
func (u *User) UpdateLastLogin()
UpdateLastLogin updates last login field
type UserRepo ¶
type UserRepo interface { View(int) (*User, error) FindByUsername(string) (*User, error) FindByReferralCode(string) (*ReferralCodeVerifyResponse, error) FindByEmail(string) (*User, error) FindByMobile(string, string) (*User, error) FindByToken(string) (*User, error) UpdateLogin(*User) error List(*ListQuery, *Pagination) ([]User, error) Update(*User) (*User, error) Delete(*User) error }
UserRepo represents user database interface (the repository)
type UserReward ¶
type UserReward struct { Base ID int `json:"id"` UserID int `json:"user_id"` JournalID string `json:"journal_id"` ReferredBy int `json:"referred_by"` RewardValue float32 `json:"reward_value"` RewardType string `json:"reward_type"` RewardTransferStatus bool `json:"reward_transfer_status"` ErrorResponse string `json:"error_response"` }