Chilkat Online Tools

delphiDll / easybill REST API / Fetch customer

Back to Collection Items

var
http: HCkHttp;
success: Boolean;
sbResponseBody: HCkStringBuilder;
jResp: HCkJsonObject;
respStatusCode: Integer;
strVal: PWideChar;
last_name: PWideChar;
company_name: PWideChar;
acquire_options: Integer;
bank_account: PWideChar;
bank_account_owner: PWideChar;
bank_bic: PWideChar;
bank_code: PWideChar;
bank_iban: PWideChar;
bank_name: PWideChar;
birth_date: PWideChar;
cash_allowance: PWideChar;
cash_allowance_days: Integer;
cash_discount: PWideChar;
cash_discount_type: PWideChar;
city: PWideChar;
state: PWideChar;
country: PWideChar;
created_at: PWideChar;
updated_at: PWideChar;
delivery_title: PWideChar;
delivery_city: PWideChar;
delivery_state: PWideChar;
delivery_company_name: PWideChar;
delivery_country: PWideChar;
delivery_first_name: PWideChar;
delivery_last_name: PWideChar;
delivery_personal: PWideChar;
delivery_salutation: Integer;
delivery_street: PWideChar;
delivery_suffix_1: PWideChar;
delivery_suffix_2: PWideChar;
delivery_zip_code: PWideChar;
display_name: PWideChar;
fax: PWideChar;
first_name: PWideChar;
grace_period: PWideChar;
due_in_days: PWideChar;
group_id: PWideChar;
id: PWideChar;
info_1: PWideChar;
info_2: PWideChar;
internet: PWideChar;
login_id: PWideChar;
mobile: PWideChar;
note: PWideChar;
v_number: PWideChar;
payment_options: Integer;
personal: Boolean;
phone_1: PWideChar;
phone_2: PWideChar;
postbox: PWideChar;
postbox_city: PWideChar;
postbox_state: PWideChar;
postbox_country: PWideChar;
postbox_zip_code: PWideChar;
sale_price_level: PWideChar;
salutation: Integer;
sepa_agreement: PWideChar;
sepa_agreement_date: PWideChar;
sepa_mandate_reference: PWideChar;
since_date: PWideChar;
street: PWideChar;
suffix_1: PWideChar;
suffix_2: PWideChar;
tax_number: PWideChar;
court: PWideChar;
court_registry_number: PWideChar;
tax_options: PWideChar;
title: PWideChar;
archived: PWideChar;
vat_identifier: PWideChar;
zip_code: PWideChar;
document_pdf_type: PWideChar;
buyer_reference: PWideChar;
foreign_supplier_number: PWideChar;
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();

CkHttp_SetRequestHeader(http,'Authorization','{{apiKey}}');
CkHttp_SetRequestHeader(http,'Accept','application/json');

sbResponseBody := CkStringBuilder_Create();
success := CkHttp_QuickGetSb(http,'https://api.easybill.de/rest/v1/customers/:id',sbResponseBody);
if (success = False) then
  begin
    Memo1.Lines.Add(CkHttp__lastErrorText(http));
    Exit;
  end;

jResp := CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,False);

Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkJsonObject__emit(jResp));

