SWIPE SDK
Integration with our api.
Using npm:
$ npm install @swp/swipe-sdk
The sdk have type system in typescript
import { Swipe } from '@swp/swipe-sdk'
const sdk = new Swipe({
apiKey: string,
secret: string,
sandbox?: boolean,
customHost?: string,
debug?: boolean
})
const data = sdk.Ledger.hello()
const data = sdk.Ledger.getMyAccount()
const newAccounts = [
{
fields?: {
'...': '...',
...
}
},
...
]
const data = sdk.Ledger.createChildrenAccounts(newAccounts)
const searchOption = {
queryParams?: {
'...': '...',
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.Ledger.getChildrenAccounts(searchOption?)
const accountId: string = '...'
const data = sdk.Ledger.getChildAccount(accountId)
const accountId: string = '...'
const data = sdk.Ledger.destroyAccount(accountId)
const asset = {
code: string,
decimalPlaces?: number,
fields?: {
'...': '...',
...
}
}
const data = sdk.Ledger.createAsset(asset)
const searchOptions = {
queryParams?: {
'...': '...',
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.Ledger.getAssets(searchOptions)
const assetId:string = '...'
const data = sdk.Ledger.getAsset(assetId)
const searchOptions = {
queryParams?: {
'fromDate': string,
'toDate': string,
'type': ActionType.TRANSFER | ActionType.ISSUE_ASSET | ActionType.BURN_ASSET
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.Ledger.getActionBatches(searchOptions)
const batchId:string = '...'
const data = sdk.Ledger.getActionBatch(batchId)
const newActionsBatchs = {
actions: [
{
type: ActionType.TRANSFER,
amount: string,
from: string,
to: string,
assetId: string
},
{
type: ActionType.ISSUE_ASSET,
amount: string,
to: string,
assetId: string
},
{
type: ActionType.BURN_ASSET,
amount: string,
from: string,
assetId: string
},
...
],
fields?: {
'...': '...',
...
}
}
const data = sdk.Ledger.newActionBatch(newActionsBatchs)
const data = sdk.Ledger.revokeCredentialGetToken()
const token:string = '...'
const data = sdk.Ledger.revokeCredential(token)
const data = sdk.Ledger.resetAll()
const accountId:string = '...'
const profile = {
name: string,
email: string,
phone: string,
cpf: string,
birthDate: string,
motherName: string,
fields?: {
'...': '...',
...
}
}
const data = sdk.Profile.addProfileToAccount(accountId, profile)
- addProfileToAccountCompany
const profileCompany = {
name: string,
corporateName: string,
cnpj: string,
email: string,
phone: string,
cnae?: string,
openingDate: string,
fields?: {
'...': '...',
...
},
companyPartner: {
name: string,
cpf: string,
birthDate: string,
motherName: string,
cellphone?: string,
fields?: {
'...': '...',
...
}
}
}
const data = sdk.Profile.addProfileToAccountCompany(accountId, profileCompany)
const accountId:string = '...'
const address = {
zipCode: string,
city: string,
complement?: string,
country: string,
neighborhood: string,
number: string,
state: string,
street: string,
}
const data = sdk.Profile.addAddressToProfile(accountId, address)
const accountId:string = '...'
const documents = {
frontSide: string,
backSide?: string,
proofOfResidence: string,
selfie: string
}
const data = sdk.Profile.addDocumentsToProfile(accountId, documents)
- addDocumentsToProfileCompany
const accountId:string = '...'
const documents = {
frontSide: string,
backSide?: string,
proofOfResidence: string,
selfie: string,
socialContract: string,
cnpjCard: string
}
const data = sdk.Profile.addDocumentsToProfileCompany(accountId, documents)
const accountId:string = '...'
const data = sdk.Profile.getProfile(accountId)
const accountId:string = '...'
const data = sdk.Profile.resetRejectedProfile(accountId)
const accountId:string = '...'
const data = sdk.Profile.aproveProfile(accountId)
const accountId:string = '...'
const data = sdk.Profile.rejectProfile(accountId)
const searchOptions = {
queryParams?: {
'with_balance': boolean,
'name': string,
'document': string,
'status': boolean,
...
},
pagination?: {
limit?: number,
starting_after: number
}
}
const data = sdk.profile.getUsers(searchOptions)
const boleto = {
amount: string,
depositAccount: string,
dueDate: string,
split?: [
{
accountId: string,
percentage: number
}
]
fields?: {
'...': '...',
...
}
}
const data = sdk.CashIn.newBoleto(id)
const boletoId:string = '...'
const data = sdk.CashIn.getBoleto(boletoId)
const boletoId:string = '...'
const data = sdk.CashIn.boletoPaymentSimulation(boletoId)
const barCode: string = '...'
const data = sdk.CashIn.getBoletoByBarCode(barCode)
const searchOptions = {
queryParams?: {
'fromDate': string,
'toDate': string,
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.CashIn.getAllBoletos(searchOptions)
const creditCardCustomer = {
buyer?: {
document?: string
},
creditCard: {
cardNumber: string,
holderName: string,
expirationMonth: string,
expirationYear: string,
securityCode: string,
}
}
const data = sdk.CashIn.newTokenCreditCard(creditCardCustomer)
const creditCard = {
installments?: number,
creditCard: string,
customer: string,
amount: string,
depositAccount: string,
split?: [
{
accountId: string,
percentage: number
}
]
fields?: {
'...': '...',
...
}
}
const data = sdk.CashIn.newCreditCard(creditCard)
- getCreditCardTransactionById
const id:string = '...'
const data = sdk.CashIn.getCreditCardTransactionById(id)
const searchOptions = {
queryParams?: {
'fromDate': string,
'toDate': string,
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.CashIn.getAllCreditCardCashIn(searchOptions)
- getAllCreditCardCustomerByIdCashIn
const data = sdk.CashIn.getAllCreditCardCustomerByIdCashIn()
const lottery = {
amount: string,
depositAccountId: string
}
const data = sdk.CashIn.newLotteryCashIn(lottery)
const searchOptions = {
queryParams?: {
'fromDate': string,
'toDate': string,
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.CashIn.getAllLotteryCashIn(searchOptions)
const id:string = '...'
const data = sdk.CashIn.getLotteryCashInById(id)
const id:string = '...'
const data = sdk.CashIn.cancelLotteryCashInById(id)
const id:string = '...'
const data = sdk.CashIn.confirmLottery(id)
const boleto = {
amount: string,
barCode?: string,
type?: BoletoType.Utility | BoletoType.General
withdrawAccountId: string
}
const data = sdk.CashOut.payBoleto(boleto)
const id:string = '...'
const data = sdk.CashOut.getBoleto(id)
const barCode:string = '...'
const data = sdk.CashOut.getBoletoInfo(barCode)
const searchOptions = {
queryParams?: {
'fromDate': string,
'toDate': string,
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.CashOut.getAllBoletos(searchOptions)
const bankTransfer = {
amount: string,
withdrawAccountId: string,
receiver: {
bankCode: string,
bankAgency: string,
bankAgencyDigit?: string,
bankAccount: string,
bankAccountDigit?: string,
name: string,
document: string,
}
fields?: {
'...': '...',
...
}
}
const data = sdk.CashOut.newBankTransfer(bankTransfer)
const id:string = '...'
const data = sdk.CashOut.getBankTransfer(id)
const data = sdk.CashOut.getBanks()
const searchOptions = {
queryParams?: {
'fromDate': string,
'toDate': string,
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.CashOut.getAllBankTransfers(searchOptions)
const topUp = {
providerId: number,
amount: string,
withdrawAccountId: string,
phone?: string,
tvSignerCode?: string,
fields?: {
'...': '...',
...
}
}
const data = sdk.CashOut.newTopUp(topUp)
const id:string = '...'
const data = sdk.CashOut.confirmTopUp(id)
const id:string = '...'
const data = sdk.CashOut.cancelTopUp(id)
const phoneStateCode:number = number
const phoneNumber:string = '...'
const data = sdk.CashOut.findPhoneProvider(phoneStateCode, phoneNumber)
const id:string = '...'
const data = sdk.CashOut.getTopUpCashOutById(id)
const id:string = {
phoneStateCode?: number,
category?: number,
type?: number
}
const data = sdk.CashOut.getAllTopUpProviders(id)
- getAvailableAmountsForProvider
const id:number = number
const phoneStateCode:string = '...'
const data = sdk.CashOut.getAvailableAmountsForProvider(id, phoneStateCode?)
const lotteryWithdrawal = {
amount: string,
withdrawAccountId: string,
}
const data = sdk.CashOut.newLotteryCashOut(lotteryWithdrawal)
const searchOptions = {
queryParams?: {
'fromDate': string,
'toDate': string,
...
},
pagination?: {
limit?: number,
starting_after: number
},
fields?: {
'...': '...',
...
}
}
const data = sdk.CashOut.getAllLotteryCashOut(searchOptions)
const id:string = '...'
const data = sdk.CashOut.getLotteryCashOutById(id)
const id:string = '...'
const data = sdk.CashOut.cancelLotteryCashOut(id)
const id:string = '...'
const data = sdk.CashOut.confirmLottery(id)
const login = {
login: string,
password: string,
accountId: string,
}
const data = sdk.Login.createLogin(login)
const login = {
email: string,
password: string,
expirationInDays?: number
}
const data = sdk.Login.newSession(login)
const id:string = '...'
const data = sdk.Login.isSessionActive(id)
const id:string = '...'
const data = sdk.Login.destroySession(id)
const newTermsAndConditions = {
text:string = '...',
}
## <a name="History">History</a>
@deprecated The method should not be used, use getAllTransactionHistory
- getTransactionHistory
```typescript
const searchOptions = {
queryParams?: {
'fromDate': string, // Ex: '2020-12-18T16:19:09.000Z'
'toDate': string, // Ex: '2020-12-18T16:19:09.000Z'
...
},
pagination?: {
limit?: number, // number bigger than 0
starting_after: number //number bigger than 0
},
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.history.getTransactionHistory(id, searchOptions)
import {HistoryStatus, Service, ServiceType} from "./history";
const searchOptions = {
queryParams? : {
'fromDate': string,
'toDate': string,
'service': string,
'serviceType': string,
'document': string,
'amountTo': string,
'amountFrom': string,
'name': string,
'status': HistoryStatus,
...
},
pagination? : {
limit? : number,
starting_after: number
},
fields? : {
'...': '...',
...
}
}
const data = sdk.history.getAllTransactionHistory(id, searchOptions)