Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi DLL) Banco Inter Obtendo uma lista de boletosSee more Banco Inter ExamplesGet a list of tickets that match the search criteria. For more information, see https://developers.bancointer.com.br/reference/pesquisarboletos
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, HttpResponse, StringBuilder, JsonObject, PrivateKey, Cert, Http, BinData; ... procedure TForm1.Button1Click(Sender: TObject); var http: HCkHttp; success: Boolean; cert: HCkCert; bdPrivKey: HCkBinData; privKeyPassword: PWideChar; privKey: HCkPrivateKey; queryParams: HCkJsonObject; resp: HCkHttpResponse; sbResponseBody: HCkStringBuilder; jResp: HCkJsonObject; respStatusCode: Integer; nomeBeneficiario: PWideChar; cnpjCpfBeneficiario: PWideChar; totalPages: Integer; totalElements: Integer; last: Boolean; first: Boolean; size: Integer; numberOfElements: Integer; i: Integer; count_i: Integer; begin // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http := CkHttp_Create(); // 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 cert := CkCert_Create(); success := CkCert_LoadFromFile(cert,'<nome arquivo certificado>.crt'); if (success = False) then begin Memo1.Lines.Add(CkCert__lastErrorText(cert)); Exit; end; bdPrivKey := CkBinData_Create(); success := CkBinData_LoadFile(bdPrivKey,'<nome arquivo chave privada>.key'); if (success = False) then begin Memo1.Lines.Add('Failed to load key'); Exit; end; // Note: If your private key file requires a password, then set it here. // Otherwise pass the empty string. privKeyPassword := ''; privKey := CkPrivateKey_Create(); success := CkPrivateKey_LoadAnyFormat(privKey,bdPrivKey,privKeyPassword); if (success = False) then begin Memo1.Lines.Add(CkPrivateKey__lastErrorText(privKey)); Exit; end; success := CkCert_SetPrivateKey(cert,privKey); if (success = False) then begin Memo1.Lines.Add(CkCert__lastErrorText(cert)); Exit; end; CkHttp_SetSslClientCert(http,cert); queryParams := CkJsonObject_Create(); CkJsonObject_UpdateString(queryParams,'dataInicial','2022-04-01'); CkJsonObject_UpdateString(queryParams,'dataFinal','2022-04-03'); CkJsonObject_UpdateString(queryParams,'situacao','VENCIDO'); CkJsonObject_UpdateString(queryParams,'tipoOrdenacao','ASC'); CkJsonObject_UpdateInt(queryParams,'itensPorPagina',10); CkJsonObject_UpdateInt(queryParams,'paginaAtual',2); // Adds the "Authorization: Bearer $TOKEN" header. CkHttp_putAuthToken(http,'$TOKEN'); resp := CkHttp_QuickRequestParams(http,'GET','https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos',queryParams); if (CkHttp_getLastMethodSuccess(http) = False) then begin Memo1.Lines.Add(CkHttp__lastErrorText(http)); Exit; end; sbResponseBody := CkStringBuilder_Create(); CkHttpResponse_GetBodySb(resp,sbResponseBody); jResp := CkJsonObject_Create(); CkJsonObject_LoadSb(jResp,sbResponseBody); CkJsonObject_putEmitCompact(jResp,False); Memo1.Lines.Add('Response Body:'); Memo1.Lines.Add(CkJsonObject__emit(jResp)); respStatusCode := CkHttpResponse_getStatusCode(resp); Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode)); if (respStatusCode >= 400) then begin Memo1.Lines.Add('Response Header:'); Memo1.Lines.Add(CkHttpResponse__header(resp)); Memo1.Lines.Add('Failed.'); CkHttpResponse_Dispose(resp); Exit; end; CkHttpResponse_Dispose(resp); // 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 totalPages := CkJsonObject_IntOf(jResp,'totalPages'); totalElements := CkJsonObject_IntOf(jResp,'totalElements'); last := CkJsonObject_BoolOf(jResp,'last'); first := CkJsonObject_BoolOf(jResp,'first'); size := CkJsonObject_IntOf(jResp,'size'); numberOfElements := CkJsonObject_IntOf(jResp,'numberOfElements'); i := 0; count_i := CkJsonObject_SizeOfArray(jResp,'content'); while i < count_i do begin CkJsonObject_putI(jResp,i); nomeBeneficiario := CkJsonObject__stringOf(jResp,'content[i].nomeBeneficiario'); cnpjCpfBeneficiario := CkJsonObject__stringOf(jResp,'content[i].cnpjCpfBeneficiario'); i := i + 1; end; CkHttp_Dispose(http); CkCert_Dispose(cert); CkBinData_Dispose(bdPrivKey); CkPrivateKey_Dispose(privKey); CkJsonObject_Dispose(queryParams); CkStringBuilder_Dispose(sbResponseBody); CkJsonObject_Dispose(jResp); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.