respStatusCode := CkHttp_getLastStatus(http);
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(CkHttp__lastHeader(http));
    Memo1.Lines.Add('Failed.');
    Exit;
  end;

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "last_name": "<string>",
//   "company_name": "<string>",
//   "acquire_options": 2,
//   "additional_groups_ids": [
//     "<integer>",
//     "<integer>"
//   ],
//   "bank_account": "<string>",
//   "bank_account_owner": "<string>",
//   "bank_bic": "<string>",
//   "bank_code": "<string>",
//   "bank_iban": "<string>",
//   "bank_name": "<string>",
//   "birth_date": "<date>",
//   "cash_allowance": "<float>",
//   "cash_allowance_days": 7,
//   "cash_discount": "<float>",
//   "cash_discount_type": "AMOUNT",
//   "city": "<string>",
//   "state": "<string>",
//   "country": "<string>",
//   "created_at": "<date>",
//   "updated_at": "<string>",
//   "delivery_title": "<string>",
//   "delivery_city": "<string>",
//   "delivery_state": "<string>",
//   "delivery_company_name": "<string>",
//   "delivery_country": "<string>",
//   "delivery_first_name": "<string>",
//   "delivery_last_name": "<string>",
//   "delivery_personal": "<boolean>",
//   "delivery_salutation": 0,
//   "delivery_street": "<string>",
//   "delivery_suffix_1": "<string>",
//   "delivery_suffix_2": "<string>",
//   "delivery_zip_code": "<string>",
//   "display_name": "<string>",
//   "emails": [
//     "<string>",
//     "<string>"
//   ],
//   "fax": "<string>",
//   "first_name": "<string>",
//   "grace_period": "<integer>",
//   "due_in_days": "<integer>",
//   "group_id": "<integer>",
//   "id": "<long>",
//   "info_1": "<string>",
//   "info_2": "<string>",
//   "internet": "<string>",
//   "login_id": "<long>",
//   "mobile": "<string>",
//   "note": "<string>",
//   "number": "<string>",
//   "payment_options": 5,
//   "personal": false,
//   "phone_1": "<string>",
//   "phone_2": "<string>",
//   "postbox": "<string>",
//   "postbox_city": "<string>",
//   "postbox_state": "<string>",
//   "postbox_country": "<string>",
//   "postbox_zip_code": "<string>",
//   "sale_price_level": "SALEPRICE10",
//   "salutation": 0,
//   "sepa_agreement": "BASIC",
//   "sepa_agreement_date": "<date>",
//   "sepa_mandate_reference": "<string>",
//   "since_date": "<date>",
//   "street": "<string>",
//   "suffix_1": "<string>",
//   "suffix_2": "<string>",
//   "tax_number": "<string>",
//   "court": "<string>",
//   "court_registry_number": "<string>",
//   "tax_options": "nStbUstID",
//   "title": "<string>",
//   "archived": "<boolean>",
//   "vat_identifier": "<string>",
//   "zip_code": "<string>",
//   "document_pdf_type": "default",
//   "buyer_reference": "<string>",
//   "foreign_supplier_number": "<string>"
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

