Entidades

export enum ActionType {
NEW_ACCOUNT = "NEW_ACCOUNT",
DESTROY_ACCOUNT = "DESTROY_ACCOUNT",
ISSUE_ASSET = "ISSUE_ASSET",
TRANSFER = "TRANSFER",
}
export type NewActionDTO = NewTransferDTO | NewAccountDTO | IssueAssetDTO | DestroyAccountDTO
export type ActionDTO = TransferDTO | AccountDTO | AssetDTO | DestroyAccountDTO
export type Fields = { [key: string]: string }
export interface SearchOptions {
fields?: Fields
pagination?: PaginationParams
}
export interface NewActionBatchDTO {
actions: NewActionDTO[]
fields?: Fields
}
export interface ActionBatchDTO {
id: string
actions: ActionDTO[]
fields?: Fields
createdAt: Date
}
export interface DestroyAccountDTO {
type: ActionType.DESTROY_ACCOUNT
id: string
}
export interface NewTransferDTO {
type: ActionType.TRANSFER
from: string
to: string
amount: string
assetId: string
}
export interface TransferDTO extends NewTransferDTO {
id: string
}
export interface IssueAssetDTO {
type: ActionType.ISSUE_ASSET
code: string
fields?: Fields
}
export interface AssetDTO extends IssueAssetDTO {
id: string
}
export interface NewAccountDTO {
type: ActionType.NEW_ACCOUNT
fields?: Fields
}
export interface Balance {
asset: AssetDTO
amount: string
}
export interface AccountDTO extends NewAccountDTO {
id: string
balances: Balance[]
}
export interface PaginationParams {
limit?: number,
starting_after?: number
}
export interface CredentialDTO {
apiKey: string
secret: string
}
export interface SignatureParams {
requestPath: string
body: string | null
secret: string
timestamp: string
method: string
}
export interface PaymentProductDTO {
id: string
code: string
name: string
quantity: number
amount: string
}
export enum BoletoCashInStatusCode {
Created = "Created",
Paid = "Paid",
PartiallyPaid = "PartiallyPaid",
Error = "Error",
}
export interface Document {
type: "CPF" | "CNPJ"
rawValue: string
}
export interface Phone {
countryCode: string // 55
areaCode: string // 11
rawValue: string
}
export interface BoletoCashInPaymentDTO {
amount: string
date: Date
}
export interface PayerDTO {
fullName: string
document: Document
email: string
}
export interface NewBoletoCashInDTO {
receiverAccountId: string
assetId: string
payerInfo: PayerDTO
amount: string
expiresAt: Date
fields?: Fields
}
export interface BoletoCashInDTO extends NewBoletoCashInDTO {
id: string
integrationId: string
url: string
paidAmount: string
payments: BoletoCashInPaymentDTO[]
status: BoletoCashInStatusCode
barCode: string
}
export enum TriggerType {
WebHook = "WebHook",
Ledger_Transfer = "Ledger_Transfer",
}
export enum TriggerCondition {
Ledger_Transfer = "Ledger_Transfer",
CashIn_Boleto_Settled = "CashIn_Boleto_Settled",
}
export type WebHookTriggerData = {
url: string
}
export interface NewWebHookTriggerDTO {
type: TriggerType.WebHook
condition: TriggerCondition
data: WebHookTriggerData
}
export interface WebHookTriggerDTO extends NewWebHookTriggerDTO {
id: string
}
export type LedgerTransferTriggerData = null
export interface NewLedgerTransferTriggerDTO {
type: TriggerType.Ledger_Transfer
condition: TriggerCondition
data: LedgerTransferTriggerData
}
export interface LedgerTransferTriggerDTO extends NewLedgerTransferTriggerDTO {
id: string
}
export type TriggerData = WebHookTriggerData | LedgerTransferTriggerData
export type NewTriggerDTO = NewWebHookTriggerDTO | NewLedgerTransferTriggerDTO
export type TriggerDTO = WebHookTriggerDTO | LedgerTransferTriggerDTO
export enum ErrorCode {
Unauthorized = "UNAUTHORIZED",
InternalServerError = "INTERNAL_SERVER_ERROR",
ValidationError = "BAD_REQUEST_BODY",
NotFound = "NOT_FOUND",
}
export enum SubErrorCode {
InvalidToken = "INVALID_TOKEN",
InvalidId = "INVALID_ID",
AssetCodeAlreadyExists = "ASSET_CODE_ALREADY_EXISTS",
TransferFromNotFound = "TRANSFER_FROM_NOT_FOUND",
TransferToNotFound = "TRANSFER_TO_NOT_FOUND",
TransferAssetNotFound = "TRANSFER_ASSET_NOT_FOUND",
TransferUnderfunded = "TRANSFER_UNDERFUNDED",
InvalidActionType = "INVALID_ACTION_TYPE",
BatchLimitExceeded = "BATCH_LIMIT_EXCEEDED",
FieldNotFound = "FIELD_NOT_FOUND",
TriggerInvalidType = "TRIGGER_INVALID_TYPE",
TriggerInvalidCondition = "TRIGGER_INVALID_CONDITION",
AccountAlreadyHasCredential = "ACCOUNT_ALREADY_HAS_CREDENTIAL",
PermissionDenied = "PERMISSION_DENIED",
IntegrationNotEnabled = "INTEGRATION_NOT_ENABLED",
MissingKyc = "MISSING_KYC",
InvalidAmount = "INVALID_AMOUNT",
}
export interface SubError {
code: SubErrorCode
msg: string
field?: string
index?: number
}
export interface SwpError extends Error {
code: ErrorCode
message: string
subErrors: SubError[]
}
export interface Pagination {
cursor: number
}
export interface SwpResponse<T> {
status: number
data?: T
error?: SwpError,
pagination?: Pagination
}
export interface SwpSuccessResponse<T> {
status: number
data: T
pagination?: Pagination
}