Documentation ¶
Index ¶
- Constants
- Variables
- func AssociateAssetWithWalletFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, ...)
- func BuildSetClause(u interface{}) (string, []interface{})
- func CompareVerificationValue(hashedValue, verificationValue string) bool
- func CreateInstructionsFixture(t *testing.T, instructions []*DisbursementInstruction) []byte
- func CreateMockImage(t *testing.T, width, height int, size ImageSize) image.Image
- func DeleteAllAssetFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DeleteAllDisbursementFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DeleteAllFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DeleteAllMessagesFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DeleteAllPaymentsFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DeleteAllReceiverVerificationFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DeleteAllReceiverWalletsFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DeleteAllReceiversFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DeleteAllWalletFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter)
- func DisableDisbursementApproval(t *testing.T, ctx context.Context, orgModel *OrganizationModel)
- func EnableDisbursementApproval(t *testing.T, ctx context.Context, orgModel *OrganizationModel)
- func EnableOrDisableWalletFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, enabled bool, ...)
- func FromUserRoleArrayToStringArray(roles []UserRole) []string
- func HashVerificationValue(verificationValue string) (string, error)
- func MakeWalletUserManaged(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, walletID string)
- func UpdateDisbursementInstructionsFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, ...)
- type Amount
- type Asset
- func ClearAndCreateAssetFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter) []Asset
- func CreateAssetFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, code, issuer string) *Asset
- func CreateWalletAssets(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, walletID string, ...) []Asset
- func GetAssetFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, code string) *Asset
- func GetWalletAssetsFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, walletID string) []Asset
- type AssetModel
- func (a *AssetModel) Get(ctx context.Context, id string) (*Asset, error)
- func (a *AssetModel) GetAll(ctx context.Context) ([]Asset, error)
- func (a *AssetModel) GetAssetsPerReceiverWallet(ctx context.Context, receiverWallets ...*ReceiverWallet) ([]ReceiverWalletAsset, error)
- func (a *AssetModel) GetByCodeAndIssuer(ctx context.Context, code, issuer string) (*Asset, error)
- func (a *AssetModel) GetByWalletID(ctx context.Context, walletID string) ([]Asset, error)
- func (a *AssetModel) GetOrCreate(ctx context.Context, code, issuer string) (*Asset, error)
- func (a *AssetModel) Insert(ctx context.Context, sqlExec db.SQLExecuter, code string, issuer string) (*Asset, error)
- func (a *AssetModel) SoftDelete(ctx context.Context, sqlExec db.SQLExecuter, id string) (*Asset, error)
- type CircleTransferRequest
- type CircleTransferRequestModel
- func (m CircleTransferRequestModel) Get(ctx context.Context, sqlExec db.SQLExecuter, queryParams QueryParams) (*CircleTransferRequest, error)
- func (m CircleTransferRequestModel) GetAll(ctx context.Context, sqlExec db.SQLExecuter, queryParams QueryParams) ([]*CircleTransferRequest, error)
- func (m CircleTransferRequestModel) GetCurrentTransfersForPaymentIDs(ctx context.Context, sqlExec db.SQLExecuter, paymentIDs []string) (map[string]*CircleTransferRequest, error)
- func (m CircleTransferRequestModel) GetIncompleteByPaymentID(ctx context.Context, sqlExec db.SQLExecuter, paymentID string) (*CircleTransferRequest, error)
- func (m CircleTransferRequestModel) GetOrInsert(ctx context.Context, paymentID string) (*CircleTransferRequest, error)
- func (m CircleTransferRequestModel) GetPendingReconciliation(ctx context.Context, sqlExec db.SQLExecuter) ([]*CircleTransferRequest, error)
- func (m CircleTransferRequestModel) Insert(ctx context.Context, paymentID string) (*CircleTransferRequest, error)
- func (m CircleTransferRequestModel) Update(ctx context.Context, sqlExec db.SQLExecuter, idempotencyKey string, ...) (*CircleTransferRequest, error)
- type CircleTransferRequestUpdate
- type CircleTransferStatus
- type Disbursement
- type DisbursementInstruction
- type DisbursementInstructionModel
- type DisbursementInstructionsOpts
- type DisbursementModel
- func (d *DisbursementModel) CompleteDisbursements(ctx context.Context, sqlExec db.SQLExecuter, disbursementIDs []string) error
- func (d *DisbursementModel) Count(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams) (int, error)
- func (d *DisbursementModel) Get(ctx context.Context, sqlExec db.SQLExecuter, id string) (*Disbursement, error)
- func (d *DisbursementModel) GetAll(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams) ([]*Disbursement, error)
- func (d *DisbursementModel) GetByName(ctx context.Context, sqlExec db.SQLExecuter, name string) (*Disbursement, error)
- func (d *DisbursementModel) GetWithStatistics(ctx context.Context, id string) (*Disbursement, error)
- func (d *DisbursementModel) Insert(ctx context.Context, disbursement *Disbursement) (string, error)
- func (d *DisbursementModel) Update(ctx context.Context, du *DisbursementUpdate) error
- func (d *DisbursementModel) UpdateStatus(ctx context.Context, sqlExec db.SQLExecuter, userID string, ...) error
- type DisbursementReceiver
- type DisbursementReceiverModel
- type DisbursementStats
- type DisbursementStatus
- type DisbursementStatusHistory
- type DisbursementStatusHistoryEntry
- type DisbursementUpdate
- type Filter
- type FilterKey
- type ImageSize
- type LogoType
- type Message
- type MessageChannelPriority
- type MessageInsert
- type MessageModel
- type MessageStatus
- type MessageStatusHistory
- type MessageStatusHistoryEntry
- type Models
- type Organization
- type OrganizationModel
- type OrganizationUpdate
- type Payment
- type PaymentInsert
- type PaymentModel
- func (p *PaymentModel) CancelPaymentsWithinPeriodDays(ctx context.Context, sqlExec db.SQLExecuter, periodInDays int64) error
- func (p *PaymentModel) Count(ctx context.Context, queryParams *QueryParams, sqlExec db.SQLExecuter) (int, error)
- func (p *PaymentModel) DeleteAllForDisbursement(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string) error
- func (p *PaymentModel) Get(ctx context.Context, id string, sqlExec db.SQLExecuter) (*Payment, error)
- func (p *PaymentModel) GetAll(ctx context.Context, queryParams *QueryParams, sqlExec db.SQLExecuter) ([]Payment, error)
- func (p *PaymentModel) GetAllReadyToPatchCompletionAnchorTransactions(ctx context.Context, sqlExec db.SQLExecuter) ([]Payment, error)
- func (p *PaymentModel) GetBatchForUpdate(ctx context.Context, sqlExec db.SQLExecuter, batchSize int) ([]*Payment, error)
- func (p *PaymentModel) GetByIDs(ctx context.Context, sqlExec db.SQLExecuter, paymentIDs []string) ([]*Payment, error)
- func (p *PaymentModel) GetReadyByDisbursementID(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string) ([]*Payment, error)
- func (p *PaymentModel) GetReadyByID(ctx context.Context, sqlExec db.SQLExecuter, paymentIDs ...string) ([]*Payment, error)
- func (p *PaymentModel) GetReadyByReceiverWalletID(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletID string) ([]*Payment, error)
- func (p *PaymentModel) InsertAll(ctx context.Context, sqlExec db.SQLExecuter, inserts []PaymentInsert) error
- func (p *PaymentModel) RetryFailedPayments(ctx context.Context, sqlExec db.SQLExecuter, email string, ...) error
- func (p *PaymentModel) Update(ctx context.Context, sqlExec db.SQLExecuter, payment *Payment, ...) error
- func (p *PaymentModel) UpdateStatus(ctx context.Context, sqlExec db.SQLExecuter, paymentID string, ...) error
- func (p *PaymentModel) UpdateStatusByDisbursementID(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string, ...) error
- func (p *PaymentModel) UpdateStatuses(ctx context.Context, sqlExec db.SQLExecuter, payments []*Payment, ...) (int64, error)
- type PaymentStatus
- type PaymentStatusHistory
- type PaymentStatusHistoryEntry
- type PaymentUpdate
- type QueryBuilder
- func (qb *QueryBuilder) AddCondition(condition string, value ...interface{}) *QueryBuilder
- func (qb *QueryBuilder) AddGroupBy(fields string) *QueryBuilder
- func (qb *QueryBuilder) AddOrCondition(condition string, value ...interface{}) *QueryBuilder
- func (qb *QueryBuilder) AddPagination(page int, pageLimit int) *QueryBuilder
- func (qb *QueryBuilder) AddSorting(sortField SortField, sortOrder SortOrder, prefix string) *QueryBuilder
- func (qb *QueryBuilder) Build() (string, []interface{})
- func (qb *QueryBuilder) BuildAndRebind(sqlExec db.SQLExecuter) (string, []interface{})
- type QueryParams
- type ReceivedAmounts
- type Receiver
- type ReceiverContactType
- type ReceiverIDs
- type ReceiverInsert
- type ReceiverModel
- func (r *ReceiverModel) Count(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams) (int, error)
- func (r *ReceiverModel) DeleteByContactInfo(ctx context.Context, dbConnectionPool db.DBConnectionPool, contactInfo string) error
- func (r *ReceiverModel) Get(ctx context.Context, sqlExec db.SQLExecuter, id string) (*Receiver, error)
- func (r *ReceiverModel) GetAll(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams) ([]Receiver, error)
- func (r *ReceiverModel) GetByContacts(ctx context.Context, sqlExec db.SQLExecuter, contacts ...string) ([]*Receiver, error)
- func (r *ReceiverModel) Insert(ctx context.Context, sqlExec db.SQLExecuter, insert ReceiverInsert) (*Receiver, error)
- func (r *ReceiverModel) ParseReceiverIDs(receivers []Receiver) ReceiverIDs
- func (r *ReceiverModel) Update(ctx context.Context, sqlExec db.SQLExecuter, ID string, ...) error
- type ReceiverRegistrationRequest
- type ReceiverStats
- type ReceiverUpdate
- type ReceiverVerification
- type ReceiverVerificationInsert
- type ReceiverVerificationModel
- func (*ReceiverVerificationModel) ExceededAttempts(attempts int) bool
- func (m *ReceiverVerificationModel) GetAllByReceiverId(ctx context.Context, sqlExec db.SQLExecuter, receiverId string) ([]ReceiverVerification, error)
- func (m *ReceiverVerificationModel) GetByReceiverIDsAndVerificationField(ctx context.Context, sqlExec db.SQLExecuter, receiverIds []string, ...) ([]*ReceiverVerification, error)
- func (m *ReceiverVerificationModel) GetLatestByContactInfo(ctx context.Context, contactInfo string) (*ReceiverVerification, error)
- func (m *ReceiverVerificationModel) Insert(ctx context.Context, sqlExec db.SQLExecuter, ...) (string, error)
- func (m *ReceiverVerificationModel) UpdateReceiverVerification(ctx context.Context, update ReceiverVerificationUpdate, sqlExec db.SQLExecuter) error
- func (m *ReceiverVerificationModel) UpdateVerificationValue(ctx context.Context, sqlExec db.SQLExecuter, receiverID string, ...) error
- func (m *ReceiverVerificationModel) UpsertVerificationValue(ctx context.Context, sqlExec db.SQLExecuter, receiverID string, ...) error
- type ReceiverVerificationUpdate
- type ReceiverWallet
- type ReceiverWalletAsset
- type ReceiverWalletInsert
- type ReceiverWalletModel
- func (rw *ReceiverWalletModel) GetAllPendingRegistrationByDisbursementID(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string) ([]*ReceiverWallet, error)
- func (rw *ReceiverWalletModel) GetAllPendingRegistrationByReceiverWalletIDs(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletIDs []string) ([]*ReceiverWallet, error)
- func (rw *ReceiverWalletModel) GetAllPendingRegistrations(ctx context.Context, sqlExec db.SQLExecuter) ([]*ReceiverWallet, error)
- func (rw *ReceiverWalletModel) GetByIDs(ctx context.Context, sqlExec db.SQLExecuter, ids ...string) ([]ReceiverWallet, error)
- func (rw *ReceiverWalletModel) GetByReceiverIDAndWalletDomain(ctx context.Context, receiverId string, walletDomain string, ...) (*ReceiverWallet, error)
- func (rw *ReceiverWalletModel) GetByReceiverIDsAndWalletID(ctx context.Context, sqlExec db.SQLExecuter, receiverIds []string, ...) ([]*ReceiverWallet, error)
- func (rw *ReceiverWalletModel) GetByStellarAccountAndMemo(ctx context.Context, stellarAccount, stellarMemo, clientDomain string) (*ReceiverWallet, error)
- func (rw *ReceiverWalletModel) GetWithReceiverIds(ctx context.Context, sqlExec db.SQLExecuter, receiverIds ReceiverIDs) ([]ReceiverWallet, error)
- func (rw *ReceiverWalletModel) Insert(ctx context.Context, sqlExec db.SQLExecuter, insert ReceiverWalletInsert) (string, error)
- func (rw *ReceiverWalletModel) RetryInvitationMessage(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletId string) (*ReceiverWallet, error)
- func (rw *ReceiverWalletModel) Update(ctx context.Context, id string, update ReceiverWalletUpdate, ...) error
- func (rw *ReceiverWalletModel) UpdateAnchorPlatformTransactionSyncedAt(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletID ...string) ([]ReceiverWallet, error)
- func (rw *ReceiverWalletModel) UpdateInvitationSentAt(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletID ...string) ([]ReceiverWallet, error)
- func (rw *ReceiverWalletModel) UpdateOTPByReceiverContactInfoAndWalletDomain(ctx context.Context, receiverContactInfo, sep10ClientDomain, otp string) (numberOfUpdatedRows int, err error)
- func (rw *ReceiverWalletModel) UpdateStatusByDisbursementID(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string, ...) error
- func (rw *ReceiverWalletModel) VerifyReceiverWalletOTP(ctx context.Context, networkPassphrase string, receiverWallet ReceiverWallet, ...) error
- type ReceiverWalletStats
- type ReceiverWalletUpdate
- type ReceiversWalletStatus
- type ReceiversWalletStatusHistory
- type ReceiversWalletStatusHistoryEntry
- type RegistrationContactType
- func (rct RegistrationContactType) MarshalJSON() ([]byte, error)
- func (rct *RegistrationContactType) ParseFromString(input string) error
- func (rct *RegistrationContactType) Scan(value interface{}) error
- func (rct RegistrationContactType) String() string
- func (rct *RegistrationContactType) UnmarshalJSON(data []byte) error
- func (rct RegistrationContactType) Value() (driver.Value, error)
- type SortField
- type SortOrder
- type State
- type StateMachine
- func DisbursementStateMachineWithInitialState(initialState DisbursementStatus) *StateMachine
- func NewStateMachine(initialState State, transitions []StateTransition) *StateMachine
- func PaymentStateMachineWithInitialState(initialState PaymentStatus) *StateMachine
- func ReceiversWalletStateMachineWithInitialState(initialState ReceiversWalletStatus) *StateMachine
- type StateTransition
- type UserRole
- type VerificationType
- type Wallet
- func ClearAndCreateWalletFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter) []Wallet
- func CreateDefaultWalletFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter) *Wallet
- func CreateWalletFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, ...) *Wallet
- func GetWalletFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, name string) *Wallet
- type WalletAssets
- type WalletInsert
- type WalletModel
- func (wm *WalletModel) FindWallets(ctx context.Context, filters ...Filter) ([]Wallet, error)
- func (wm *WalletModel) Get(ctx context.Context, id string) (*Wallet, error)
- func (wm *WalletModel) GetAll(ctx context.Context) ([]Wallet, error)
- func (wm *WalletModel) GetAssets(ctx context.Context, walletID string) ([]Asset, error)
- func (wm *WalletModel) GetByWalletName(ctx context.Context, name string) (*Wallet, error)
- func (wm *WalletModel) GetOrCreate(ctx context.Context, name, homepage, deepLink, sep10Domain string) (*Wallet, error)
- func (wm *WalletModel) Insert(ctx context.Context, newWallet WalletInsert) (*Wallet, error)
- func (w *WalletModel) SoftDelete(ctx context.Context, walletID string) (*Wallet, error)
- func (wm *WalletModel) Update(ctx context.Context, walletID string, enabled bool) (*Wallet, error)
Constants ¶
const ( DefaultReceiverRegistrationMessageTemplate = "You have a payment waiting for you from the {{.OrganizationName}}. Click {{.RegistrationLink}} to register." DefaultOTPMessageTemplate = "{{.OTP}} is your {{.OrganizationName}} verification code." )
const ( // TestnetAlwaysValidOTP is used for testing purposes and will be considered a valid OTP for any testnet account. TestnetAlwaysValidOTP = "000000" // TestnetAlwaysInvalidOTP is used for testing purposes and will be considered an invalid OTP for any testnet account. TestnetAlwaysInvalidOTP = "999999" )
const (
FixtureAssetUSDC = "USDC"
)
const MaxAttemptsAllowed = 15
const MaxInstructionsPerDisbursement = 10000
const OTPExpirationTimeMinutes = 30
Variables ¶
var ( ErrMaxInstructionsExceeded = errors.New("maximum number of instructions exceeded") ErrReceiverVerificationMismatch = errors.New("receiver verification mismatch") ErrReceiverWalletAddressMismatch = errors.New("receiver wallet address mismatch") )
var ( DefaultDisbursementSortField = SortFieldCreatedAt DefaultDisbursementSortOrder = SortOrderDESC AllowedDisbursementFilters = []FilterKey{FilterKeyStatus, FilterKeyCreatedAtAfter, FilterKeyCreatedAtBefore} AllowedDisbursementSorts = []SortField{SortFieldName, SortFieldCreatedAt} )
var ( ErrRecordNotFound = errors.New("record not found") ErrRecordAlreadyExists = errors.New("record already exists") ErrMismatchNumRowsAffected = errors.New("mismatch number of rows affected") ErrMissingInput = errors.New("missing input") )
var ( DefaultPaymentSortField = SortFieldUpdatedAt DefaultPaymentSortOrder = SortOrderDESC AllowedPaymentFilters = []FilterKey{FilterKeyStatus, FilterKeyCreatedAtAfter, FilterKeyCreatedAtBefore, FilterKeyReceiverID} AllowedPaymentSorts = []SortField{SortFieldCreatedAt, SortFieldUpdatedAt} )
var ( DefaultReceiverSortField = SortFieldUpdatedAt DefaultReceiverSortOrder = SortOrderDESC AllowedReceiverFilters = []FilterKey{FilterKeyStatus, FilterKeyCreatedAtAfter, FilterKeyCreatedAtBefore} AllowedReceiverSorts = []SortField{SortFieldCreatedAt, SortFieldUpdatedAt} )
var ( RegistrationContactTypeEmail = RegistrationContactType{ReceiverContactTypeEmail, false} RegistrationContactTypePhone = RegistrationContactType{ReceiverContactTypeSMS, false} RegistrationContactTypeEmailAndWalletAddress = RegistrationContactType{ReceiverContactTypeEmail, true} RegistrationContactTypePhoneAndWalletAddress = RegistrationContactType{ReceiverContactTypeSMS, true} )
var ( ErrWalletNameAlreadyExists = errors.New("a wallet with this name already exists") ErrWalletHomepageAlreadyExists = errors.New("a wallet with this homepage already exists") ErrWalletDeepLinkSchemaAlreadyExists = errors.New("a wallet with this deep link schema already exists") ErrInvalidAssetID = errors.New("invalid asset ID") )
var DefaultMessageChannelPriority = MessageChannelPriority{ message.MessageChannelSMS, message.MessageChannelEmail, }
Functions ¶
func AssociateAssetWithWalletFixture ¶
func AssociateAssetWithWalletFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, assetID, walletID string)
AssociateAssetWithWalletFixture associates an asset with a wallet
func BuildSetClause ¶
func BuildSetClause(u interface{}) (string, []interface{})
BuildSetClause builds a SET clause for an UPDATE query based on the provided struct and its "db" tags. For instance, given the following struct:
type User struct { ID int64 `db:"id"` Name string `db:"name"` }
The function will return the following string and slice when called with an instance of `User{ID: 1, Name: "John"}`: "id = ?, name = ?", []interface{}{1, "John"}
func CreateInstructionsFixture ¶
func CreateInstructionsFixture(t *testing.T, instructions []*DisbursementInstruction) []byte
func CreateMockImage ¶
CreateMockImage creates an RGBA image with the given proportion and size. The size is defined by how many different colors are drawn in the image, so the compression format (jpeg or png) will generate a larger file since the image will have more complexity. Note: Depending on the compression format the image size may vary.
Example creating a file:
img := CreateMockImage(t, 3840, 2160, ImageSizeLarge) f, err := os.Create("image.png") require.NoError(t, err) err = jpeg.Encode(f, img, &jpeg.Options{Quality: jpeg.DefaultQuality} require.NoError(t, err)
Example in memory image:
img := CreateMockImage(t, 1920, 1080, ImageSizeMedium) buf := new(bytes.Buffer) err = png.Encode(buf, img) require.NoError(t, err) fmt.Println(img.Bytes())
func DeleteAllAssetFixtures ¶
DeleteAllAssetFixtures deletes all assets in the database
func DeleteAllFixtures ¶
func DeleteAllWalletFixtures ¶
DeleteAllWalletFixtures deletes all wallets in the database
func DisableDisbursementApproval ¶
func DisableDisbursementApproval(t *testing.T, ctx context.Context, orgModel *OrganizationModel)
DisableDisbursementApproval disables disbursement workflow approval for the given organization.
func EnableDisbursementApproval ¶
func EnableDisbursementApproval(t *testing.T, ctx context.Context, orgModel *OrganizationModel)
EnableDisbursementApproval enables disbursement workflow approval for the given organization.
func FromUserRoleArrayToStringArray ¶
FromUserRoleArrayToStringArray converts an array of UserRole type to an array of string
func HashVerificationValue ¶
func MakeWalletUserManaged ¶
func UpdateDisbursementInstructionsFixture ¶
func UpdateDisbursementInstructionsFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, disbursementID, fileName string, instructions []*DisbursementInstruction)
Types ¶
type Asset ¶
type Asset struct { ID string `json:"id" db:"id"` Code string `json:"code" db:"code"` Issuer string `json:"issuer" db:"issuer"` CreatedAt *time.Time `json:"created_at,omitempty" db:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` DeletedAt *time.Time `json:"deleted_at" db:"deleted_at"` }
func ClearAndCreateAssetFixtures ¶
ClearAndCreateAssetFixtures deletes all assets in the database then creates new assets for testing
func CreateAssetFixture ¶
func CreateWalletAssets ¶
func GetAssetFixture ¶
func GetWalletAssetsFixture ¶
type AssetModel ¶
type AssetModel struct {
// contains filtered or unexported fields
}
func (*AssetModel) GetAll ¶
func (a *AssetModel) GetAll(ctx context.Context) ([]Asset, error)
GetAll returns all assets in the database.
func (*AssetModel) GetAssetsPerReceiverWallet ¶
func (a *AssetModel) GetAssetsPerReceiverWallet(ctx context.Context, receiverWallets ...*ReceiverWallet) ([]ReceiverWalletAsset, error)
GetAssetsPerReceiverWallet returns the assets associated with a READY payment for each receiver wallet provided.
func (*AssetModel) GetByCodeAndIssuer ¶
GetByCodeAndIssuer returns asset filtering by code and issuer.
func (*AssetModel) GetByWalletID ¶
GetByWalletID returns all assets associated with a wallet.
func (*AssetModel) GetOrCreate ¶
func (*AssetModel) Insert ¶
func (a *AssetModel) Insert(ctx context.Context, sqlExec db.SQLExecuter, code string, issuer string) (*Asset, error)
Insert is idempotent and returns a new asset if it doesn't exist or the existing one if it does, clearing the deleted_at field if it was marked as deleted.
func (*AssetModel) SoftDelete ¶
func (a *AssetModel) SoftDelete(ctx context.Context, sqlExec db.SQLExecuter, id string) (*Asset, error)
type CircleTransferRequest ¶
type CircleTransferRequest struct { IdempotencyKey string `db:"idempotency_key"` PaymentID string `db:"payment_id"` CircleTransferID *string `db:"circle_transfer_id"` Status *CircleTransferStatus `db:"status"` ResponseBody []byte `db:"response_body"` SourceWalletID *string `db:"source_wallet_id"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` CompletedAt *time.Time `db:"completed_at"` LastSyncAttemptAt *time.Time `db:"last_sync_attempt_at"` SyncAttempts int `db:"sync_attempts"` }
func CreateCircleTransferRequestFixture ¶
func CreateCircleTransferRequestFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, insert CircleTransferRequest) *CircleTransferRequest
type CircleTransferRequestModel ¶
type CircleTransferRequestModel struct {
// contains filtered or unexported fields
}
func (CircleTransferRequestModel) Get ¶
func (m CircleTransferRequestModel) Get(ctx context.Context, sqlExec db.SQLExecuter, queryParams QueryParams) (*CircleTransferRequest, error)
func (CircleTransferRequestModel) GetAll ¶
func (m CircleTransferRequestModel) GetAll(ctx context.Context, sqlExec db.SQLExecuter, queryParams QueryParams) ([]*CircleTransferRequest, error)
func (CircleTransferRequestModel) GetCurrentTransfersForPaymentIDs ¶
func (m CircleTransferRequestModel) GetCurrentTransfersForPaymentIDs(ctx context.Context, sqlExec db.SQLExecuter, paymentIDs []string) (map[string]*CircleTransferRequest, error)
func (CircleTransferRequestModel) GetIncompleteByPaymentID ¶
func (m CircleTransferRequestModel) GetIncompleteByPaymentID(ctx context.Context, sqlExec db.SQLExecuter, paymentID string) (*CircleTransferRequest, error)
func (CircleTransferRequestModel) GetOrInsert ¶
func (m CircleTransferRequestModel) GetOrInsert(ctx context.Context, paymentID string) (*CircleTransferRequest, error)
func (CircleTransferRequestModel) GetPendingReconciliation ¶
func (m CircleTransferRequestModel) GetPendingReconciliation(ctx context.Context, sqlExec db.SQLExecuter) ([]*CircleTransferRequest, error)
GetPendingReconciliation returns the pending Circle transfer requests that are in `pending` status and have not reached the maximum sync attempts.
func (CircleTransferRequestModel) Insert ¶
func (m CircleTransferRequestModel) Insert(ctx context.Context, paymentID string) (*CircleTransferRequest, error)
func (CircleTransferRequestModel) Update ¶
func (m CircleTransferRequestModel) Update(ctx context.Context, sqlExec db.SQLExecuter, idempotencyKey string, update CircleTransferRequestUpdate) (*CircleTransferRequest, error)
type CircleTransferRequestUpdate ¶
type CircleTransferRequestUpdate struct { CircleTransferID string `db:"circle_transfer_id"` Status CircleTransferStatus `db:"status"` ResponseBody []byte `db:"response_body"` SourceWalletID string `db:"source_wallet_id"` CompletedAt *time.Time `db:"completed_at"` LastSyncAttemptAt *time.Time `db:"last_sync_attempt_at"` SyncAttempts int `db:"sync_attempts"` }
type CircleTransferStatus ¶
type CircleTransferStatus string
const ( CircleTransferStatusPending CircleTransferStatus = "pending" CircleTransferStatusSuccess CircleTransferStatus = "complete" // means success CircleTransferStatusFailed CircleTransferStatus = "failed" )
func CompletedCircleStatuses ¶
func CompletedCircleStatuses() []CircleTransferStatus
func (CircleTransferStatus) IsCompleted ¶
func (s CircleTransferStatus) IsCompleted() bool
type Disbursement ¶
type Disbursement struct { ID string `json:"id" db:"id"` Name string `json:"name" db:"name"` Wallet *Wallet `json:"wallet,omitempty" db:"wallet"` Asset *Asset `json:"asset,omitempty" db:"asset"` Status DisbursementStatus `json:"status" db:"status"` VerificationField VerificationType `json:"verification_field,omitempty" db:"verification_field"` StatusHistory DisbursementStatusHistory `json:"status_history,omitempty" db:"status_history"` ReceiverRegistrationMessageTemplate string `json:"receiver_registration_message_template" db:"receiver_registration_message_template"` FileName string `json:"file_name,omitempty" db:"file_name"` FileContent []byte `json:"-" db:"file_content"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` RegistrationContactType RegistrationContactType `json:"registration_contact_type,omitempty" db:"registration_contact_type"` *DisbursementStats }
func CreateDisbursementFixture ¶
func CreateDisbursementFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, model *DisbursementModel, d *Disbursement) *Disbursement
func CreateDraftDisbursementFixture ¶
func CreateDraftDisbursementFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, model *DisbursementModel, insert Disbursement) *Disbursement
type DisbursementInstruction ¶
type DisbursementInstruction struct { Phone string `csv:"phone"` Email string `csv:"email"` ID string `csv:"id"` Amount string `csv:"amount"` VerificationValue string `csv:"verification"` ExternalPaymentId string `csv:"paymentID"` WalletAddress string `csv:"walletAddress"` }
func (*DisbursementInstruction) Contact ¶
func (di *DisbursementInstruction) Contact() (string, error)
type DisbursementInstructionModel ¶
type DisbursementInstructionModel struct {
// contains filtered or unexported fields
}
func NewDisbursementInstructionModel ¶
func NewDisbursementInstructionModel(dbConnectionPool db.DBConnectionPool) *DisbursementInstructionModel
NewDisbursementInstructionModel creates a new DisbursementInstructionModel.
func (DisbursementInstructionModel) ProcessAll ¶
func (di DisbursementInstructionModel) ProcessAll(ctx context.Context, opts DisbursementInstructionsOpts) error
ProcessAll Processes all disbursement instructions and persists the data to the database.
|--- For each line in the instructions: | |--- Check if a receiver exists by their contact information (phone, email). | | |--- If a receiver does not exist, create one. | |--- For each receiver: | | |--- Check if the receiver verification exists. | | | |--- If the receiver verification does not exist, create one. | | | |--- If the receiver verification exists: | | | | |--- Check if the verification value matches. | | | | | |--- If the verification value does not match and the verification is confirmed, return an error. | | | | | |--- If the verification value does not match and the verification is not confirmed, update the verification value. | | | | | |--- If the verification value matches, continue. | | |--- [!ReceiverContactType.IncludesWalletAddress] Check if the receiver wallet exists. | | | |--- If the receiver wallet does not exist, create one. | | | |--- If the receiver wallet exists and it's not REGISTERED, retry the invitation SMS. | | |--- [ReceiverContactType.IncludesWalletAddress] Register the supplied wallet address | | |--- Delete all previously existing payments tied to this disbursement. | | |--- Create all payments passed in the instructions.
type DisbursementInstructionsOpts ¶
type DisbursementInstructionsOpts struct { UserID string Instructions []*DisbursementInstruction Disbursement *Disbursement DisbursementUpdate *DisbursementUpdate MaxNumberOfInstructions int }
type DisbursementModel ¶
type DisbursementModel struct {
// contains filtered or unexported fields
}
func (*DisbursementModel) CompleteDisbursements ¶
func (d *DisbursementModel) CompleteDisbursements(ctx context.Context, sqlExec db.SQLExecuter, disbursementIDs []string) error
CompleteDisbursements sets disbursements statuses to complete after all payments are processed and successfully sent.
func (*DisbursementModel) Count ¶
func (d *DisbursementModel) Count(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams) (int, error)
Count returns the number of disbursements matching the given query parameters.
func (*DisbursementModel) Get ¶
func (d *DisbursementModel) Get(ctx context.Context, sqlExec db.SQLExecuter, id string) (*Disbursement, error)
func (*DisbursementModel) GetAll ¶
func (d *DisbursementModel) GetAll(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams) ([]*Disbursement, error)
GetAll returns all disbursements matching the given query parameters.
func (*DisbursementModel) GetByName ¶
func (d *DisbursementModel) GetByName(ctx context.Context, sqlExec db.SQLExecuter, name string) (*Disbursement, error)
func (*DisbursementModel) GetWithStatistics ¶
func (d *DisbursementModel) GetWithStatistics(ctx context.Context, id string) (*Disbursement, error)
func (*DisbursementModel) Insert ¶
func (d *DisbursementModel) Insert(ctx context.Context, disbursement *Disbursement) (string, error)
func (*DisbursementModel) Update ¶
func (d *DisbursementModel) Update(ctx context.Context, du *DisbursementUpdate) error
func (*DisbursementModel) UpdateStatus ¶
func (d *DisbursementModel) UpdateStatus(ctx context.Context, sqlExec db.SQLExecuter, userID string, disbursementID string, targetStatus DisbursementStatus) error
UpdateStatus updates the status of the given disbursement.
type DisbursementReceiver ¶
type DisbursementReceiver struct { ID string `json:"id" db:"id"` Email string `json:"email,omitempty" db:"email"` PhoneNumber string `json:"phone_number" db:"phone_number"` ExternalID string `json:"external_id" db:"external_id"` ReceiverWallet *ReceiverWallet `json:"receiver_wallet" db:"receiver_wallet"` Payment *Payment `json:"payment" db:"payment"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type DisbursementReceiverModel ¶
type DisbursementReceiverModel struct {
// contains filtered or unexported fields
}
func (DisbursementReceiverModel) Count ¶
func (m DisbursementReceiverModel) Count(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string) (int, error)
func (DisbursementReceiverModel) GetAll ¶
func (m DisbursementReceiverModel) GetAll(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams, disbursementID string) ([]*DisbursementReceiver, error)
type DisbursementStats ¶
type DisbursementStats struct { TotalPayments int `json:"total_payments" db:"total_payments"` SuccessfulPayments int `json:"total_payments_sent" db:"total_payments_sent"` FailedPayments int `json:"total_payments_failed" db:"total_payments_failed"` CanceledPayments int `json:"total_payments_canceled" db:"total_payments_canceled"` RemainingPayments int `json:"total_payments_remaining" db:"total_payments_remaining"` AmountDisbursed string `json:"amount_disbursed" db:"amount_disbursed"` TotalAmount string `json:"total_amount" db:"total_amount"` AverageAmount string `json:"average_amount" db:"average_amount"` }
type DisbursementStatus ¶
type DisbursementStatus string
const ( DraftDisbursementStatus DisbursementStatus = "DRAFT" ReadyDisbursementStatus DisbursementStatus = "READY" StartedDisbursementStatus DisbursementStatus = "STARTED" PausedDisbursementStatus DisbursementStatus = "PAUSED" CompletedDisbursementStatus DisbursementStatus = "COMPLETED" )
func DisbursementStatuses ¶
func DisbursementStatuses() []DisbursementStatus
DisbursementStatuses returns a list of all possible disbursement statuses
func ToDisbursementStatus ¶
func ToDisbursementStatus(s string) (DisbursementStatus, error)
ToDisbursementStatus converts a string to a DisbursementStatus
func (DisbursementStatus) SourceStatuses ¶
func (status DisbursementStatus) SourceStatuses() []DisbursementStatus
SourceStatuses returns a list of states that the payment status can transition from given the target state
func (DisbursementStatus) State ¶
func (status DisbursementStatus) State() State
func (DisbursementStatus) TransitionTo ¶
func (status DisbursementStatus) TransitionTo(targetState DisbursementStatus) error
TransitionTo transitions the disbursement status to the target state
func (DisbursementStatus) Validate ¶
func (status DisbursementStatus) Validate() error
Validate validates the disbursement status
type DisbursementStatusHistory ¶
type DisbursementStatusHistory []DisbursementStatusHistoryEntry
func (*DisbursementStatusHistory) Scan ¶
func (dsh *DisbursementStatusHistory) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type DisbursementStatusHistoryEntry ¶
type DisbursementStatusHistoryEntry struct { UserID string `json:"user_id"` Status DisbursementStatus `json:"status"` Timestamp time.Time `json:"timestamp"` }
type DisbursementUpdate ¶
func (*DisbursementUpdate) Validate ¶
func (du *DisbursementUpdate) Validate() error
type FilterKey ¶
type FilterKey string
const ( FilterKeyStatus FilterKey = "status" FilterKeyReceiverID FilterKey = "receiver_id" FilterKeyPaymentID FilterKey = "payment_id" FilterKeyCompletedAt FilterKey = "completed_at" FilterKeyCreatedAtAfter FilterKey = "created_at_after" FilterKeyCreatedAtBefore FilterKey = "created_at_before" FilterKeySyncAttempts FilterKey = "sync_attempts" )
type Message ¶
type Message struct { ID string `db:"id"` Type message.MessengerType `db:"type"` AssetID *string `db:"asset_id"` ReceiverID string `db:"receiver_id"` WalletID string `db:"wallet_id"` ReceiverWalletID *string `db:"receiver_wallet_id"` TextEncrypted string `db:"text_encrypted"` TitleEncrypted string `db:"title_encrypted"` Status MessageStatus `db:"status"` StatusHistory MessageStatusHistory `db:"status_history"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` }
func CreateMessageFixture ¶
type MessageChannelPriority ¶
type MessageChannelPriority []message.MessageChannel
func (*MessageChannelPriority) Scan ¶
func (mcp *MessageChannelPriority) Scan(src interface{}) error
type MessageInsert ¶
type MessageInsert struct { Type message.MessengerType AssetID *string ReceiverID string WalletID string ReceiverWalletID *string TextEncrypted string TitleEncrypted string Status MessageStatus StatusHistory MessageStatusHistory }
type MessageModel ¶
type MessageModel struct {
// contains filtered or unexported fields
}
func (*MessageModel) BulkInsert ¶
func (m *MessageModel) BulkInsert(ctx context.Context, sqlExec db.SQLExecuter, newMsgs []*MessageInsert) error
func (*MessageModel) Insert ¶
func (m *MessageModel) Insert(ctx context.Context, newMsg *MessageInsert) (*Message, error)
type MessageStatus ¶
type MessageStatus string
var ( PendingMessageStatus MessageStatus = "PENDING" SuccessMessageStatus MessageStatus = "SUCCESS" FailureMessageStatus MessageStatus = "FAILURE" )
type MessageStatusHistory ¶
type MessageStatusHistory []MessageStatusHistoryEntry
func (*MessageStatusHistory) Scan ¶
func (msh *MessageStatusHistory) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type MessageStatusHistoryEntry ¶
type MessageStatusHistoryEntry struct { StatusMessage *string `json:"status_message"` Status MessageStatus `json:"status"` Timestamp time.Time `json:"timestamp"` }
type Models ¶
type Models struct { Disbursements *DisbursementModel Wallets *WalletModel Assets *AssetModel Organizations *OrganizationModel Payment *PaymentModel Receiver *ReceiverModel DisbursementInstructions *DisbursementInstructionModel ReceiverVerification *ReceiverVerificationModel ReceiverWallet *ReceiverWalletModel DisbursementReceivers *DisbursementReceiverModel Message *MessageModel CircleTransferRequests *CircleTransferRequestModel DBConnectionPool db.DBConnectionPool }
type Organization ¶
type Organization struct { ID string `json:"id" db:"id"` Name string `json:"name" db:"name"` TimezoneUTCOffset string `json:"timezone_utc_offset" db:"timezone_utc_offset"` // ReceiverInvitationResendInterval is the time period that SDP will wait to resend the invitation to the receivers that aren't registered. // If it's nil means resending the invitation is deactivated. ReceiverInvitationResendIntervalDays *int64 `json:"receiver_invitation_resend_interval_days" db:"receiver_invitation_resend_interval_days"` // PaymentCancellationPeriodDays is the number of days for a ready payment to be automatically cancelled. PaymentCancellationPeriodDays *int64 `json:"payment_cancellation_period_days" db:"payment_cancellation_period_days"` ReceiverRegistrationMessageTemplate string `json:"receiver_registration_message_template" db:"receiver_registration_message_template"` // OTPMessageTemplate is the message template to send the OTP code to the receivers validates their identity when registering their wallets. // The message may have the template values {{.OTP}} and {{.OrganizationName}}, it will be parsed and the values injected when executing the template. // When the {{.OTP}} is not found in the message, it's added at the beginning of the message. // Example: // {{.OTP}} OTPMessageTemplate OTPMessageTemplate string `json:"otp_message_template" db:"otp_message_template"` PrivacyPolicyLink *string `json:"privacy_policy_link" db:"privacy_policy_link"` Logo []byte `db:"logo"` IsApprovalRequired bool `json:"is_approval_required" db:"is_approval_required"` MessageChannelPriority MessageChannelPriority `json:"message_channel_priority" db:"message_channel_priority"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
type OrganizationModel ¶
type OrganizationModel struct {
// contains filtered or unexported fields
}
func (*OrganizationModel) Get ¶
func (om *OrganizationModel) Get(ctx context.Context) (*Organization, error)
func (*OrganizationModel) Update ¶
func (om *OrganizationModel) Update(ctx context.Context, ou *OrganizationUpdate) error
type OrganizationUpdate ¶
type OrganizationUpdate struct { Name string `json:",omitempty"` Logo []byte `json:",omitempty"` TimezoneUTCOffset string `json:",omitempty"` IsApprovalRequired *bool `json:",omitempty"` ReceiverInvitationResendIntervalDays *int64 `json:",omitempty"` PaymentCancellationPeriodDays *int64 `json:",omitempty"` // Using pointers to accept empty strings ReceiverRegistrationMessageTemplate *string `json:",omitempty"` OTPMessageTemplate *string `json:",omitempty"` PrivacyPolicyLink *string `json:",omitempty"` }
type Payment ¶
type Payment struct { ID string `json:"id" db:"id"` Amount string `json:"amount" db:"amount"` StellarTransactionID string `json:"stellar_transaction_id" db:"stellar_transaction_id"` // TODO: evaluate if we will keep or remove StellarOperationID StellarOperationID string `json:"stellar_operation_id" db:"stellar_operation_id"` Status PaymentStatus `json:"status" db:"status"` StatusHistory PaymentStatusHistory `json:"status_history,omitempty" db:"status_history"` Disbursement *Disbursement `json:"disbursement,omitempty" db:"disbursement"` Asset Asset `json:"asset"` ReceiverWallet *ReceiverWallet `json:"receiver_wallet,omitempty" db:"receiver_wallet"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` ExternalPaymentID string `json:"external_payment_id,omitempty" db:"external_payment_id"` CircleTransferRequestID *string `json:"circle_transfer_request_id,omitempty"` }
func CreatePaymentFixture ¶
func CreatePaymentFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, model *PaymentModel, p *Payment) *Payment
type PaymentInsert ¶
type PaymentInsert struct { ReceiverID string `db:"receiver_id"` DisbursementID string `db:"disbursement_id"` Amount string `db:"amount"` AssetID string `db:"asset_id"` ReceiverWalletID string `db:"receiver_wallet_id"` ExternalPaymentID *string `db:"external_payment_id"` }
func (*PaymentInsert) Validate ¶
func (p *PaymentInsert) Validate() error
type PaymentModel ¶
type PaymentModel struct {
// contains filtered or unexported fields
}
func (*PaymentModel) CancelPaymentsWithinPeriodDays ¶
func (p *PaymentModel) CancelPaymentsWithinPeriodDays(ctx context.Context, sqlExec db.SQLExecuter, periodInDays int64) error
CancelPaymentsWithinPeriodDays cancels automatically payments that are in "READY" status after a certain time period in days.
func (*PaymentModel) Count ¶
func (p *PaymentModel) Count(ctx context.Context, queryParams *QueryParams, sqlExec db.SQLExecuter) (int, error)
Count returns the number of payments matching the given query parameters.
func (*PaymentModel) DeleteAllForDisbursement ¶
func (p *PaymentModel) DeleteAllForDisbursement(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string) error
DeleteAllForDisbursement deletes all payments for a given disbursement.
func (*PaymentModel) Get ¶
func (p *PaymentModel) Get(ctx context.Context, id string, sqlExec db.SQLExecuter) (*Payment, error)
func (*PaymentModel) GetAll ¶
func (p *PaymentModel) GetAll(ctx context.Context, queryParams *QueryParams, sqlExec db.SQLExecuter) ([]Payment, error)
GetAll returns all PAYMENTS matching the given query parameters.
func (*PaymentModel) GetAllReadyToPatchCompletionAnchorTransactions ¶
func (p *PaymentModel) GetAllReadyToPatchCompletionAnchorTransactions(ctx context.Context, sqlExec db.SQLExecuter) ([]Payment, error)
func (*PaymentModel) GetBatchForUpdate ¶
func (p *PaymentModel) GetBatchForUpdate(ctx context.Context, sqlExec db.SQLExecuter, batchSize int) ([]*Payment, error)
func (*PaymentModel) GetByIDs ¶
func (p *PaymentModel) GetByIDs(ctx context.Context, sqlExec db.SQLExecuter, paymentIDs []string) ([]*Payment, error)
GetByIDs returns a list of payments for the given IDs.
func (*PaymentModel) GetReadyByDisbursementID ¶
func (p *PaymentModel) GetReadyByDisbursementID(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string) ([]*Payment, error)
func (*PaymentModel) GetReadyByID ¶
func (p *PaymentModel) GetReadyByID(ctx context.Context, sqlExec db.SQLExecuter, paymentIDs ...string) ([]*Payment, error)
func (*PaymentModel) GetReadyByReceiverWalletID ¶
func (p *PaymentModel) GetReadyByReceiverWalletID(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletID string) ([]*Payment, error)
func (*PaymentModel) InsertAll ¶
func (p *PaymentModel) InsertAll(ctx context.Context, sqlExec db.SQLExecuter, inserts []PaymentInsert) error
InsertAll inserts a batch of payments into the database.
func (*PaymentModel) RetryFailedPayments ¶
func (p *PaymentModel) RetryFailedPayments(ctx context.Context, sqlExec db.SQLExecuter, email string, paymentIDs ...string) error
func (*PaymentModel) Update ¶
func (p *PaymentModel) Update(ctx context.Context, sqlExec db.SQLExecuter, payment *Payment, update *PaymentUpdate) error
Update updates a payment's fields with the given update.
func (*PaymentModel) UpdateStatus ¶
func (p *PaymentModel) UpdateStatus( ctx context.Context, sqlExec db.SQLExecuter, paymentID string, status PaymentStatus, statusMsg *string, stellarTransactionHash string, ) error
UpdateStatus updates the status of a payment.
func (*PaymentModel) UpdateStatusByDisbursementID ¶
func (p *PaymentModel) UpdateStatusByDisbursementID(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string, targetStatus PaymentStatus) error
UpdateStatusByDisbursementID updates the status of all payments with a given status for a given disbursement.
func (*PaymentModel) UpdateStatuses ¶
func (p *PaymentModel) UpdateStatuses(ctx context.Context, sqlExec db.SQLExecuter, payments []*Payment, toStatus PaymentStatus) (int64, error)
type PaymentStatus ¶
type PaymentStatus string
const ( // DraftPaymentStatus is a non-terminal state for payments that were registered in the database but their disbursement has not started yet. Payments in this state can be deleted or transitioned to READY. DraftPaymentStatus PaymentStatus = "DRAFT" // ReadyPaymentStatus is a non-terminal state for payments that are waiting for the receiver to register. As soon as the receiver registers, the state is transitioned to PENDING. ReadyPaymentStatus PaymentStatus = "READY" // PendingPaymentStatus is a non-terminal state for payments that were marked for submission to the Stellar network. They can or can not have been submitted yet. PendingPaymentStatus PaymentStatus = "PENDING" // PausedPaymentStatus is a non-terminal state for payments that were manually paused. Payments in this state can be resumed. PausedPaymentStatus PaymentStatus = "PAUSED" // SuccessPaymentStatus is a terminal state for payments that were successfully submitted to the Stellar network. SuccessPaymentStatus PaymentStatus = "SUCCESS" // FailedPaymentStatus is a terminal state for payments that failed when submitted to the Stellar network. Payments in this state can be retried. FailedPaymentStatus PaymentStatus = "FAILED" // CanceledPaymentStatus is a terminal state for payments that were either manually or automatically canceled. CanceledPaymentStatus PaymentStatus = "CANCELED" )
func PaymentActiveStatuses ¶
func PaymentActiveStatuses() []PaymentStatus
func PaymentInProgressStatuses ¶
func PaymentInProgressStatuses() []PaymentStatus
PaymentInProgressStatuses returns a list of payment statuses that are in progress and could block potential new payments from being initiated if the distribution balance is low.
func PaymentStatuses ¶
func PaymentStatuses() []PaymentStatus
PaymentStatuses returns a list of all possible payment statuses
func ToPaymentStatus ¶
func ToPaymentStatus(s string) (PaymentStatus, error)
ToPaymentStatus converts a string to a PaymentStatus
func (PaymentStatus) SourceStatuses ¶
func (status PaymentStatus) SourceStatuses() []PaymentStatus
SourceStatuses returns a list of states that the payment status can transition from given the target state
func (PaymentStatus) State ¶
func (status PaymentStatus) State() State
func (PaymentStatus) TransitionTo ¶
func (status PaymentStatus) TransitionTo(targetState PaymentStatus) error
TransitionTo transitions the payment status to the target state
func (PaymentStatus) Validate ¶
func (status PaymentStatus) Validate() error
Validate validates the payment status
type PaymentStatusHistory ¶
type PaymentStatusHistory []PaymentStatusHistoryEntry
func (*PaymentStatusHistory) Scan ¶
func (psh *PaymentStatusHistory) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type PaymentStatusHistoryEntry ¶
type PaymentStatusHistoryEntry struct { Status PaymentStatus `json:"status"` StatusMessage string `json:"status_message"` Timestamp time.Time `json:"timestamp"` }
type PaymentUpdate ¶
type PaymentUpdate struct { Status PaymentStatus `db:"status"` StatusMessage string StellarTransactionID string `db:"stellar_transaction_id"` }
func (*PaymentUpdate) Validate ¶
func (p *PaymentUpdate) Validate() error
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder is a helper struct for building SQL queries
func NewQueryBuilder ¶
func NewQueryBuilder(query string) *QueryBuilder
NewQueryBuilder creates a new QueryBuilder
func (*QueryBuilder) AddCondition ¶
func (qb *QueryBuilder) AddCondition(condition string, value ...interface{}) *QueryBuilder
AddCondition adds a AND condition to the query The condition should be a string with a placeholder for the value e.g. "name = ?", "id > ?"
func (*QueryBuilder) AddGroupBy ¶
func (qb *QueryBuilder) AddGroupBy(fields string) *QueryBuilder
func (*QueryBuilder) AddOrCondition ¶
func (qb *QueryBuilder) AddOrCondition(condition string, value ...interface{}) *QueryBuilder
TODO [SDP-1190]: combine AddCondition and AddOrCondition into one function with a parameter for the condition type AddOrCondition adds an OR condition to the query
func (*QueryBuilder) AddPagination ¶
func (qb *QueryBuilder) AddPagination(page int, pageLimit int) *QueryBuilder
AddPagination adds a pagination clause to the query
func (*QueryBuilder) AddSorting ¶
func (qb *QueryBuilder) AddSorting(sortField SortField, sortOrder SortOrder, prefix string) *QueryBuilder
AddSorting adds a sorting clause to the query prefix is the prefix to use for the sort field e.g. "d" for "d.created_at"
func (*QueryBuilder) Build ¶
func (qb *QueryBuilder) Build() (string, []interface{})
Build assembles all statements in the correct order and returns the query and the parameters
func (*QueryBuilder) BuildAndRebind ¶
func (qb *QueryBuilder) BuildAndRebind(sqlExec db.SQLExecuter) (string, []interface{})
type QueryParams ¶
type ReceivedAmounts ¶
type ReceivedAmounts []Amount
func (*ReceivedAmounts) Scan ¶
func (ra *ReceivedAmounts) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type Receiver ¶
type Receiver struct { ID string `json:"id" db:"id"` ExternalID string `json:"external_id,omitempty" db:"external_id"` CreatedAt *time.Time `json:"created_at,omitempty" db:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` Email string `json:"email,omitempty" db:"email"` PhoneNumber string `json:"phone_number,omitempty" db:"phone_number"` ReceiverStats }
func CreateReceiverFixture ¶
func InsertReceiverFixture ¶
func InsertReceiverFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, r *ReceiverInsert) *Receiver
func (Receiver) ContactByType ¶
func (r Receiver) ContactByType(contactType ReceiverContactType) string
type ReceiverContactType ¶
type ReceiverContactType string
const ( ReceiverContactTypeEmail ReceiverContactType = "EMAIL" ReceiverContactTypeSMS ReceiverContactType = "PHONE_NUMBER" )
func GetAllReceiverContactTypes ¶
func GetAllReceiverContactTypes() []ReceiverContactType
type ReceiverIDs ¶
type ReceiverIDs []string
type ReceiverInsert ¶
type ReceiverModel ¶
type ReceiverModel struct{}
func (*ReceiverModel) Count ¶
func (r *ReceiverModel) Count(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams) (int, error)
Count returns the number of receivers matching the given query parameters.
func (*ReceiverModel) DeleteByContactInfo ¶
func (r *ReceiverModel) DeleteByContactInfo(ctx context.Context, dbConnectionPool db.DBConnectionPool, contactInfo string) error
DeleteByContactInfo deletes a receiver by phone number or email. It also deletes the associated entries in other tables: messages, payments, receiver_verifications, receiver_wallets, receivers, disbursements, submitter_transactions.
func (*ReceiverModel) Get ¶
func (r *ReceiverModel) Get(ctx context.Context, sqlExec db.SQLExecuter, id string) (*Receiver, error)
Get returns a RECEIVER matching the given ID.
func (*ReceiverModel) GetAll ¶
func (r *ReceiverModel) GetAll(ctx context.Context, sqlExec db.SQLExecuter, queryParams *QueryParams) ([]Receiver, error)
GetAll returns all RECEIVERS matching the given query parameters.
func (*ReceiverModel) GetByContacts ¶
func (r *ReceiverModel) GetByContacts(ctx context.Context, sqlExec db.SQLExecuter, contacts ...string) ([]*Receiver, error)
GetByContacts search for receivers by phone numbers and email.
func (*ReceiverModel) Insert ¶
func (r *ReceiverModel) Insert(ctx context.Context, sqlExec db.SQLExecuter, insert ReceiverInsert) (*Receiver, error)
Insert inserts a new receiver into the database.
func (*ReceiverModel) ParseReceiverIDs ¶
func (r *ReceiverModel) ParseReceiverIDs(receivers []Receiver) ReceiverIDs
ParseReceiverIDs return the array of receivers IDs.
func (*ReceiverModel) Update ¶
func (r *ReceiverModel) Update(ctx context.Context, sqlExec db.SQLExecuter, ID string, receiverUpdate ReceiverUpdate) error
Update updates the receiver Email and/or External ID.
type ReceiverStats ¶
type ReceiverStats struct { TotalPayments string `json:"total_payments,omitempty" db:"total_payments"` SuccessfulPayments string `json:"successful_payments,omitempty" db:"successful_payments"` FailedPayments string `json:"failed_payments,omitempty" db:"failed_payments"` CanceledPayments string `json:"canceled_payments,omitempty" db:"canceled_payments"` RemainingPayments string `json:"remaining_payments,omitempty" db:"remaining_payments"` RegisteredWallets string `json:"registered_wallets,omitempty" db:"registered_wallets"` ReceivedAmounts ReceivedAmounts `json:"received_amounts,omitempty" db:"received_amounts"` }
type ReceiverUpdate ¶
type ReceiverUpdate ReceiverInsert
func (ReceiverUpdate) IsEmpty ¶
func (ru ReceiverUpdate) IsEmpty() bool
func (ReceiverUpdate) Validate ¶
func (ru ReceiverUpdate) Validate() error
type ReceiverVerification ¶
type ReceiverVerification struct { ReceiverID string `json:"receiver_id" db:"receiver_id"` VerificationField VerificationType `json:"verification_field" db:"verification_field"` HashedValue string `json:"hashed_value" db:"hashed_value"` Attempts int `json:"attempts" db:"attempts"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` ConfirmedAt *time.Time `json:"confirmed_at" db:"confirmed_at"` FailedAt *time.Time `json:"failed_at" db:"failed_at"` VerificationChannel *message.MessageChannel `json:"verification_channel" db:"verification_channel"` }
func CreateReceiverVerificationFixture ¶
func CreateReceiverVerificationFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, insert ReceiverVerificationInsert) *ReceiverVerification
type ReceiverVerificationInsert ¶
type ReceiverVerificationInsert struct { ReceiverID string `db:"receiver_id"` VerificationField VerificationType `db:"verification_field"` VerificationValue string `db:"hashed_value"` }
func (*ReceiverVerificationInsert) Validate ¶
func (rvi *ReceiverVerificationInsert) Validate() error
type ReceiverVerificationModel ¶
type ReceiverVerificationModel struct {
// contains filtered or unexported fields
}
func (*ReceiverVerificationModel) ExceededAttempts ¶
func (*ReceiverVerificationModel) ExceededAttempts(attempts int) bool
ExceededAttempts check if the number of attempts exceeded the max value.
func (*ReceiverVerificationModel) GetAllByReceiverId ¶
func (m *ReceiverVerificationModel) GetAllByReceiverId(ctx context.Context, sqlExec db.SQLExecuter, receiverId string) ([]ReceiverVerification, error)
GetAllByReceiverId returns all receiver verifications by receiver id.
func (*ReceiverVerificationModel) GetByReceiverIDsAndVerificationField ¶
func (m *ReceiverVerificationModel) GetByReceiverIDsAndVerificationField(ctx context.Context, sqlExec db.SQLExecuter, receiverIds []string, verificationField VerificationType) ([]*ReceiverVerification, error)
GetByReceiverIDsAndVerificationField returns receiver verifications by receiver IDs and verification type.
func (*ReceiverVerificationModel) GetLatestByContactInfo ¶
func (m *ReceiverVerificationModel) GetLatestByContactInfo(ctx context.Context, contactInfo string) (*ReceiverVerification, error)
GetLatestByContactInfo returns the latest updated receiver verification for a receiver associated with a phone number or email.
func (*ReceiverVerificationModel) Insert ¶
func (m *ReceiverVerificationModel) Insert(ctx context.Context, sqlExec db.SQLExecuter, verificationInsert ReceiverVerificationInsert) (string, error)
Insert inserts a new receiver verification
func (*ReceiverVerificationModel) UpdateReceiverVerification ¶
func (m *ReceiverVerificationModel) UpdateReceiverVerification(ctx context.Context, update ReceiverVerificationUpdate, sqlExec db.SQLExecuter) error
UpdateReceiverVerification updates the attempts, confirmed_at, and failed_at values of a receiver verification.
func (*ReceiverVerificationModel) UpdateVerificationValue ¶
func (m *ReceiverVerificationModel) UpdateVerificationValue(ctx context.Context, sqlExec db.SQLExecuter, receiverID string, verificationField VerificationType, verificationValue string, ) error
UpdateVerificationValue updates the hashed value of a receiver verification.
func (*ReceiverVerificationModel) UpsertVerificationValue ¶
func (m *ReceiverVerificationModel) UpsertVerificationValue(ctx context.Context, sqlExec db.SQLExecuter, receiverID string, verificationField VerificationType, verificationValue string) error
UpsertVerificationValue creates or updates the receiver's verification. In case the verification exists and it's already confirmed by the receiver it's not updated.
type ReceiverVerificationUpdate ¶
type ReceiverVerificationUpdate struct { ReceiverID string `db:"receiver_id"` VerificationField VerificationType `db:"verification_field"` VerificationChannel message.MessageChannel `db:"verification_channel"` Attempts *int `db:"attempts"` ConfirmedAt *time.Time `db:"confirmed_at"` FailedAt *time.Time `db:"failed_at"` }
func (ReceiverVerificationUpdate) Validate ¶
func (rvu ReceiverVerificationUpdate) Validate() error
type ReceiverWallet ¶
type ReceiverWallet struct { ID string `json:"id" db:"id"` Receiver Receiver `json:"receiver" db:"receiver"` Wallet Wallet `json:"wallet" db:"wallet"` StellarAddress string `json:"stellar_address,omitempty" db:"stellar_address"` StellarMemo string `json:"stellar_memo,omitempty" db:"stellar_memo"` StellarMemoType string `json:"stellar_memo_type,omitempty" db:"stellar_memo_type"` Status ReceiversWalletStatus `json:"status" db:"status"` StatusHistory ReceiversWalletStatusHistory `json:"status_history,omitempty" db:"status_history"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` OTP string `json:"-" db:"otp"` OTPCreatedAt *time.Time `json:"-" db:"otp_created_at"` OTPConfirmedAt *time.Time `json:"otp_confirmed_at,omitempty" db:"otp_confirmed_at"` OTPConfirmedWith string `json:"otp_confirmed_with,omitempty" db:"otp_confirmed_with"` // AnchorPlatformAccountID is the ID of the SEP24 transaction initiated by the Anchor Platform where the receiver wallet was registered. AnchorPlatformTransactionID string `json:"anchor_platform_transaction_id,omitempty" db:"anchor_platform_transaction_id"` AnchorPlatformTransactionSyncedAt *time.Time `json:"anchor_platform_transaction_synced_at,omitempty" db:"anchor_platform_transaction_synced_at"` InvitedAt *time.Time `json:"invited_at,omitempty" db:"invited_at"` LastMessageSentAt *time.Time `json:"last_message_sent_at,omitempty" db:"last_message_sent_at"` InvitationSentAt *time.Time `json:"invitation_sent_at" db:"invitation_sent_at"` ReceiverWalletStats }
func CreateReceiverWalletFixture ¶
func CreateReceiverWalletFixture(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter, receiverID, walletID string, status ReceiversWalletStatus) *ReceiverWallet
type ReceiverWalletAsset ¶
type ReceiverWalletAsset struct { WalletID string `db:"wallet_id"` ReceiverWallet ReceiverWallet `db:"receiver_wallet"` Asset Asset `db:"asset"` DisbursementReceiverRegistrationMsgTemplate *string `json:"-" db:"receiver_registration_message_template"` }
type ReceiverWalletInsert ¶
type ReceiverWalletModel ¶
type ReceiverWalletModel struct {
// contains filtered or unexported fields
}
func (*ReceiverWalletModel) GetAllPendingRegistrationByDisbursementID ¶
func (rw *ReceiverWalletModel) GetAllPendingRegistrationByDisbursementID(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string) ([]*ReceiverWallet, error)
func (*ReceiverWalletModel) GetAllPendingRegistrationByReceiverWalletIDs ¶
func (rw *ReceiverWalletModel) GetAllPendingRegistrationByReceiverWalletIDs(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletIDs []string) ([]*ReceiverWallet, error)
func (*ReceiverWalletModel) GetAllPendingRegistrations ¶
func (rw *ReceiverWalletModel) GetAllPendingRegistrations(ctx context.Context, sqlExec db.SQLExecuter) ([]*ReceiverWallet, error)
func (*ReceiverWalletModel) GetByIDs ¶
func (rw *ReceiverWalletModel) GetByIDs(ctx context.Context, sqlExec db.SQLExecuter, ids ...string) ([]ReceiverWallet, error)
GetByIDs returns a receiver wallet by IDs
func (*ReceiverWalletModel) GetByReceiverIDAndWalletDomain ¶
func (rw *ReceiverWalletModel) GetByReceiverIDAndWalletDomain(ctx context.Context, receiverId string, walletDomain string, sqlExec db.SQLExecuter) (*ReceiverWallet, error)
GetByReceiverIDAndWalletDomain returns a receiver wallet that match the receiver ID and wallet domain.
func (*ReceiverWalletModel) GetByReceiverIDsAndWalletID ¶
func (rw *ReceiverWalletModel) GetByReceiverIDsAndWalletID(ctx context.Context, sqlExec db.SQLExecuter, receiverIds []string, walletId string) ([]*ReceiverWallet, error)
GetByReceiverIDsAndWalletID returns a list of receiver wallets by receiver IDs and wallet ID.
func (*ReceiverWalletModel) GetByStellarAccountAndMemo ¶
func (rw *ReceiverWalletModel) GetByStellarAccountAndMemo(ctx context.Context, stellarAccount, stellarMemo, clientDomain string) (*ReceiverWallet, error)
GetByStellarAccountAndMemo returns a receiver wallets that match the Stellar Account, memo and client domain.
func (*ReceiverWalletModel) GetWithReceiverIds ¶
func (rw *ReceiverWalletModel) GetWithReceiverIds(ctx context.Context, sqlExec db.SQLExecuter, receiverIds ReceiverIDs) ([]ReceiverWallet, error)
func (*ReceiverWalletModel) Insert ¶
func (rw *ReceiverWalletModel) Insert(ctx context.Context, sqlExec db.SQLExecuter, insert ReceiverWalletInsert) (string, error)
Insert inserts a new receiver wallet into the database.
func (*ReceiverWalletModel) RetryInvitationMessage ¶
func (rw *ReceiverWalletModel) RetryInvitationMessage(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletId string) (*ReceiverWallet, error)
RetryInvitationMessage sets null the invitation_sent_at of a receiver wallet.
func (*ReceiverWalletModel) Update ¶
func (rw *ReceiverWalletModel) Update(ctx context.Context, id string, update ReceiverWalletUpdate, sqlExec db.SQLExecuter) error
func (*ReceiverWalletModel) UpdateAnchorPlatformTransactionSyncedAt ¶
func (rw *ReceiverWalletModel) UpdateAnchorPlatformTransactionSyncedAt(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletID ...string) ([]ReceiverWallet, error)
func (*ReceiverWalletModel) UpdateInvitationSentAt ¶
func (rw *ReceiverWalletModel) UpdateInvitationSentAt(ctx context.Context, sqlExec db.SQLExecuter, receiverWalletID ...string) ([]ReceiverWallet, error)
func (*ReceiverWalletModel) UpdateOTPByReceiverContactInfoAndWalletDomain ¶
func (rw *ReceiverWalletModel) UpdateOTPByReceiverContactInfoAndWalletDomain(ctx context.Context, receiverContactInfo, sep10ClientDomain, otp string) (numberOfUpdatedRows int, err error)
UpdateOTPByReceiverContactInfoAndWalletDomain updates receiver wallet OTP if its not verified yet, and returns the number of updated rows.
func (*ReceiverWalletModel) UpdateStatusByDisbursementID ¶
func (rw *ReceiverWalletModel) UpdateStatusByDisbursementID(ctx context.Context, sqlExec db.SQLExecuter, disbursementID string, from, to ReceiversWalletStatus) error
UpdateStatusByDisbursementID updates the status of the receiver wallets associated with a disbursement.
func (*ReceiverWalletModel) VerifyReceiverWalletOTP ¶
func (rw *ReceiverWalletModel) VerifyReceiverWalletOTP(ctx context.Context, networkPassphrase string, receiverWallet ReceiverWallet, otp string) error
VerifyReceiverWalletOTP validates the receiver wallet OTP.
type ReceiverWalletStats ¶
type ReceiverWalletStats struct { TotalPayments string `json:"total_payments,omitempty" db:"total_payments"` PaymentsReceived string `json:"payments_received,omitempty" db:"payments_received"` FailedPayments string `json:"failed_payments,omitempty" db:"failed_payments"` CanceledPayments string `json:"canceled_payments,omitempty" db:"canceled_payments"` RemainingPayments string `json:"remaining_payments,omitempty" db:"remaining_payments"` ReceivedAmounts ReceivedAmounts `json:"received_amounts,omitempty" db:"received_amounts"` // TotalInvitationResentAttempts holds how many times were resent the Invitation SMS to the receiver // since the last invitation has been sent. TotalInvitationResentAttempts int64 `json:"-" db:"total_invitation_sms_resent_attempts"` }
type ReceiverWalletUpdate ¶
type ReceiverWalletUpdate struct { Status ReceiversWalletStatus `db:"status"` AnchorPlatformTransactionID string `db:"anchor_platform_transaction_id"` StellarAddress string `db:"stellar_address"` StellarMemo string `db:"stellar_memo"` StellarMemoType string `db:"stellar_memo_type"` OTPConfirmedAt time.Time `db:"otp_confirmed_at"` OTPConfirmedWith string `db:"otp_confirmed_with"` }
func (ReceiverWalletUpdate) Validate ¶
func (rwu ReceiverWalletUpdate) Validate() error
type ReceiversWalletStatus ¶
type ReceiversWalletStatus string
const ( DraftReceiversWalletStatus ReceiversWalletStatus = "DRAFT" ReadyReceiversWalletStatus ReceiversWalletStatus = "READY" RegisteredReceiversWalletStatus ReceiversWalletStatus = "REGISTERED" FlaggedReceiversWalletStatus ReceiversWalletStatus = "FLAGGED" )
func (ReceiversWalletStatus) State ¶
func (status ReceiversWalletStatus) State() State
func (ReceiversWalletStatus) TransitionTo ¶
func (status ReceiversWalletStatus) TransitionTo(targetState ReceiversWalletStatus) error
TransitionTo transitions the receiver wallet status to the target state
func (ReceiversWalletStatus) Validate ¶
func (status ReceiversWalletStatus) Validate() error
Validate validates the receiver wallet status
type ReceiversWalletStatusHistory ¶
type ReceiversWalletStatusHistory []ReceiversWalletStatusHistoryEntry
func (*ReceiversWalletStatusHistory) Scan ¶
func (rwsh *ReceiversWalletStatusHistory) Scan(src interface{}) error
Scan implements the sql.Scanner interface.
type ReceiversWalletStatusHistoryEntry ¶
type ReceiversWalletStatusHistoryEntry struct { Status ReceiversWalletStatus `json:"status"` Timestamp time.Time `json:"timestamp"` }
type RegistrationContactType ¶
type RegistrationContactType struct { ReceiverContactType ReceiverContactType `json:"registration_contact_type"` IncludesWalletAddress bool `json:"includes_wallet_address"` }
RegistrationContactType represents the type of contact information to be used when creating and validating a disbursement.
func AllRegistrationContactTypes ¶
func AllRegistrationContactTypes() []RegistrationContactType
func (RegistrationContactType) MarshalJSON ¶
func (rct RegistrationContactType) MarshalJSON() ([]byte, error)
func (*RegistrationContactType) ParseFromString ¶
func (rct *RegistrationContactType) ParseFromString(input string) error
ParseFromString parses the string, setting ReceiverContactType and IncludesWalletAddress based on suffix.
func (*RegistrationContactType) Scan ¶
func (rct *RegistrationContactType) Scan(value interface{}) error
func (RegistrationContactType) String ¶
func (rct RegistrationContactType) String() string
func (*RegistrationContactType) UnmarshalJSON ¶
func (rct *RegistrationContactType) UnmarshalJSON(data []byte) error
type StateMachine ¶
func DisbursementStateMachineWithInitialState ¶
func DisbursementStateMachineWithInitialState(initialState DisbursementStatus) *StateMachine
DisbursementStateMachineWithInitialState returns a state machine for disbursements initialized with the given state
func NewStateMachine ¶
func NewStateMachine(initialState State, transitions []StateTransition) *StateMachine
func PaymentStateMachineWithInitialState ¶
func PaymentStateMachineWithInitialState(initialState PaymentStatus) *StateMachine
PaymentStateMachineWithInitialState returns a state machine for Payments initialized with the given state
func ReceiversWalletStateMachineWithInitialState ¶
func ReceiversWalletStateMachineWithInitialState(initialState ReceiversWalletStatus) *StateMachine
ReceiversWalletStateMachineWithInitialState returns a state machine for ReceiversWallets initialized with the given state
func (*StateMachine) CanTransitionTo ¶
func (sm *StateMachine) CanTransitionTo(targetState State) bool
func (*StateMachine) TransitionTo ¶
func (sm *StateMachine) TransitionTo(targetState State) error
type StateTransition ¶
type UserRole ¶
type UserRole string
const ( // OwnerUserRole has permission to do everything. Also, it's in charge of creating new users and managing Org account. OwnerUserRole UserRole = "owner" // FinancialControllerUserRole has the same permissions as the OwnerUserRole except for user management. FinancialControllerUserRole UserRole = "financial_controller" // DeveloperUserRole has only configuration permissions. (wallets, assets management. Also, statistics access permission) DeveloperUserRole UserRole = "developer" // BusinessUserRole has read-only permissions - except for user management that they can't read any data. BusinessUserRole UserRole = "business" )
Roles description reference: https://stellarfoundation.slack.com/archives/C04C9MLM9UZ/p1681238994830149
type VerificationType ¶
type VerificationType string
const ( VerificationTypeDateOfBirth VerificationType = "DATE_OF_BIRTH" VerificationTypeYearMonth VerificationType = "YEAR_MONTH" VerificationTypePin VerificationType = "PIN" VerificationTypeNationalID VerificationType = "NATIONAL_ID_NUMBER" )
func GetAllVerificationTypes ¶
func GetAllVerificationTypes() []VerificationType
GetAllVerificationTypes returns all the available verification types.
type Wallet ¶
type Wallet struct { ID string `json:"id" db:"id"` Name string `json:"name" db:"name"` Homepage string `json:"homepage,omitempty" db:"homepage"` SEP10ClientDomain string `json:"sep_10_client_domain,omitempty" db:"sep_10_client_domain"` DeepLinkSchema string `json:"deep_link_schema,omitempty" db:"deep_link_schema"` Enabled bool `json:"enabled" db:"enabled"` UserManaged bool `json:"user_managed,omitempty" db:"user_managed"` Assets WalletAssets `json:"assets,omitempty" db:"assets"` CreatedAt *time.Time `json:"created_at,omitempty" db:"created_at"` UpdatedAt *time.Time `json:"updated_at,omitempty" db:"updated_at"` DeletedAt *time.Time `json:"-" db:"deleted_at"` }
func ClearAndCreateWalletFixtures ¶
func ClearAndCreateWalletFixtures(t *testing.T, ctx context.Context, sqlExec db.SQLExecuter) []Wallet
ClearAndCreateWalletFixtures deletes all wallets in the database then creates new wallets for testing
func CreateWalletFixture ¶
func GetWalletFixture ¶
type WalletAssets ¶
type WalletAssets []Asset
func (*WalletAssets) Scan ¶
func (wa *WalletAssets) Scan(src interface{}) error
type WalletInsert ¶
type WalletModel ¶
type WalletModel struct {
// contains filtered or unexported fields
}
func (*WalletModel) FindWallets ¶
FindWallets returns wallets filtering by enabled status.
func (*WalletModel) GetAll ¶
func (wm *WalletModel) GetAll(ctx context.Context) ([]Wallet, error)
GetAll returns all wallets in the database
func (*WalletModel) GetByWalletName ¶
GetByWalletName returns wallet filtering by wallet name.
func (*WalletModel) GetOrCreate ¶
func (*WalletModel) Insert ¶
func (wm *WalletModel) Insert(ctx context.Context, newWallet WalletInsert) (*Wallet, error)
func (*WalletModel) SoftDelete ¶
Source Files ¶
- assets.go
- circle_transfer_requests.go
- dibursements_state_machine.go
- disbursement_instructions.go
- disbursement_receivers.go
- disbursements.go
- fixtures.go
- messages.go
- models.go
- organizations.go
- otp.go
- payments.go
- payments_state_machine.go
- query_builder.go
- query_params.go
- receiver_verification.go
- receiver_wallets_state_machine.go
- receivers.go
- receivers_wallet.go
- registration_contact_type.go
- roles.go
- statemachine.go
- verification_type.go
- wallets.go