last_name := CkJsonObject__stringOf(jResp,'last_name');
company_name := CkJsonObject__stringOf(jResp,'company_name');
acquire_options := CkJsonObject_IntOf(jResp,'acquire_options');
bank_account := CkJsonObject__stringOf(jResp,'bank_account');
bank_account_owner := CkJsonObject__stringOf(jResp,'bank_account_owner');
bank_bic := CkJsonObject__stringOf(jResp,'bank_bic');
bank_code := CkJsonObject__stringOf(jResp,'bank_code');
bank_iban := CkJsonObject__stringOf(jResp,'bank_iban');
bank_name := CkJsonObject__stringOf(jResp,'bank_name');
birth_date := CkJsonObject__stringOf(jResp,'birth_date');
cash_allowance := CkJsonObject__stringOf(jResp,'cash_allowance');
cash_allowance_days := CkJsonObject_IntOf(jResp,'cash_allowance_days');
cash_discount := CkJsonObject__stringOf(jResp,'cash_discount');
cash_discount_type := CkJsonObject__stringOf(jResp,'cash_discount_type');
city := CkJsonObject__stringOf(jResp,'city');
state := CkJsonObject__stringOf(jResp,'state');
country := CkJsonObject__stringOf(jResp,'country');
created_at := CkJsonObject__stringOf(jResp,'created_at');
updated_at := CkJsonObject__stringOf(jResp,'updated_at');
delivery_title := CkJsonObject__stringOf(jResp,'delivery_title');
delivery_city := CkJsonObject__stringOf(jResp,'delivery_city');
delivery_state := CkJsonObject__stringOf(jResp,'delivery_state');
delivery_company_name := CkJsonObject__stringOf(jResp,'delivery_company_name');
delivery_country := CkJsonObject__stringOf(jResp,'delivery_country');
delivery_first_name := CkJsonObject__stringOf(jResp,'delivery_first_name');
delivery_last_name := CkJsonObject__stringOf(jResp,'delivery_last_name');
delivery_personal := CkJsonObject__stringOf(jResp,'delivery_personal');
delivery_salutation := CkJsonObject_IntOf(jResp,'delivery_salutation');
delivery_street := CkJsonObject__stringOf(jResp,'delivery_street');
delivery_suffix_1 := CkJsonObject__stringOf(jResp,'delivery_suffix_1');
delivery_suffix_2 := CkJsonObject__stringOf(jResp,'delivery_suffix_2');
delivery_zip_code := CkJsonObject__stringOf(jResp,'delivery_zip_code');
display_name := CkJsonObject__stringOf(jResp,'display_name');
fax := CkJsonObject__stringOf(jResp,'fax');
first_name := CkJsonObject__stringOf(jResp,'first_name');
grace_period := CkJsonObject__stringOf(jResp,'grace_period');
due_in_days := CkJsonObject__stringOf(jResp,'due_in_days');
group_id := CkJsonObject__stringOf(jResp,'group_id');
id := CkJsonObject__stringOf(jResp,'id');
info_1 := CkJsonObject__stringOf(jResp,'info_1');
info_2 := CkJsonObject__stringOf(jResp,'info_2');
internet := CkJsonObject__stringOf(jResp,'internet');
login_id := CkJsonObject__stringOf(jResp,'login_id');
mobile := CkJsonObject__stringOf(jResp,'mobile');
note := CkJsonObject__stringOf(jResp,'note');
v_number := CkJsonObject__stringOf(jResp,'number');
payment_options := CkJsonObject_IntOf(jResp,'payment_options');
personal := CkJsonObject_BoolOf(jResp,'personal');
phone_1 := CkJsonObject__stringOf(jResp,'phone_1');
phone_2 := CkJsonObject__stringOf(jResp,'phone_2');
postbox := CkJsonObject__stringOf(jResp,'postbox');
postbox_city := CkJsonObject__stringOf(jResp,'postbox_city');
postbox_state := CkJsonObject__stringOf(jResp,'postbox_state');
postbox_country := CkJsonObject__stringOf(jResp,'postbox_country');
postbox_zip_code := CkJsonObject__stringOf(jResp,'postbox_zip_code');
sale_price_level := CkJsonObject__stringOf(jResp,'sale_price_level');
salutation := CkJsonObject_IntOf(jResp,'salutation');
sepa_agreement := CkJsonObject__stringOf(jResp,'sepa_agreement');
sepa_agreement_date := CkJsonObject__stringOf(jResp,'sepa_agreement_date');
sepa_mandate_reference := CkJsonObject__stringOf(jResp,'sepa_mandate_reference');
since_date := CkJsonObject__stringOf(jResp,'since_date');
street := CkJsonObject__stringOf(jResp,'street');
suffix_1 := CkJsonObject__stringOf(jResp,'suffix_1');
suffix_2 := CkJsonObject__stringOf(jResp,'suffix_2');
tax_number := CkJsonObject__stringOf(jResp,'tax_number');
court := CkJsonObject__stringOf(jResp,'court');
court_registry_number := CkJsonObject__stringOf(jResp,'court_registry_number');
tax_options := CkJsonObject__stringOf(jResp,'tax_options');
title := CkJsonObject__stringOf(jResp,'title');
archived := CkJsonObject__stringOf(jResp,'archived');
vat_identifier := CkJsonObject__stringOf(jResp,'vat_identifier');
zip_code := CkJsonObject__stringOf(jResp,'zip_code');
document_pdf_type := CkJsonObject__stringOf(jResp,'document_pdf_type');
buyer_reference := CkJsonObject__stringOf(jResp,'buyer_reference');
foreign_supplier_number := CkJsonObject__stringOf(jResp,'foreign_supplier_number');
i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'additional_groups_ids');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    strVal := CkJsonObject__stringOf(jResp,'additional_groups_ids[i]');
    i := i + 1;
  end;

i := 0;
count_i := CkJsonObject_SizeOfArray(jResp,'emails');
while i < count_i do
  begin
    CkJsonObject_putI(jResp,i);
    strVal := CkJsonObject__stringOf(jResp,'emails[i]');
    i := i + 1;
  end;

CkHttp_Dispose(http);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);

Curl Command

curl -X GET
	-H "Authorization: {{apiKey}}"
	-H "Accept: application/json"
https://api.easybill.de/rest/v1/customers/:id

Postman Collection Item JSON

