Chilkat Online Tools

unicodeCpp / easybill REST API / Fetch customer

Back to Collection Items

#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>

void ChilkatSample(void)
    {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;
    bool success;

    http.SetRequestHeader(L"Authorization",L"{{apiKey}}");
    http.SetRequestHeader(L"Accept",L"application/json");

    CkStringBuilderW sbResponseBody;
    success = http.QuickGetSb(L"https://api.easybill.de/rest/v1/customers/:id",sbResponseBody);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = http.get_LastStatus();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",http.lastHeader());
        wprintf(L"Failed.\n");
        return;
    }

    // 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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    const wchar_t *strVal = 0;

    const wchar_t *last_name = jResp.stringOf(L"last_name");
    const wchar_t *company_name = jResp.stringOf(L"company_name");
    int acquire_options = jResp.IntOf(L"acquire_options");
    const wchar_t *bank_account = jResp.stringOf(L"bank_account");
    const wchar_t *bank_account_owner = jResp.stringOf(L"bank_account_owner");
    const wchar_t *bank_bic = jResp.stringOf(L"bank_bic");
    const wchar_t *bank_code = jResp.stringOf(L"bank_code");
    const wchar_t *bank_iban = jResp.stringOf(L"bank_iban");
    const wchar_t *bank_name = jResp.stringOf(L"bank_name");
    const wchar_t *birth_date = jResp.stringOf(L"birth_date");
    const wchar_t *cash_allowance = jResp.stringOf(L"cash_allowance");
    int cash_allowance_days = jResp.IntOf(L"cash_allowance_days");
    const wchar_t *cash_discount = jResp.stringOf(L"cash_discount");
    const wchar_t *cash_discount_type = jResp.stringOf(L"cash_discount_type");
    const wchar_t *city = jResp.stringOf(L"city");
    const wchar_t *state = jResp.stringOf(L"state");
    const wchar_t *country = jResp.stringOf(L"country");
    const wchar_t *created_at = jResp.stringOf(L"created_at");
    const wchar_t *updated_at = jResp.stringOf(L"updated_at");
    const wchar_t *delivery_title = jResp.stringOf(L"delivery_title");
    const wchar_t *delivery_city = jResp.stringOf(L"delivery_city");
    const wchar_t *delivery_state = jResp.stringOf(L"delivery_state");
    const wchar_t *delivery_company_name = jResp.stringOf(L"delivery_company_name");
    const wchar_t *delivery_country = jResp.stringOf(L"delivery_country");
    const wchar_t *delivery_first_name = jResp.stringOf(L"delivery_first_name");
    const wchar_t *delivery_last_name = jResp.stringOf(L"delivery_last_name");
    const wchar_t *delivery_personal = jResp.stringOf(L"delivery_personal");
    int delivery_salutation = jResp.IntOf(L"delivery_salutation");
    const wchar_t *delivery_street = jResp.stringOf(L"delivery_street");
    const wchar_t *delivery_suffix_1 = jResp.stringOf(L"delivery_suffix_1");
    const wchar_t *delivery_suffix_2 = jResp.stringOf(L"delivery_suffix_2");
    const wchar_t *delivery_zip_code = jResp.stringOf(L"delivery_zip_code");
    const wchar_t *display_name = jResp.stringOf(L"display_name");
    const wchar_t *fax = jResp.stringOf(L"fax");
    const wchar_t *first_name = jResp.stringOf(L"first_name");
    const wchar_t *grace_period = jResp.stringOf(L"grace_period");
    const wchar_t *due_in_days = jResp.stringOf(L"due_in_days");
    const wchar_t *group_id = jResp.stringOf(L"group_id");
    const wchar_t *id = jResp.stringOf(L"id");
    const wchar_t *info_1 = jResp.stringOf(L"info_1");
    const wchar_t *info_2 = jResp.stringOf(L"info_2");
    const wchar_t *internet = jResp.stringOf(L"internet");
    const wchar_t *login_id = jResp.stringOf(L"login_id");
    const wchar_t *mobile = jResp.stringOf(L"mobile");
    const wchar_t *note = jResp.stringOf(L"note");
    const wchar_t *v_number = jResp.stringOf(L"number");
    int payment_options = jResp.IntOf(L"payment_options");
    bool personal = jResp.BoolOf(L"personal");
    const wchar_t *phone_1 = jResp.stringOf(L"phone_1");
    const wchar_t *phone_2 = jResp.stringOf(L"phone_2");
    const wchar_t *postbox = jResp.stringOf(L"postbox");
    const wchar_t *postbox_city = jResp.stringOf(L"postbox_city");
    const wchar_t *postbox_state = jResp.stringOf(L"postbox_state");
    const wchar_t *postbox_country = jResp.stringOf(L"postbox_country");
    const wchar_t *postbox_zip_code = jResp.stringOf(L"postbox_zip_code");
    const wchar_t *sale_price_level = jResp.stringOf(L"sale_price_level");
    int salutation = jResp.IntOf(L"salutation");
    const wchar_t *sepa_agreement = jResp.stringOf(L"sepa_agreement");
    const wchar_t *sepa_agreement_date = jResp.stringOf(L"sepa_agreement_date");
    const wchar_t *sepa_mandate_reference = jResp.stringOf(L"sepa_mandate_reference");
    const wchar_t *since_date = jResp.stringOf(L"since_date");
    const wchar_t *street = jResp.stringOf(L"street");
    const wchar_t *suffix_1 = jResp.stringOf(L"suffix_1");
    const wchar_t *suffix_2 = jResp.stringOf(L"suffix_2");
    const wchar_t *tax_number = jResp.stringOf(L"tax_number");
    const wchar_t *court = jResp.stringOf(L"court");
    const wchar_t *court_registry_number = jResp.stringOf(L"court_registry_number");
    const wchar_t *tax_options = jResp.stringOf(L"tax_options");
    const wchar_t *title = jResp.stringOf(L"title");
    const wchar_t *archived = jResp.stringOf(L"archived");
    const wchar_t *vat_identifier = jResp.stringOf(L"vat_identifier");
    const wchar_t *zip_code = jResp.stringOf(L"zip_code");
    const wchar_t *document_pdf_type = jResp.stringOf(L"document_pdf_type");
    const wchar_t *buyer_reference = jResp.stringOf(L"buyer_reference");
    const wchar_t *foreign_supplier_number = jResp.stringOf(L"foreign_supplier_number");
    int i = 0;
    int count_i = jResp.SizeOfArray(L"additional_groups_ids");
    while (i < count_i) {
        jResp.put_I(i);
        strVal = jResp.stringOf(L"additional_groups_ids[i]");
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"emails");
    while (i < count_i) {
        jResp.put_I(i);
        strVal = jResp.stringOf(L"emails[i]");
        i = i + 1;
    }
    }

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": ""
    }
  ]
}