Documentation ¶
Index ¶
- Constants
- type Account
- type AddAddressToProfileRequest
- type Auth
- type AuthConfig
- type AuthContext
- type AuthProfile
- type Balance
- type Chain
- type Client
- func (c *Client) AddAddressToProfile(ctx context.Context, req *AddAddressToProfileRequest) (*Profile, error)
- func (c *Client) GetAuthContext(ctx context.Context) (*AuthContext, error)
- func (c *Client) GetBalances(ctx context.Context) ([]*ProfileBalance, error)
- func (c *Client) GetBalancesForProfile(ctx context.Context, req *GetBalancesForProfileRequest) ([]*ProfileBalance, error)
- func (c *Client) GetOrder(ctx context.Context, req *GetOrderRequest) (*Order, error)
- func (c *Client) GetOrders(ctx context.Context, req *GetOrdersRequest) ([]*Order, error)
- func (c *Client) GetProfile(ctx context.Context, req *GetProfileRequest) (*Profile, error)
- func (c *Client) GetProfiles(ctx context.Context) ([]*ProfileSummary, error)
- func (c *Client) GetTokens(ctx context.Context) ([]*Token, error)
- func (c *Client) OrdersNotifications(ctx context.Context, req *OrdersNotificationsRequest, os chan<- *OrderResult) error
- func (c *Client) PlaceOrder(ctx context.Context, req *PlaceOrderRequest) (*Order, error)
- func (c *Client) UploadFile(ctx context.Context, req *UploadFileRequest) (*File, error)
- type ClientOption
- type Counterpart
- type CounterpartDetails
- type Currency
- type File
- type FileMeta
- type GetBalancesForProfileRequest
- type GetOrderRequest
- type GetOrdersRequest
- type GetProfileRequest
- type Identifier
- type KYCDetails
- type KYCOutcome
- type KYCState
- type Network
- type Order
- type OrderKind
- type OrderMeta
- type OrderResult
- type OrderState
- type OrdersNotificationsRequest
- type PlaceOrderRequest
- type Profile
- type ProfileBalance
- type ProfileSummary
- type Symbol
- type Ticker
- type Token
- type UploadFileRequest
Constants ¶
const ( SandboxBaseURL = "https://api.monerium.dev" SandboxWebsocketURL = "wss://api.monerium.dev" SandboxTokenURL = "https://api.monerium.dev/auth/token" ProductionBaseURL = "https://api.monerium.app" ProductionWebsocketURL = "wss://api.monerium.app" ProductionTokenURL = "https://api.monerium.app/auth/token" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Address string `json:"address,omitempty"` Chain Chain `json:"chain,omitempty"` Network Network `json:"network,omitempty"` Currency Currency `json:"currency,omitempty"` Standard string `json:"standard,omitempty"` IBAN string `json:"iban,omitempty"` State string `json:"state,omitempty"` SortCode string `json:"sortCode,omitempty"` AccountNumber string `json:"accountNumber,omitempty"` }
Account represents an account in Monerium system.
type AddAddressToProfileRequest ¶
type AddAddressToProfileRequest struct { ProfileID string `json:"-"` Address string `json:"address"` Message string `json:"message"` Signature string `json:"signature"` Accounts []Account `json:"accounts"` }
func (*AddAddressToProfileRequest) Validate ¶
func (r *AddAddressToProfileRequest) Validate() error
type AuthConfig ¶
type AuthConfig struct { // ClientID is the application's ID. ClientID string // ClientSecret is the application's secret. ClientSecret string // TokenURL is the resource server's token endpoint URL. TokenURL string }
AuthConfig is used for passing data related to OAuth2 Client Credentials flow.
type AuthContext ¶
type AuthContext struct { UserID string `json:"userId"` Email string `json:"email"` Name string `json:"name"` Roles []string `json:"roles"` Auth Auth `json:"auth"` DefaultProfileID string `json:"defaultProfile"` Profiles []AuthProfile `json:"profiles"` }
AuthContext represents the context of authenticated user.
type AuthProfile ¶
type Balance ¶
type Balance struct { Amount string `json:"amount,omitempty"` Currency string `json:"currency,omitempty"` }
Balance represents a balance - amount and currency.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a new Monerium API client.
func NewClient ¶
func NewClient(ctx context.Context, baseURL, wsURL string, auth *AuthConfig, opts ...ClientOption) *Client
NewClient initializes a new API client. baseURL and wsURL should point to corresponding urls for Sandbox or Production environments. AuthConfig is used for passing data related to OAuth2 ClientCredentials flow. Client behavior can be tweaked via ClientOption.
func (*Client) AddAddressToProfile ¶
func (c *Client) AddAddressToProfile(ctx context.Context, req *AddAddressToProfileRequest) (*Profile, error)
AddAddressToProfile links given blockchain address (wallet) and create an account for Monerium tokens.
func (*Client) GetAuthContext ¶
func (c *Client) GetAuthContext(ctx context.Context) (*AuthContext, error)
GetAuthContext retrieves context of authenticated user.
func (*Client) GetBalances ¶
func (c *Client) GetBalances(ctx context.Context) ([]*ProfileBalance, error)
GetBalances retrieves balance for every account of the default profile. Each account represent one token, on a chain and network.
func (*Client) GetBalancesForProfile ¶
func (c *Client) GetBalancesForProfile(ctx context.Context, req *GetBalancesForProfileRequest) ([]*ProfileBalance, error)
GetBalancesForProfile retrieves balance for every account of a profile. Each account represent one token, on a chain and network.
func (*Client) GetOrders ¶
GetOrders retrieves all orders accessible by the authenticated user. Query parameters passed in GetOrderRequest can be used to filter and sort the result. GetOrderRequest can be nil, in that case no filters are applied.
func (*Client) GetProfile ¶
GetProfile retrieves a single profile details.
func (*Client) GetProfiles ¶
func (c *Client) GetProfiles(ctx context.Context) ([]*ProfileSummary, error)
GetProfiles retrieves all profiles summaries. The summary contains information about the profile such as its kind and the permission the authenticated user has on the profiles.
func (*Client) GetTokens ¶
GetTokens retrieves information about the emoney tokens with tickers, symbols, decimals, token contract address and the network and chain information, we currently support Ethereum and Polygon.
func (*Client) OrdersNotifications ¶
func (c *Client) OrdersNotifications(ctx context.Context, req *OrdersNotificationsRequest, os chan<- *OrderResult) error
OrdersNotifications streams order updates over a channel.
The websocket will emit the same order object up to three times, once for the following state changes: 1. Placed - the initial state of placed order. 2. Pending - order is being processed. 3. Processed - money has been received for issue orders or tokens have been burnt for redeem orders.
Pending state is optional and Order might transform from placed straight to processed. OrderResult contains Order on sucessfull response or Error on failure.
func (*Client) PlaceOrder ¶
PlaceOrder initialize a payment to an external SEPA account (redeem order).
The payload includes the amount, currency and the beneficiary (counterpart). All SEPA payments must be authorized using a strong customer authentication. In short, users must provide two of three elements to authorize payments:
- Knowledge: something only the user knows, e.g. a password or a PIN code
- Possession: something only the user possesses, e.g. a mobile phone
- Inherence: something the user is, e.g. the use of a fingerprint or voice recognition.
The authorization is implemented by requiring a signature derived from a private key (possession) in addition to a password (knowledge). A message, the signature and the address associated with the private key used to sign must be added to the request payload.
func (*Client) UploadFile ¶
UploadFile accepts request with filename and content of the file to be uploaded via generic file upload endpoint. UploadFile can be used e.g. for uploading supporting documents for large redeem orders.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption represents an configurable option to Client.
func WithNotifyTick ¶
func WithNotifyTick(d time.Duration) ClientOption
WithNotifyTick sets tick duration for polling websocket connection.
type Counterpart ¶
type Counterpart struct { Identifier Identifier `json:"identifier,omitempty"` Details CounterpartDetails `json:"details,omitempty"` }
Counterpart represents the counterpart of an Order.
type CounterpartDetails ¶
type CounterpartDetails struct { Country string `json:"country,omitempty"` FirstName string `json:"firstName,omitempty"` LastName string `json:"lastName,omitempty"` }
CounterpartDetails represents the details of a Counterpart.
type File ¶
type File struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Size int `json:"size,omitempty"` Hash string `json:"hash,omitempty"` Meta *FileMeta `json:"meta,omitempty"` }
File represents a file that was successfully uploaded.
type FileMeta ¶
type FileMeta struct { UploadedBy string `json:"uploadedBy,omitempty"` CreatedAt time.Time `json:"createdAt,omitempty"` UpdatedAt time.Time `json:"updatedAt,omitempty"` }
FileMeta represents a metadata of a file that was successfully uploaded.
type GetBalancesForProfileRequest ¶
type GetBalancesForProfileRequest struct {
ProfileID string
}
GetBalancesForProfileRequest contains data needed for making the request.
func (*GetBalancesForProfileRequest) Validate ¶
func (r *GetBalancesForProfileRequest) Validate() error
Validate checks GetBalancesForProfileRequest.
type GetOrderRequest ¶
type GetOrderRequest struct {
OrderID string `url:"orderId"`
}
GetOrderRequest contains optional query parameters that can be used to filter results.
type GetOrdersRequest ¶
type GetOrdersRequest struct { Address string `url:"address"` TxHash string `url:"txHash"` Memo string `url:"memo"` State OrderState `url:"state"` AccountID string `url:"accountId"` ProfileID string `url:"profile"` }
GetOrdersRequest contains optional query parameters that can be used to filter results.
type GetProfileRequest ¶
type GetProfileRequest struct {
ProfileID string
}
func (*GetProfileRequest) Validate ¶
func (r *GetProfileRequest) Validate() error
type Identifier ¶
type Identifier struct { Standard string `json:"standard,omitempty"` IBAN string `json:"iban,omitempty"` }
Identifier represents the identifier of a Counterpart.
type KYCDetails ¶
type KYCDetails struct { State KYCState `json:"state,omitempty"` Outcome string `json:"outcome,omitempty"` }
KYCDetails represents KYC details of a profile.
type KYCOutcome ¶
type KYCOutcome string
KYCOutcome represents the verdict of the KYC from Monerium.
const ( // KYCOutcomeApproved means a valid customer. KYCOutcomeApproved KYCOutcome = "approved" // KYCOutcomeRejected mean that the applicant did not meet the KYC requirements. KYCOutcomeRejected KYCOutcome = "rejected" // KYCOutcomeUnknown the outcome has not been reached yet. KYCOutcomeUnknown = "unknown" )
type KYCState ¶
type KYCState string
KYCState represents the state of the customer onboarding.
const ( //KYCStateAbsent means there is no KYC version available. KYCStateAbsent KYCState = "absent" // KYCStateSubmitted means the user has submitted KYC data, but it has not been processed. KYCStateSubmitted KYCState = "submitted" // KYCStatePending means the admin has started processing the KYC application. KYCStatePending KYCState = "pending" // KYCStateConfirmed means an admin has decided on the outcome of a KYC application. KYCStateConfirmed KYCState = "confirmed" )
type Order ¶
type Order struct { ID string `json:"id,omitempty"` Profile string `json:"profile,omitempty"` AccountID string `json:"accountId,omitempty"` Address string `json:"address,omitempty"` Kind OrderKind `json:"kind,omitempty"` Amount string `json:"amount,omitempty"` Currency Currency `json:"currency,omitempty"` Counterpart Counterpart `json:"counterpart,omitempty"` Memo string `json:"memo,omitempty"` RejectedReason string `json:"rejectedReason,omitempty"` SupportingDocumentID string `json:"supportingDocumentId,omitempty"` Meta OrderMeta `json:"meta,omitempty"` }
Order represents a payment Order. If order is rejected, the reason is stored in RejectedReason.
type OrderKind ¶
type OrderKind string
OrderKind represents Order kind. Only redeem order can be placed via API. Issue orders are created via money transfer over SEPA to IBAN number provided by Monerium.
type OrderMeta ¶
type OrderMeta struct { ApprovedAt time.Time `json:"approvedAt,omitempty"` ProcessedAt time.Time `json:"processedAt,omitempty"` RejectedAt time.Time `json:"rejectedAt,omitempty"` State OrderState `json:"state,omitempty"` PlacedBy string `json:"placedBy,omitempty"` PlacedAt time.Time `json:"placedAt,omitempty"` ReceivedAmount string `json:"receivedAmount,omitempty"` SentAmount string `json:"sentAmount,omitempty"` }
OrderMeta represents the metadata of an Order.
type OrderResult ¶
OrderResult contains Order response on success or Error with failure reason.
type OrderState ¶
type OrderState string
OrderKind represents Order kind.
const ( OrderStatePlaced OrderState = "placed" OrderStatePending OrderState = "pending" OrderStateProcessed OrderState = "processed" OrderStateRejected OrderState = "rejected" )
type OrdersNotificationsRequest ¶
type OrdersNotificationsRequest struct {
ProfileID string
}
OrdersNotificationsRequest represents request data fro Order notifications.
type PlaceOrderRequest ¶
type PlaceOrderRequest struct { Address string `json:"address,omitempty"` Currency Currency `json:"currency,omitempty"` Chain Chain `json:"chain,omitempty"` AccountID string `json:"accountId,omitempty"` Kind OrderKind `json:"kind"` Amount string `json:"amount"` Signature string `json:"signature"` Message string `json:"message"` Counterpart *Counterpart `json:"counterpart"` Memo string `json:"memo,omitempty"` SupportingDocumentID string `json:"supportingDocumentId,omitempty"` }
PlaceOrderRequest contains parameters for placing an order. Order can be placed either with set of Address, Currency and Chain or AccountID. Memo is a reference of the SEPA transfer. SupportingDocumentID is a document to be attached for redeem order above certain limit. Memo and SupportingDocumentID are optional.
SupportingDocumentID is the ID of a uploaded file via UploadFile call.
func (*PlaceOrderRequest) Validate ¶
func (r *PlaceOrderRequest) Validate() error
Validate checks if PlaceOrderRequest is correct.
type Profile ¶
type Profile struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` KYC KYCDetails `json:"kyc,omitempty"` Accounts []Account `json:"accounts,omitempty"` }
Profile contains general information about the profile: KYC details and linked accounts.
type ProfileBalance ¶
type ProfileBalance struct { ProfileID string `json:"id,omitempty"` Address string `json:"address,omitempty"` Chain string `json:"chain,omitempty"` Network string `json:"network,omitempty"` Balances []*Balance `json:"balances,omitempty"` }
ProfileBalance represents balances of a profile identified by ProfileID.
type ProfileSummary ¶
type ProfileSummary struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` Type string `json:"type,omitempty"` Permissions []string `json:"perms,omitempty"` }
ProfileSummary contains auth related information about the profile: type and permissions.
type Token ¶
type Token struct { Currency Currency `json:"currency,omitempty"` Ticker Ticker `json:"ticker,omitempty"` Symbol Symbol `json:"symbol,omitempty"` Chain Chain `json:"chain,omitempty"` Network Network `json:"network,omitempty"` Address string `json:"address,omitempty"` Decimals uint `json:"decimals,omitempty"` }
Token represents an e-money token: its chain, network, address and so on.
type UploadFileRequest ¶
UploadFileRequest contains filename and content of the file to be uploaded.