Chilkat Online Tools

Swift3 / Belvo API Docs / Detail

Back to Collection Items

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

    let http = CkoHttp()!
    var success: Bool

    http.basicAuth = true
    http.login = "{{secretId}}"
    http.password = "{{secretPassword}}"

    let sbResponseBody = CkoStringBuilder()!
    success = http.quickGetSb("https://domain.com/api/transactions/:id/", sbContent: sbResponseBody)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    let jResp = CkoJsonObject()!
    jResp.loadSb(sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = http.lastStatus.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(http.lastHeader!)")
        print("Failed.")
        return
    }

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

    // {
    //   "id": "<uuid>",
    //   "account": {
    //     "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>"
    //     }
    //   },
    //   "collected_at": "<date>",
    //   "value_date": "<string>",
    //   "accounting_date": "<date>",
    //   "amount": "<number>",
    //   "balance": "<number>",
    //   "currency": "<string>",
    //   "description": "<string>",
    //   "observations": "<string>",
    //   "category": "<string>",
    //   "reference": "<string>",
    //   "type": "eiusmod veniam ea sint",
    //   "status": "est nostrud",
    //   "gig_data": {
    //     "pickup_at": "<dateTime>",
    //     "dropoff_at": "<dateTime>",
    //     "request_at": "<dateTime>",
    //     "pickup_address": "<string>",
    //     "dropoff_address": "<string>",
    //     "pickup_latitude": "<number>",
    //     "pickup_longitude": "<number>",
    //     "dropoff_latitude": "<number>",
    //     "dropoff_longitude": "<number>",
    //     "distance": "<number>",
    //     "payment_method": "<string>",
    //     "vehicle_type": "<string>",
    //     "merchant_type": "<string>",
    //     "breakdown": [
    //       {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       },
    //       {
    //         "value": "<Error: Too many levels of nesting to fake this schema>"
    //       }
    //     ],
    //     "collected_at": "<dateTime>"
    //   },
    //   "credit_card_data": {
    //     "bill_name": "<string>"
    //   }
    // }

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

    var value: String?

    var id: String? = jResp.string(of: "id")
    var Id: String? = jResp.string(of: "account.id")
    var Value: String? = jResp.string(of: "account.link.value")
    var InstitutionValue: String? = jResp.string(of: "account.institution.value")
    var Collected_atValue: String? = jResp.string(of: "account.collected_at.value")
    var CategoryValue: String? = jResp.string(of: "account.category.value")
    var TypeValue: String? = jResp.string(of: "account.type.value")
    var NameValue: String? = jResp.string(of: "account.name.value")
    var NumberValue: String? = jResp.string(of: "account.number.value")
    var BalanceValue: String? = jResp.string(of: "account.balance.value")
    var CurrencyValue: String? = jResp.string(of: "account.currency.value")
    var Bank_product_idValue: String? = jResp.string(of: "account.bank_product_id.value")
    var Internal_identificationValue: String? = jResp.string(of: "account.internal_identification.value")
    var Public_identification_nameValue: String? = jResp.string(of: "account.public_identification_name.value")
    var Public_identification_valueValue: String? = jResp.string(of: "account.public_identification_value.value")
    var Last_accessed_atValue: String? = jResp.string(of: "account.last_accessed_at.value")
    var Credit_dataValue: String? = jResp.string(of: "account.credit_data.value")
    var Loan_dataValue: String? = jResp.string(of: "account.loan_data.value")
    var Funds_dataValue: String? = jResp.string(of: "account.funds_data.value")
    var Gig_payment_dataValue: String? = jResp.string(of: "account.gig_payment_data.value")
    var collected_at: String? = jResp.string(of: "collected_at")
    var value_date: String? = jResp.string(of: "value_date")
    var accounting_date: String? = jResp.string(of: "accounting_date")
    var amount: String? = jResp.string(of: "amount")
    var balance: String? = jResp.string(of: "balance")
    var v_currency: String? = jResp.string(of: "currency")
    var description: String? = jResp.string(of: "description")
    var observations: String? = jResp.string(of: "observations")
    var category: String? = jResp.string(of: "category")
    var reference: String? = jResp.string(of: "reference")
    var v_type: String? = jResp.string(of: "type")
    var status: String? = jResp.string(of: "status")
    var Pickup_at: String? = jResp.string(of: "gig_data.pickup_at")
    var Dropoff_at: String? = jResp.string(of: "gig_data.dropoff_at")
    var Request_at: String? = jResp.string(of: "gig_data.request_at")
    var Pickup_address: String? = jResp.string(of: "gig_data.pickup_address")
    var Dropoff_address: String? = jResp.string(of: "gig_data.dropoff_address")
    var Pickup_latitude: String? = jResp.string(of: "gig_data.pickup_latitude")
    var Pickup_longitude: String? = jResp.string(of: "gig_data.pickup_longitude")
    var Dropoff_latitude: String? = jResp.string(of: "gig_data.dropoff_latitude")
    var Dropoff_longitude: String? = jResp.string(of: "gig_data.dropoff_longitude")
    var Distance: String? = jResp.string(of: "gig_data.distance")
    var Payment_method: String? = jResp.string(of: "gig_data.payment_method")
    var Vehicle_type: String? = jResp.string(of: "gig_data.vehicle_type")
    var Merchant_type: String? = jResp.string(of: "gig_data.merchant_type")
    var Collected_at: String? = jResp.string(of: "gig_data.collected_at")
    var Bill_name: String? = jResp.string(of: "credit_card_data.bill_name")
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "gig_data.breakdown").intValue
    while i < count_i {
        jResp.i = i
        value = jResp.string(of: "gig_data.breakdown[i].value")
        i = i + 1
    }


}

