Chilkat Online Tools

PureBasic / Belvo API Docs / Detail

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"

Procedure ChilkatExample()

    ; This example assumes the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    CkHttp::setCkBasicAuth(http, 1)
    CkHttp::setCkLogin(http, "{{secretId}}")
    CkHttp::setCkPassword(http, "{{secretPassword}}")

    sbResponseBody.i = CkStringBuilder::ckCreate()
    If sbResponseBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkHttp::ckQuickGetSb(http,"https://domain.com/api/accounts/:id/",sbResponseBody)
    If success = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkStringBuilder::ckDispose(sbResponseBody)
        ProcedureReturn
    EndIf

    jResp.i = CkJsonObject::ckCreate()
    If jResp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoadSb(jResp,sbResponseBody)
    CkJsonObject::setCkEmitCompact(jResp, 0)

    Debug "Response Body:"
    Debug CkJsonObject::ckEmit(jResp)

    respStatusCode.i = CkHttp::ckLastStatus(http)
    Debug "Response Status Code = " + Str(respStatusCode)
    If respStatusCode >= 400
        Debug "Response Header:"
        Debug CkHttp::ckLastHeader(http)
        Debug "Failed."
        CkHttp::ckDispose(http)
        CkStringBuilder::ckDispose(sbResponseBody)
        CkJsonObject::ckDispose(jResp)
        ProcedureReturn
    EndIf

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

    ; {
    ;   "id": "<uuid>",
    ;   "link": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "institution": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "collected_at": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "category": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "type": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "name": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "number": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "balance": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "currency": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "bank_product_id": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "internal_identification": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "public_identification_name": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "public_identification_value": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "last_accessed_at": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "credit_data": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "loan_data": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "funds_data": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   },
    ;   "gig_payment_data": {
    ;     "value": "<Error: Too many levels of nesting to fake this schema>"
    ;   }
    ; }

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

    id.s = CkJsonObject::ckStringOf(jResp,"id")
    Value.s = CkJsonObject::ckStringOf(jResp,"link.value")
    institutionValue.s = CkJsonObject::ckStringOf(jResp,"institution.value")
    collected_atValue.s = CkJsonObject::ckStringOf(jResp,"collected_at.value")
    categoryValue.s = CkJsonObject::ckStringOf(jResp,"category.value")
    typeValue.s = CkJsonObject::ckStringOf(jResp,"type.value")
    nameValue.s = CkJsonObject::ckStringOf(jResp,"name.value")
    numberValue.s = CkJsonObject::ckStringOf(jResp,"number.value")
    balanceValue.s = CkJsonObject::ckStringOf(jResp,"balance.value")
    currencyValue.s = CkJsonObject::ckStringOf(jResp,"currency.value")
    bank_product_idValue.s = CkJsonObject::ckStringOf(jResp,"bank_product_id.value")
    internal_identificationValue.s = CkJsonObject::ckStringOf(jResp,"internal_identification.value")
    public_identification_nameValue.s = CkJsonObject::ckStringOf(jResp,"public_identification_name.value")
    public_identification_valueValue.s = CkJsonObject::ckStringOf(jResp,"public_identification_value.value")
    last_accessed_atValue.s = CkJsonObject::ckStringOf(jResp,"last_accessed_at.value")
    credit_dataValue.s = CkJsonObject::ckStringOf(jResp,"credit_data.value")
    loan_dataValue.s = CkJsonObject::ckStringOf(jResp,"loan_data.value")
    funds_dataValue.s = CkJsonObject::ckStringOf(jResp,"funds_data.value")
    gig_payment_dataValue.s = CkJsonObject::ckStringOf(jResp,"gig_payment_data.value")


    CkHttp::ckDispose(http)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkJsonObject::ckDispose(jResp)


    ProcedureReturn
EndProcedure

Curl Command

curl -X GET
	-u '{{secretId}}:{{secretPassword}}'
https://domain.com/api/accounts/:id/

Postman Collection Item JSON

{
  "name": "Detail",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/accounts/:id/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "accounts",
        ":id",
        ""
      ],
      "variable": [
        {
          "key": "id",
          "value": "consequa",
          "description": "(Required) The `account.id` you want to get detailed information about."
        }
      ]
    },
    "description": "Get the details of a specific account."
  },
  "response": [
    {
      "name": "Ok",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/accounts/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "accounts",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n\t\"id\": \"<uuid>\",\n\t\"link\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"institution\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"collected_at\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"category\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"type\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"name\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"number\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"balance\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"currency\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"bank_product_id\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"internal_identification\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"public_identification_name\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"public_identification_value\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"last_accessed_at\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"credit_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"loan_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"funds_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t},\n\t\"gig_payment_data\": {\n\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t}\n}"
    },
    {
      "name": "Unauthorized",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/accounts/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "accounts",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Unauthorized",
      "code": 401,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "[\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t},\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t}\n]"
    },
    {
      "name": "Too Many Sessions",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: basic",
            "key": "Authorization",
            "value": "Basic <credentials>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/accounts/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "accounts",
            ":id"
          ],
          "variable": [
            {
              "key": "id"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "[\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t},\n\t{\n\t\t\"code\": \"<string>\",\n\t\t\"message\": \"<string>\",\n\t\t\"request_id\": \"<string>\"\n\t}\n]"
    }
  ]
}