withdraw

package
v0.0.0-...-069e140 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrStrAmountMustBeGreaterThanZero message to return when requested amount is less than 0
	ErrStrAmountMustBeGreaterThanZero = "amount must be greater than 0"
	// ErrStrAddressisInvalid message to return when address is invalid for crypto request
	ErrStrAddressisInvalid = "address is not valid"
	// ErrStrAddressNotSet message to return when address is empty
	ErrStrAddressNotSet = "address cannot be empty"
	// ErrStrNoCurrencySet message to return when no currency is set
	ErrStrNoCurrencySet = "currency not set"
	// ErrStrCurrencyNotCrypto message to return when requested currency is not crypto
	ErrStrCurrencyNotCrypto = "requested currency is not a cryptocurrency"
	// ErrStrCurrencyNotFiat message to return when requested currency is not fiat
	ErrStrCurrencyNotFiat = "requested currency is not fiat"
	// ErrStrFeeCannotBeNegative message to return when fee amount is negative
	ErrStrFeeCannotBeNegative = "fee amount cannot be negative"
	// ErrStrAddressNotWhiteListed message to return when attempting to withdraw to non-whitelisted address
	ErrStrAddressNotWhiteListed = "address is not whitelisted for withdrawals"
	// ErrStrExchangeNotSupportedByAddress message to return when attemptign to withdraw to an unsupported exchange
	ErrStrExchangeNotSupportedByAddress = "address is not supported by exchange"
)

Variables

View Source
var (
	// ErrRequestCannotBeNil message to return when a request is nil
	ErrRequestCannotBeNil = errors.New("request cannot be nil")
	// ErrInvalidRequest message to return when a request type is invalid
	ErrInvalidRequest = errors.New("invalid request type")
	// CacheSize cache size to use for withdrawal request history
	CacheSize uint64 = 25
	// Cache LRU cache for recent requests
	Cache = cache.New(CacheSize)
	// DryRunID uuid to use for dryruns
	DryRunID, _ = uuid.FromString("3e7e2c25-5a0b-429b-95a1-0960079dce56")
)

Functions

func Validate

func Validate(request *Request) (err error)

Validate takes interface and passes to asset type to check the request meets requirements to submit

Types

type CryptoRequest

type CryptoRequest struct {
	Address    string
	AddressTag string
	FeeAmount  float64
}

CryptoRequest stores the info required for a crypto withdrawal request

type ExchangeResponse

type ExchangeResponse struct {
	Name   string `json:"name"`
	ID     string `json:"id"`
	Status string `json:"status"`
}

ExchangeResponse holds information returned from an exchange

type FiatRequest

type FiatRequest struct {
	Bank *banking.Account

	IsExpressWire bool
	// Intermediary bank information
	RequiresIntermediaryBank      bool
	IntermediaryBankAccountNumber float64
	IntermediaryBankName          string
	IntermediaryBankAddress       string
	IntermediaryBankCity          string
	IntermediaryBankCountry       string
	IntermediaryBankPostalCode    string
	IntermediarySwiftCode         string
	IntermediaryBankCode          float64
	IntermediaryIBAN              string
	WireCurrency                  string
}

FiatRequest used for fiat withdrawal requests

type Request

type Request struct {
	Exchange    string        `json:"exchange"`
	Currency    currency.Code `json:"currency"`
	Description string        `json:"description"`
	Amount      float64       `json:"amount"`
	Type        RequestType   `json:"type"`

	TradePassword   string
	OneTimePassword int64
	PIN             int64

	Crypto *CryptoRequest `json:",omitempty"`
	Fiat   *FiatRequest   `json:",omitempty"`
}

Request holds complete details for request

type RequestType

type RequestType uint8

RequestType used for easy matching of int type to Word

const (
	// Crypto request type
	Crypto RequestType = iota
	// Fiat request type
	Fiat
	// Unknown request type
	Unknown
)

type Response

type Response struct {
	ID uuid.UUID `json:"id"`

	Exchange       *ExchangeResponse `json:"exchange"`
	RequestDetails *Request          `json:"request_details"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Response holds complete details for Response

Jump to

Keyboard shortcuts

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