db

package
v0.0.0-...-17f2f0b Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UniqueViolation = "23505"
)

Variables

View Source
var ErrRecordNotFound = pgx.ErrNoRows
View Source
var ErrUniqueViolation = &pgconn.PgError{
	Code: UniqueViolation,
}

Functions

func ErrorCode

func ErrorCode(err error) string

Types

type AdministrativeStatus

type AdministrativeStatus string
const (
	AdministrativeStatusAdmActive    AdministrativeStatus = "adm:active"
	AdministrativeStatusAdmBlocked   AdministrativeStatus = "adm:blocked"
	AdministrativeStatusAdmSuspended AdministrativeStatus = "adm:suspended"
	AdministrativeStatusAdmProcessed AdministrativeStatus = "adm:processed"
)

func (*AdministrativeStatus) Scan

func (e *AdministrativeStatus) Scan(src interface{}) error

type ClientProfile

type ClientProfile struct {
	ID uuid.UUID `json:"id"`
	// Client status set by the system admin
	Adm AdministrativeStatus `json:"adm"`
	// Client status from security service (Know Your Client)
	Kyc             KycStatus `json:"kyc"`
	Name            string    `json:"name"`
	Surname         string    `json:"surname"`
	Updated         time.Time `json:"updated"`
	Created         time.Time `json:"created"`
	Password        string    `json:"password"`
	Email           string    `json:"email"`
	PasswordUpdated time.Time `json:"password_updated"`
}

Account holders profile

type ClientSession

type ClientSession struct {
	ID      uuid.UUID `json:"id"`
	Sub     uuid.UUID `json:"sub"`
	Refresh string    `json:"refresh"`
	Agent   string    `json:"agent"`
	Ip      string    `json:"ip"`
	Blocked bool      `json:"blocked"`
	Expires time.Time `json:"expires"`
	Created time.Time `json:"created"`
}

type CreateClientProfileParams

type CreateClientProfileParams struct {
	ID       uuid.UUID            `json:"id"`
	Adm      AdministrativeStatus `json:"adm"`
	Kyc      KycStatus            `json:"kyc"`
	Name     string               `json:"name"`
	Surname  string               `json:"surname"`
	Password string               `json:"password"`
	Email    string               `json:"email"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID      uuid.UUID `json:"id"`
	Sub     uuid.UUID `json:"sub"`
	Refresh string    `json:"refresh"`
	Agent   string    `json:"agent"`
	Ip      string    `json:"ip"`
	Blocked bool      `json:"blocked"`
	Expires time.Time `json:"expires"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetClientPasswordByIdRow

type GetClientPasswordByIdRow struct {
	Password        string    `json:"password"`
	PasswordUpdated time.Time `json:"password_updated"`
}

type KycStatus

type KycStatus string
const (
	KycStatusKycUnconfirmed  KycStatus = "kyc:unconfirmed"
	KycStatusKycConfirmed    KycStatus = "kyc:confirmed"
	KycStatusKycPending      KycStatus = "kyc:pending"
	KycStatusKycRejected     KycStatus = "kyc:rejected"
	KycStatusKycResubmission KycStatus = "kyc:resubmission"
	KycStatusKycInitiated    KycStatus = "kyc:initiated"
)

func (*KycStatus) Scan

func (e *KycStatus) Scan(src interface{}) error

type NullAdministrativeStatus

type NullAdministrativeStatus struct {
	AdministrativeStatus AdministrativeStatus `json:"administrative_status"`
	Valid                bool                 `json:"valid"` // Valid is true if AdministrativeStatus is not NULL
}

func (*NullAdministrativeStatus) Scan

func (ns *NullAdministrativeStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAdministrativeStatus) Value

Value implements the driver Valuer interface.

type NullKycStatus

type NullKycStatus struct {
	KycStatus KycStatus `json:"kyc_status"`
	Valid     bool      `json:"valid"` // Valid is true if KycStatus is not NULL
}

func (*NullKycStatus) Scan

func (ns *NullKycStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullKycStatus) Value

func (ns NullKycStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Querier

type Querier interface {
	CreateClientProfile(ctx context.Context, arg CreateClientProfileParams) (uuid.UUID, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (ClientSession, error)
	DeleteClientProfile(ctx context.Context, id uuid.UUID) error
	GetClientPasswordById(ctx context.Context, id uuid.UUID) (GetClientPasswordByIdRow, error)
	GetClientProfile(ctx context.Context, id uuid.UUID) (ClientProfile, error)
	GetClientProfileByEmail(ctx context.Context, email string) (ClientProfile, error)
	GetSession(ctx context.Context, id uuid.UUID) (ClientSession, error)
	UpdateClientPassword(ctx context.Context, arg UpdateClientPasswordParams) error
	UpdateClientProfile(ctx context.Context, arg UpdateClientProfileParams) error
	UpdateClientStatus(ctx context.Context, arg UpdateClientStatusParams) error
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) CreateClientProfile

func (q *Queries) CreateClientProfile(ctx context.Context, arg CreateClientProfileParams) (uuid.UUID, error)

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (ClientSession, error)

func (*Queries) DeleteClientProfile

func (q *Queries) DeleteClientProfile(ctx context.Context, id uuid.UUID) error

func (*Queries) GetClientPasswordById

func (q *Queries) GetClientPasswordById(ctx context.Context, id uuid.UUID) (GetClientPasswordByIdRow, error)

func (*Queries) GetClientProfile

func (q *Queries) GetClientProfile(ctx context.Context, id uuid.UUID) (ClientProfile, error)

func (*Queries) GetClientProfileByEmail

func (q *Queries) GetClientProfileByEmail(ctx context.Context, email string) (ClientProfile, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, id uuid.UUID) (ClientSession, error)

func (*Queries) UpdateClientPassword

func (q *Queries) UpdateClientPassword(ctx context.Context, arg UpdateClientPasswordParams) error

func (*Queries) UpdateClientProfile

func (q *Queries) UpdateClientProfile(ctx context.Context, arg UpdateClientProfileParams) error

func (*Queries) UpdateClientStatus

func (q *Queries) UpdateClientStatus(ctx context.Context, arg UpdateClientStatusParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type SQLStore

type SQLStore struct {
	*Queries
	// contains filtered or unexported fields
}

type Store

type Store interface {
	Querier
}

Store defines all functions to execute db queries and transactions

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

NewStore creates a new store

type UpdateClientPasswordParams

type UpdateClientPasswordParams struct {
	ID       uuid.UUID `json:"id"`
	Password string    `json:"password"`
}

type UpdateClientProfileParams

type UpdateClientProfileParams struct {
	ID      uuid.UUID   `json:"id"`
	Name    pgtype.Text `json:"name"`
	Surname pgtype.Text `json:"surname"`
	Email   pgtype.Text `json:"email"`
}

type UpdateClientStatusParams

type UpdateClientStatusParams struct {
	ID  uuid.UUID                `json:"id"`
	Adm NullAdministrativeStatus `json:"adm"`
	Kyc NullKycStatus            `json:"kyc"`
}

Jump to

Keyboard shortcuts

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