Sample code for 30+ languages & platforms
Unicode C

Yapily - Get Application Self

See more Yapily Examples

Get the information about the institutions configured in your application

Chilkat Unicode C Downloads

Unicode C
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttpW http;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jResp;
    int respStatusCode;
    const wchar_t *strVal;
    const wchar_t *id;
    const wchar_t *fullName;
    const wchar_t *environmentType;
    const wchar_t *credentialsType;
    int j;
    int count_j;
    const wchar_t *displayName;
    const wchar_t *countryCode2;
    const wchar_t *source;
    const wchar_t *v_type;
    const wchar_t *uuid;
    const wchar_t *name;
    BOOL active;
    const wchar_t *created;
    const wchar_t *updated;
    int i;
    int count_i;

    success = FALSE;

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

    http = CkHttpW_Create();

    // Implements the following CURL command:

    // curl -i -X GET \
    //   -u <username>:<password> \
    //   https://api.yapily.com/me

    // Use the following online tool to generate HTTP code from a CURL command
    // Convert a cURL Command to HTTP Source Code

    CkHttpW_putLogin(http,L"<username>");
    CkHttpW_putPassword(http,L"<password>");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkHttpW_QuickGetSb(http,L"https://api.yapily.com/me",sbResponseBody);
    if (success == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jResp,sbResponseBody);
    CkJsonObjectW_putEmitCompact(jResp,FALSE);

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

    respStatusCode = CkHttpW_getLastStatus(http);
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",CkHttpW_lastHeader(http));
        wprintf(L"Failed.\n");
        CkHttpW_Dispose(http);
        CkStringBuilderW_Dispose(sbResponseBody);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

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

    // {
    //   "uuid": "64949de6-6510-4d70-9500-d4aa094c506c",
    //   "name": "APPLICATION NAME",
    //   "active": true,
    //   "authCallbacks": [
    //     "https://display-parameters.com/"
    //   ],
    //   "institutions": [
    //     {
    //       "id": "modelo-sandbox",
    //       "name": "Modelo Sandbox",
    //       "fullName": "Modelo Sandbox",
    //       "countries": [
    //         {
    //           "displayName": "United Kingdom",
    //           "countryCode2": "GB"
    //         }
    //       ],
    //       "environmentType": "SANDBOX",
    //       "credentialsType": "OPEN_BANKING_UK_AUTO",
    //       "media": [
    //         {
    //           "source": "https://images.yapily.com/image/ce2bfdbf-1ae2-4919-ab7b-e8b3d5e93b36?size=0",
    //           "type": "icon"
    //         },
    //         {
    //           "source": "https://images.yapily.com/image/ca502f24-d6df-4785-b4b8-1034b100af77?size=0",
    //           "type": "logo"
    //         }
    //       ],
    //       "features": [
    //         "INITIATE_SINGLE_PAYMENT_SORTCODE",
    //         "CREATE_DOMESTIC_PERIODIC_PAYMENT",
    //         "ACCOUNT_REQUEST_DETAILS",
    //         "ACCOUNT_STATEMENT_FILE",
    //         "CREATE_SINGLE_PAYMENT_SORTCODE",
    //         "ACCOUNTS",
    //         "CREATE_DOMESTIC_SCHEDULED_PAYMENT",
    //         "ACCOUNT_PERIODIC_PAYMENTS",
    //         "CREATE_DOMESTIC_SINGLE_PAYMENT",
    //         "INITIATE_DOMESTIC_PERIODIC_PAYMENT",
    //         "EXISTING_PAYMENTS_DETAILS",
    //         "INITIATE_BULK_PAYMENT",
    //         "EXISTING_PAYMENT_INITIATION_DETAILS",
    //         "ACCOUNT_DIRECT_DEBITS",
    //         "ACCOUNT_TRANSACTIONS",
    //         "INITIATE_DOMESTIC_SINGLE_PAYMENT",
    //         "PERIODIC_PAYMENT_FREQUENCY_EXTENDED",
    //         "CREATE_INTERNATIONAL_SINGLE_PAYMENT",
    //         "ACCOUNT_SCHEDULED_PAYMENTS",
    //         "ACCOUNT",
    //         "ACCOUNT_STATEMENTS",
    //         "ACCOUNT_TRANSACTIONS_WITH_MERCHANT",
    //         "CREATE_BULK_PAYMENT",
    //         "ACCOUNT_BALANCES",
    //         "INITIATE_INTERNATIONAL_SINGLE_PAYMENT",
    //         "INITIATE_DOMESTIC_SCHEDULED_PAYMENT",
    //         "ACCOUNT_BENEFICIARIES",
    //         "IDENTITY",
    //         "ACCOUNT_STATEMENT",
    //         "INITIATE_ACCOUNT_REQUEST"
    //       ]
    //     }
    //   ],
    //   "media": [
    //   ],
    //   "created": "2020-11-09T10:05:29.897+0000",
    //   "updated": "2021-04-14T12:51:07.419+0000"
    // }

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

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    uuid = CkJsonObjectW_stringOf(jResp,L"uuid");
    name = CkJsonObjectW_stringOf(jResp,L"name");
    active = CkJsonObjectW_BoolOf(jResp,L"active");
    created = CkJsonObjectW_stringOf(jResp,L"created");
    updated = CkJsonObjectW_stringOf(jResp,L"updated");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"authCallbacks");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        strVal = CkJsonObjectW_stringOf(jResp,L"authCallbacks[i]");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"institutions");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        id = CkJsonObjectW_stringOf(jResp,L"institutions[i].id");
        name = CkJsonObjectW_stringOf(jResp,L"institutions[i].name");
        fullName = CkJsonObjectW_stringOf(jResp,L"institutions[i].fullName");
        environmentType = CkJsonObjectW_stringOf(jResp,L"institutions[i].environmentType");
        credentialsType = CkJsonObjectW_stringOf(jResp,L"institutions[i].credentialsType");
        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"institutions[i].countries");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            displayName = CkJsonObjectW_stringOf(jResp,L"institutions[i].countries[j].displayName");
            countryCode2 = CkJsonObjectW_stringOf(jResp,L"institutions[i].countries[j].countryCode2");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"institutions[i].media");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            source = CkJsonObjectW_stringOf(jResp,L"institutions[i].media[j].source");
            v_type = CkJsonObjectW_stringOf(jResp,L"institutions[i].media[j].type");
            j = j + 1;
        }

        j = 0;
        count_j = CkJsonObjectW_SizeOfArray(jResp,L"institutions[i].features");
        while (j < count_j) {
            CkJsonObjectW_putJ(jResp,j);
            strVal = CkJsonObjectW_stringOf(jResp,L"institutions[i].features[j]");
            j = j + 1;
        }

        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"media");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        i = i + 1;
    }



    CkHttpW_Dispose(http);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jResp);

    }