{
  "name": "Fetch customer",
  "request": {
    "method": "GET",
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "url": {
      "raw": "{{baseUrl}}/customers/:id",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "customers",
        ":id"
      ],
      "variable": [
        {
          "key": "id",
          "value": "<long>",
          "description": "(Required) ID of customer that needs to be fetched"
        }
      ]
    }
  },
  "response": [
    {
      "name": "Successful operation",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/customers/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "customers",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n  \"last_name\": \"<string>\",\n  \"company_name\": \"<string>\",\n  \"acquire_options\": 2,\n  \"additional_groups_ids\": [\n    \"<integer>\",\n    \"<integer>\"\n  ],\n  \"bank_account\": \"<string>\",\n  \"bank_account_owner\": \"<string>\",\n  \"bank_bic\": \"<string>\",\n  \"bank_code\": \"<string>\",\n  \"bank_iban\": \"<string>\",\n  \"bank_name\": \"<string>\",\n  \"birth_date\": \"<date>\",\n  \"cash_allowance\": \"<float>\",\n  \"cash_allowance_days\": 7,\n  \"cash_discount\": \"<float>\",\n  \"cash_discount_type\": \"AMOUNT\",\n  \"city\": \"<string>\",\n  \"state\": \"<string>\",\n  \"country\": \"<string>\",\n  \"created_at\": \"<date>\",\n  \"updated_at\": \"<string>\",\n  \"delivery_title\": \"<string>\",\n  \"delivery_city\": \"<string>\",\n  \"delivery_state\": \"<string>\",\n  \"delivery_company_name\": \"<string>\",\n  \"delivery_country\": \"<string>\",\n  \"delivery_first_name\": \"<string>\",\n  \"delivery_last_name\": \"<string>\",\n  \"delivery_personal\": \"<boolean>\",\n  \"delivery_salutation\": 0,\n  \"delivery_street\": \"<string>\",\n  \"delivery_suffix_1\": \"<string>\",\n  \"delivery_suffix_2\": \"<string>\",\n  \"delivery_zip_code\": \"<string>\",\n  \"display_name\": \"<string>\",\n  \"emails\": [\n    \"<string>\",\n    \"<string>\"\n  ],\n  \"fax\": \"<string>\",\n  \"first_name\": \"<string>\",\n  \"grace_period\": \"<integer>\",\n  \"due_in_days\": \"<integer>\",\n  \"group_id\": \"<integer>\",\n  \"id\": \"<long>\",\n  \"info_1\": \"<string>\",\n  \"info_2\": \"<string>\",\n  \"internet\": \"<string>\",\n  \"login_id\": \"<long>\",\n  \"mobile\": \"<string>\",\n  \"note\": \"<string>\",\n  \"number\": \"<string>\",\n  \"payment_options\": 5,\n  \"personal\": false,\n  \"phone_1\": \"<string>\",\n  \"phone_2\": \"<string>\",\n  \"postbox\": \"<string>\",\n  \"postbox_city\": \"<string>\",\n  \"postbox_state\": \"<string>\",\n  \"postbox_country\": \"<string>\",\n  \"postbox_zip_code\": \"<string>\",\n  \"sale_price_level\": \"SALEPRICE10\",\n  \"salutation\": 0,\n  \"sepa_agreement\": \"BASIC\",\n  \"sepa_agreement_date\": \"<date>\",\n  \"sepa_mandate_reference\": \"<string>\",\n  \"since_date\": \"<date>\",\n  \"street\": \"<string>\",\n  \"suffix_1\": \"<string>\",\n  \"suffix_2\": \"<string>\",\n  \"tax_number\": \"<string>\",\n  \"court\": \"<string>\",\n  \"court_registry_number\": \"<string>\",\n  \"tax_options\": \"nStbUstID\",\n  \"title\": \"<string>\",\n  \"archived\": \"<boolean>\",\n  \"vat_identifier\": \"<string>\",\n  \"zip_code\": \"<string>\",\n  \"document_pdf_type\": \"default\",\n  \"buyer_reference\": \"<string>\",\n  \"foreign_supplier_number\": \"<string>\"\n}"
    },
    {
      "name": "Not found",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/customers/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "customers",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Too Many Requests",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: apikey",
            "key": "Authorization",
            "value": "<API Key>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/customers/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "customers",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Too Many Requests",
      "code": 429,
      "_postman_previewlanguage": "text",
      "header": [
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}