@swp/swipe-sdk v0.12.71
SWIPE SDK
Integration with our api.
Table of Contents
Install
Using npm:
$ npm install @swp/swipe-sdkExamples
The sdk have type system in typescript
Initialize
import { Swipe } from '@swp/swipe-sdk'
const sdk = new Swipe({
apiKey: string, // Ex: key
secret: string, // Ex: secret
sandbox?: boolean, // default false to acess prod
customHost?: string, // default null
debug?: boolean // default false
})Ledger
- hello
const data = sdk.Ledger.hello()- getMyAccount
const data = sdk.Ledger.getMyAccount()- createChildrenAccounts
const newAccounts = [
{
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
},
...
]
const data = sdk.Ledger.createChildrenAccounts(newAccounts)const searchOption = {
queryParams?: {
'...': '...',
...
},
pagination?: {
limit?: number, // number bigger than 0
starting_after: number //number bigger than 0
},
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.Ledger.getChildrenAccounts(searchOption?)- getChildAccount
const accountId: string = '...'
const data = sdk.Ledger.getChildAccount(accountId)- destroyAccount
const accountId: string = '...'
const data = sdk.Ledger.destroyAccount(accountId)- createAsset
const asset = {
code: string, // Ex: 'BRL' or 'USD' or 'Banana'
decimalPlaces?: number, // for have a asset like '5.00000' set 5
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.Ledger.createAsset(asset)- getAssets
const searchOptions = {
queryParams?: {
'...': '...',
...
},
pagination?: {
limit?: number, // number bigger than 0
starting_after: number //number bigger than 0
},
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.Ledger.getAssets(searchOptions)- getAsset
const assetId:string = '...'
const data = sdk.Ledger.getAsset(assetId)- getActionBatches
const searchOptions = {
queryParams?: {
'fromDate': string, // Ex: '2020-12-18T16:19:09.000Z'
'toDate': string, // Ex: '2020-12-18T16:19:09.000Z'
'type': ActionType.TRANSFER | ActionType.ISSUE_ASSET | ActionType.BURN_ASSET
...
},
pagination?: {
limit?: number, // number bigger than 0
starting_after: number //number bigger than 0
},
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.Ledger.getActionBatches(searchOptions)- getActionBatch
const batchId:string = '...'
const data = sdk.Ledger.getActionBatch(batchId)- newActionBatch
const newActionsBatchs = {
actions: [
{
type: ActionType.TRANSFER,
amount: string, // Ex: '2.7'
from: string, // senderId
to: string, // receiverId
assetId: string // assetId
},
{
type: ActionType.ISSUE_ASSET,
amount: string, // Ex: '4.20'
to: string, // receiverId
assetId: string // assetId
},
{
type: ActionType.BURN_ASSET,
amount: string, // Ex: '3.141549'
from: string, // senderId
assetId: string // assetId
},
...
],
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.Ledger.newActionBatch(newActionsBatchs)- revokeCredentialGetToken
const data = sdk.Ledger.revokeCredentialGetToken()- revokeCredential
const token:string = '...'
const data = sdk.Ledger.revokeCredential(token)- resetAll
const data = sdk.Ledger.resetAll()Profile
- addProfileToAccount
const accountId:string = '...'
const profile = {
name: string, // Ex: 'Frederico Ferreira Franco'
email: string, // Ex: 'donald@knuth.com'
phone: string, // Ex: ''+5511900000000'
cpf: string, // Ex: '000.000.000-00'
birthDate: string, // Ex: '1990-12-17'
motherName: string, // Ex: 'Francisca Ferreica Franco'
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.Profile.addProfileToAccount(accountId, profile)- addProfileToAccountCompany
const profileCompany = {
name: string, //: Ex: 'Swipe"
corporateName: string, // Ex: 'Swipe'
cnpj: string, // Ex: '00.000.000/0000-00' or '00000000000000'
email: string, // Ex: 'swipe@swipetech.io'
phone: string, // Ex: '11900000000'
cnae?: string, // Ex: 'Agricultor'
openingDate: string, // Ex: '1990-12-17'
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
},
companyPartner: {
name: string, // Ex: 'Francisco Ferreiro'
cpf: string, // Ex: '000.000.000-00' or '00000000000'
birthDate: string, // Ex: '1990-12-17'
motherName: string, // Ex: 'Maria Ferreiro'
cellphone?: string, // Ex: '11900000000'
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
}
const data = sdk.Profile.addProfileToAccountCompany(accountId, profileCompany)- addAddressToProfile
const accountId:string = '...'
const address = {
zipCode: string, // Ex: '000000-000'
city: string, // Ex: 'São João do Rio do Peixe'
complement?: string, // Ex: 'Logo ali depois da praça do peixe'
country: string, // Ex: 'BR'
neighborhood: string, // Ex: 'centro'
number: string, // Ex: '42'
state: string, // Ex: 'SP'
street: string, // Ex: 'Av. Brasil'
}
const data = sdk.Profile.addAddressToProfile(accountId, address)- addDocumentsToProfile
const accountId:string = '...'
const documents = {
frontSide: string, // Ex: 'C:/Images/image.png'
backSide?: string, // Ex: 'C:/Images/image.png'
proofOfResidence: string, // Ex: 'C:/Images/image.png'
selfie: string // Ex: 'C:/Images/image.png'
}
const data = sdk.Profile.addDocumentsToProfile(accountId, documents)- addDocumentsToProfileCompany
const accountId:string = '...'
const documents = {
frontSide: string, // Ex: 'C:/Images/image.png'
backSide?: string, // Ex: 'C:/Images/image.png'
proofOfResidence: string, // Ex: 'C:/Images/image.png'
selfie: string, // Ex: 'C:/Images/image.png'
socialContract: string, // Ex: 'C:/Images/image.png'
cnpjCard: string // Ex: 'C:/Images/image.png'
}
const data = sdk.Profile.addDocumentsToProfileCompany(accountId, documents)- getProfile
const accountId:string = '...'
const data = sdk.Profile.getProfile(accountId)- resetRejectedProfile
const accountId:string = '...'
const data = sdk.Profile.resetRejectedProfile(accountId)- aproveProfile
const accountId:string = '...'
const data = sdk.Profile.aproveProfile(accountId)- rejectProfile
const accountId:string = '...'
const data = sdk.Profile.rejectProfile(accountId)- getUsers
const searchOptions = {
queryParams?: {
'with_balance': boolean,
'name': string,
'document': string,
'status': boolean,
...
},
pagination?: {
limit?: number, // number bigger than 0
starting_after: number //number bigger than 0
}
}
const data = sdk.profile.getUsers(searchOptions)Cash-In
- newBoleto
const boleto = {
amount: string, // Ex: '42.0'
depositAccount: string, // Ex: 'id'
dueDate: string, // Ex: '2020-08-01T13:38:24.600Z'
split?: [
{
accountId: string, // Ex: accountId
percentage: number // Ex: 0.55
}
]
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.CashIn.newBoleto(id)- getBoleto
const boletoId:string = '...'
const data = sdk.CashIn.getBoleto(boletoId)- boletoPaymentSimulation
const boletoId:string = '...'
const data = sdk.CashIn.boletoPaymentSimulation(boletoId)- getBoletoByBarCode
const barCode: string = '...'
const data = sdk.CashIn.getBoletoByBarCode(barCode)- getAllBoletos
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.CashIn.getAllBoletos(searchOptions)- newTokenCreditCard
const creditCardCustomer = {
buyer?: {
document?: string // Ex: '00000000000'
},
creditCard: {
cardNumber: string, // Ex: '0000000000000000'
holderName: string, // Ex: 'João S Silveira'
expirationMonth: string, // Ex: '07'
expirationYear: string, // Ex: '2042'
securityCode: string, // Ex: '097'
}
}
const data = sdk.CashIn.newTokenCreditCard(creditCardCustomer)- newCreditCard
const creditCard = {
installments?: number,
creditCard: string, // Ex: id
customer: string, // Ex: id
amount: string, // Ex: '0.42'
depositAccount: string, // Ex: id
split?: [
{
accountId: string, // Ex: accountId
percentage: number
}
]
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.CashIn.newCreditCard(creditCard)- getCreditCardTransactionById
const id:string = '...'
const data = sdk.CashIn.getCreditCardTransactionById(id)- getAllCreditCardCashIn
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.CashIn.getAllCreditCardCashIn(searchOptions)- getAllCreditCardCustomerByIdCashIn
const data = sdk.CashIn.getAllCreditCardCustomerByIdCashIn()- newLotteryCashIn
const lottery = {
amount: string, // Ex: '3.1415'
depositAccountId: string // id
}
const data = sdk.CashIn.newLotteryCashIn(lottery)- getAllLotteryCashIn
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.CashIn.getAllLotteryCashIn(searchOptions)- getLotteryCashInById
const id:string = '...'
const data = sdk.CashIn.getLotteryCashInById(id)- cancelLotteryCashInById
const id:string = '...'
const data = sdk.CashIn.cancelLotteryCashInById(id)- confirmLottery
const id:string = '...'
const data = sdk.CashIn.confirmLottery(id)CashOut
- payBoleto
const boleto = {
amount: string, // Ex: '13.0'
barCode?: string, // Ex: code
type?: BoletoType.Utility | BoletoType.General
withdrawAccountId: string // Ex: id
}
const data = sdk.CashOut.payBoleto(boleto)- getBoleto
const id:string = '...'
const data = sdk.CashOut.getBoleto(id)- getBoletoInfo
const barCode:string = '...'
const data = sdk.CashOut.getBoletoInfo(barCode)- getAllBoletos
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.CashOut.getAllBoletos(searchOptions)- newBankTransfer
const bankTransfer = {
amount: string, // Ex: '12.0'
withdrawAccountId: string, // Ex: id
receiver: {
bankCode: string, // Ex: '340'
bankAgency: string, // Ex: '2000'
bankAgencyDigit?: string, // Ex: '0'
bankAccount: string, // Ex: '12345'
bankAccountDigit?: string, // Ex: '1'
name: string, // Ex: 'João Silva Silveira'
document: string, // Ex: '12345678910'
}
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.CashOut.newBankTransfer(bankTransfer)- getBankTransfer
const id:string = '...'
const data = sdk.CashOut.getBankTransfer(id)- getBanks
const data = sdk.CashOut.getBanks()- getAllBankTransfers
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.CashOut.getAllBankTransfers(searchOptions)- newTopUp
const topUp = {
providerId: number, // Ex: providerId
amount: string, // Ex: '12.0'
withdrawAccountId: string, // Ex: accountId
phone?: string, // Ex: '00900000000'
tvSignerCode?: string, // Ex: id
fields?: {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.CashOut.newTopUp(topUp)- confirmTopUp
const id:string = '...'
const data = sdk.CashOut.confirmTopUp(id)- cancelTopUp
const id:string = '...'
const data = sdk.CashOut.cancelTopUp(id)- findPhoneProvider
const phoneStateCode:number = number
const phoneNumber:string = '...'
const data = sdk.CashOut.findPhoneProvider(phoneStateCode, phoneNumber)- getTopUpCashOutById
const id:string = '...'
const data = sdk.CashOut.getTopUpCashOutById(id)- getAllTopUpProviders
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?)- newLotteryCashOut
const lotteryWithdrawal = {
amount: string, // Ex: '2.0'
withdrawAccountId: string, // id
}
const data = sdk.CashOut.newLotteryCashOut(lotteryWithdrawal)- getAllLotteryCashOut
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.CashOut.getAllLotteryCashOut(searchOptions)- getLotteryCashOutById
const id:string = '...'
const data = sdk.CashOut.getLotteryCashOutById(id)- cancelLotteryCashOut
const id:string = '...'
const data = sdk.CashOut.cancelLotteryCashOut(id)- confirmLottery
const id:string = '...'
const data = sdk.CashOut.confirmLottery(id)Login
- createLogin
const login = {
login: string, // Ex: 'the_quick_brown_fox' or 'izaac@azimov.com'
password: string,
accountId: string, // accountId
}
const data = sdk.Login.createLogin(login)- newSession
const login = {
email: string, // Ex: 'the_quick_brown_fox' or 'izaac@azimov.com'
password: string,
expirationInDays?: number // Ex: 10
}
const data = sdk.Login.newSession(login)- isSessionActive
const id:string = '...'
const data = sdk.Login.isSessionActive(id)- destroySession
const id:string = '...'
const data = sdk.Login.destroySession(id)- addNewTermsAndConditions
const newTermsAndConditions = {
text:string = '...', // Ex: 'Payment account opening agreement...'
}
## <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)- getAllTransactionHistory
import {HistoryStatus, Service, ServiceType} from "./history";
const searchOptions = {
queryParams? : {
'fromDate': string, // Ex: '2020-12-18T16:19:09.000Z'
'toDate': string, // Ex: '2020-12-18T16:19:09.000Z'
'service': string, // EX: 'LEDGER,CASH_IN' // Service
'serviceType': string, // EX: 'BANK_SLIP,CREDIT_CARD' // ServiceType
'document': string,
'amountTo': string,
'amountFrom': string,
'name': string,
'status': HistoryStatus,
...
},
pagination? : {
limit? : number, // number bigger than 0
starting_after: number //number bigger than 0
},
fields? : {
'...': '...', // string:string Ex: 'clientType': 'common'
...
}
}
const data = sdk.history.getAllTransactionHistory(id, searchOptions)4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago