Sample code for 30+ languages & platforms
Objective-C

Yapily - Get Application Self

See more Yapily Examples

Get the information about the institutions configured in your application

Chilkat Objective-C Downloads

Objective-C
#import <CkoHttp.h>
#import <CkoStringBuilder.h>
#import <CkoJsonObject.h>
#import <NSString.h>

BOOL success = NO;

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

CkoHttp *http = [[CkoHttp alloc] init];

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

http.Login = @"<username>";
http.Password = @"<password>";

CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [http QuickGetSb: @"https://api.yapily.com/me" sbContent: sbResponseBody];
if (success == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

CkoJsonObject *jResp = [[CkoJsonObject alloc] init];
[jResp LoadSb: sbResponseBody];
jResp.EmitCompact = NO;

NSLog(@"%@",@"Response Body:");
NSLog(@"%@",[jResp Emit]);

int respStatusCode = [http.LastStatus intValue];
NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
if (respStatusCode >= 400) {
    NSLog(@"%@",@"Response Header:");
    NSLog(@"%@",http.LastHeader);
    NSLog(@"%@",@"Failed.");
    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

NSString *strVal = 0;
NSString *id = 0;
NSString *fullName = 0;
NSString *environmentType = 0;
NSString *credentialsType = 0;
int j;
int count_j;
NSString *displayName = 0;
NSString *countryCode2 = 0;
NSString *source = 0;
NSString *v_type = 0;

NSString *uuid = [jResp StringOf: @"uuid"];
NSString *name = [jResp StringOf: @"name"];
BOOL active = [jResp BoolOf: @"active"];
NSString *created = [jResp StringOf: @"created"];
NSString *updated = [jResp StringOf: @"updated"];
int i = 0;
int count_i = [[jResp SizeOfArray: @"authCallbacks"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    strVal = [jResp StringOf: @"authCallbacks[i]"];
    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"institutions"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    id = [jResp StringOf: @"institutions[i].id"];
    name = [jResp StringOf: @"institutions[i].name"];
    fullName = [jResp StringOf: @"institutions[i].fullName"];
    environmentType = [jResp StringOf: @"institutions[i].environmentType"];
    credentialsType = [jResp StringOf: @"institutions[i].credentialsType"];
    j = 0;
    count_j = [[jResp SizeOfArray: @"institutions[i].countries"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        displayName = [jResp StringOf: @"institutions[i].countries[j].displayName"];
        countryCode2 = [jResp StringOf: @"institutions[i].countries[j].countryCode2"];
        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"institutions[i].media"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        source = [jResp StringOf: @"institutions[i].media[j].source"];
        v_type = [jResp StringOf: @"institutions[i].media[j].type"];
        j = j + 1;
    }

    j = 0;
    count_j = [[jResp SizeOfArray: @"institutions[i].features"] intValue];
    while (j < count_j) {
        jResp.J = [NSNumber numberWithInt: j];
        strVal = [jResp StringOf: @"institutions[i].features[j]"];
        j = j + 1;
    }

    i = i + 1;
}

i = 0;
count_i = [[jResp SizeOfArray: @"media"] intValue];
while (i < count_i) {
    jResp.I = [NSNumber numberWithInt: i];
    i = i + 1;
}