Curl Command

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

Postman Collection Item JSON

{
  "name": "Detail",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/transactions/:id/",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "transactions",
        ":id",
        ""
      ],
      "variable": [
        {
          "key": "id",
          "value": "consequa",
          "description": "(Required) The `transaction.id` you want to get detailed information about."
        }
      ]
    },
    "description": "Get the details of a specific transaction."
  },
  "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/transactions/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "transactions",
            ":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\"account\": {\n\t\t\"id\": \"<uuid>\",\n\t\t\"link\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"institution\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"collected_at\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"category\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"type\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"name\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"number\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"balance\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"currency\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"bank_product_id\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"internal_identification\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"public_identification_name\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"public_identification_value\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"last_accessed_at\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"credit_data\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"loan_data\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"funds_data\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t},\n\t\t\"gig_payment_data\": {\n\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t}\n\t},\n\t\"collected_at\": \"<date>\",\n\t\"value_date\": \"<string>\",\n\t\"accounting_date\": \"<date>\",\n\t\"amount\": \"<number>\",\n\t\"balance\": \"<number>\",\n\t\"currency\": \"<string>\",\n\t\"description\": \"<string>\",\n\t\"observations\": \"<string>\",\n\t\"category\": \"<string>\",\n\t\"reference\": \"<string>\",\n\t\"type\": \"eiusmod veniam ea sint\",\n\t\"status\": \"est nostrud\",\n\t\"gig_data\": {\n\t\t\"pickup_at\": \"<dateTime>\",\n\t\t\"dropoff_at\": \"<dateTime>\",\n\t\t\"request_at\": \"<dateTime>\",\n\t\t\"pickup_address\": \"<string>\",\n\t\t\"dropoff_address\": \"<string>\",\n\t\t\"pickup_latitude\": \"<number>\",\n\t\t\"pickup_longitude\": \"<number>\",\n\t\t\"dropoff_latitude\": \"<number>\",\n\t\t\"dropoff_longitude\": \"<number>\",\n\t\t\"distance\": \"<number>\",\n\t\t\"payment_method\": \"<string>\",\n\t\t\"vehicle_type\": \"<string>\",\n\t\t\"merchant_type\": \"<string>\",\n\t\t\"breakdown\": [\n\t\t\t{\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t},\n\t\t\t{\n\t\t\t\t\"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n\t\t\t}\n\t\t],\n\t\t\"collected_at\": \"<dateTime>\"\n\t},\n\t\"credit_card_data\": {\n\t\t\"bill_name\": \"<string>\"\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/transactions/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "transactions",
            ":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/transactions/:id",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "transactions",
            ":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]"
    }
  ]
}