model

package
v0.0.0-...-8cb3723 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Models []interface{}

Models hold registered models in-memory

Functions

func Register

func Register(m interface{})

Register is used for registering models

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 AccessToken struct {
	ID          int    `json:"id"`
	PublicToken string `json:"public_token"`
	ItemID      string `json:"item_id"`
}

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 AssetsRepo interface {
	CreateOrUpdate(*Asset) (*Asset, error)
	UpdateAsset(*Asset) error
	Search(string) ([]Asset, error)
}

type AuthService

type AuthService interface {
	User(*gin.Context) *AuthUser
}

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

func (b *Base) BeforeInsert(ctx context.Context) (context.Context, error)

BeforeInsert hooks into insert operations, setting createdAt and updatedAt to current time

func (*Base) BeforeUpdate

func (b *Base) BeforeUpdate(ctx context.Context) (context.Context, error)

BeforeUpdate hooks into update operations, setting updatedAt to current time

func (*Base) Delete

func (b *Base) Delete()

Delete sets deleted_at time 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 ListQuery

type ListQuery struct {
	Query string
	ID    int
}

ListQuery holds company/location data used for list db queries

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

type Pagination struct {
	Limit  int
	Offset int
}

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

type RefreshToken struct {
	Token   string `json:"token"`
	Expires string `json:"expires"`
}

RefreshToken holds authentication token details

type Reward

type Reward struct {
	Base
	ID                   int     `json:"id"`
	PerAccountLimit      int     `json:"per_account_limit"`
	ReferralKycReward    float64 `json:"referral_kyc_reward"`
	ReferralSignupReward float64 `json:"referral_signup_reward"`
	ReferreKycReward     float64 `json:"referre_Kyc_reward"`
}

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"`
	PublicShareholder                 string     `json:"public_shareholder"`
	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"`
	ShareholderCompanyName            string     `json:"shareholder_company_name"`
	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) Delete

func (u *User) Delete()

Delete updates the deleted_at field

func (*User) Update

func (u *User) Update()

Update updates the updated_at field

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"`
}

type Verification

type Verification struct {
	Base
	ID     int    `json:"id"`
	Token  string `json:"token"`
	UserID int    `json:"user_id"`
}

Verification stores randomly generated tokens that can be redeemed

Jump to

Keyboard shortcuts

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