DataFlex
DataFlex
Banco Inter Obtendo uma lista de boletos
See more Banco Inter Examples
Get a list of tickets that match the search criteria.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
Variant vCert
Handle hoCert
Variant vBdPrivKey
Handle hoBdPrivKey
String sPrivKeyPassword
Variant vPrivKey
Handle hoPrivKey
Variant vQueryParams
Handle hoQueryParams
Variant vResp
Handle hoResp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sNomeBeneficiario
String sCnpjCpfBeneficiario
Integer iTotalPages
Integer iTotalElements
Boolean iLast
Boolean iFirst
Integer iSize
Integer iNumberOfElements
Integer i
Integer iCount_i
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Implements the following CURL command:
// curl \
// -X GET \
// -H "Authorization: Bearer $TOKEN" \
// --cert <nome arquivo certificado>.crt \
// --key <nome arquivo chave privada>.key \
// --get \
// --data-urlencode "dataInicial=2022-04-01" \
// --data-urlencode "dataFinal=2022-04-03" \
// --data-urlencode "situacao=VENCIDO" \
// --data-urlencode "tipoOrdenacao=ASC" \
// --data-urlencode "itensPorPagina=10" \
// --data-urlencode "paginaAtual=2" \
// https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos
// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code
Get Create (RefClass(cComChilkatCert)) To hoCert
If (Not(IsComObjectCreated(hoCert))) Begin
Send CreateComObject of hoCert
End
Get ComLoadFromFile Of hoCert "<nome arquivo certificado>.crt" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCert To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatBinData)) To hoBdPrivKey
If (Not(IsComObjectCreated(hoBdPrivKey))) Begin
Send CreateComObject of hoBdPrivKey
End
Get ComLoadFile Of hoBdPrivKey "<nome arquivo chave privada>.key" To iSuccess
If (iSuccess = False) Begin
Showln "Failed to load key"
Procedure_Return
End
// Note: If your private key file requires a password, then set it here.
// Otherwise pass the empty string.
Move "" To sPrivKeyPassword
Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivKey
If (Not(IsComObjectCreated(hoPrivKey))) Begin
Send CreateComObject of hoPrivKey
End
Get pvComObject of hoBdPrivKey to vBdPrivKey
Get ComLoadAnyFormat Of hoPrivKey vBdPrivKey sPrivKeyPassword To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoPrivKey To sTemp1
Showln sTemp1
Procedure_Return
End
Get pvComObject of hoPrivKey to vPrivKey
Get ComSetPrivateKey Of hoCert vPrivKey To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoCert To sTemp1
Showln sTemp1
Procedure_Return
End
Get pvComObject of hoCert to vCert
Get ComSetSslClientCert Of hoHttp vCert To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoQueryParams
If (Not(IsComObjectCreated(hoQueryParams))) Begin
Send CreateComObject of hoQueryParams
End
Get ComUpdateString Of hoQueryParams "dataInicial" "2022-04-01" To iSuccess
Get ComUpdateString Of hoQueryParams "dataFinal" "2022-04-03" To iSuccess
Get ComUpdateString Of hoQueryParams "situacao" "VENCIDO" To iSuccess
Get ComUpdateString Of hoQueryParams "tipoOrdenacao" "ASC" To iSuccess
Get ComUpdateInt Of hoQueryParams "itensPorPagina" 10 To iSuccess
Get ComUpdateInt Of hoQueryParams "paginaAtual" 2 To iSuccess
// Adds the "Authorization: Bearer $TOKEN" header.
Set ComAuthToken Of hoHttp To "$TOKEN"
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get pvComObject of hoQueryParams to vQueryParams
Get pvComObject of hoResp to vResp
Get ComHttpParams Of hoHttp "GET" "https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos" vQueryParams vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "totalPages": 1,
// "totalElements": 58,
// "last": true,
// "first": true,
// "size": 100,
// "numberOfElements": 58,
// "content": [
// {
// "nomeBeneficiario": "nome do beneficiario 1",
// "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario 1"
// },
// {
// "nomeBeneficiario": "nome do beneficiario 2",
// "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario 2"
// },
// {
// "nomeBeneficiario": "nome do beneficiario N",
// "cnpjCpfBeneficiario": "CNPJ/CPF beneficiario N"
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use the following online tool to generate parsing code from sample JSON:
// Generate Parsing Code from JSON
Get ComIntOf Of hoJResp "totalPages" To iTotalPages
Get ComIntOf Of hoJResp "totalElements" To iTotalElements
Get ComBoolOf Of hoJResp "last" To iLast
Get ComBoolOf Of hoJResp "first" To iFirst
Get ComIntOf Of hoJResp "size" To iSize
Get ComIntOf Of hoJResp "numberOfElements" To iNumberOfElements
Move 0 To i
Get ComSizeOfArray Of hoJResp "content" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "content[i].nomeBeneficiario" To sNomeBeneficiario
Get ComStringOf Of hoJResp "content[i].cnpjCpfBeneficiario" To sCnpjCpfBeneficiario
Move (i + 1) To i
Loop
End_Procedure