Sample code for 30+ languages & platforms
PowerBuilder

Yapily - Get Application Self

See more Yapily Examples

Get the information about the institutions configured in your application

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Http
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_StrVal
string ls_Id
string ls_FullName
string ls_EnvironmentType
string ls_CredentialsType
integer j
integer li_Count_j
string ls_DisplayName
string ls_CountryCode2
string ls_Source
string ls_V_type
string ls_Uuid
string ls_Name
integer li_Active
string ls_Created
string ls_Updated
integer i
integer li_Count_i

li_Success = 0

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

loo_Http.Login = "<username>"
loo_Http.Password = "<password>"

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://api.yapily.com/me",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

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

ls_Uuid = loo_JResp.StringOf("uuid")
ls_Name = loo_JResp.StringOf("name")
li_Active = loo_JResp.BoolOf("active")
ls_Created = loo_JResp.StringOf("created")
ls_Updated = loo_JResp.StringOf("updated")
i = 0
li_Count_i = loo_JResp.SizeOfArray("authCallbacks")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("authCallbacks[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("institutions")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Id = loo_JResp.StringOf("institutions[i].id")
    ls_Name = loo_JResp.StringOf("institutions[i].name")
    ls_FullName = loo_JResp.StringOf("institutions[i].fullName")
    ls_EnvironmentType = loo_JResp.StringOf("institutions[i].environmentType")
    ls_CredentialsType = loo_JResp.StringOf("institutions[i].credentialsType")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("institutions[i].countries")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_DisplayName = loo_JResp.StringOf("institutions[i].countries[j].displayName")
        ls_CountryCode2 = loo_JResp.StringOf("institutions[i].countries[j].countryCode2")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("institutions[i].media")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Source = loo_JResp.StringOf("institutions[i].media[j].source")
        ls_V_type = loo_JResp.StringOf("institutions[i].media[j].type")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("institutions[i].features")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("institutions[i].features[j]")
        j = j + 1
    loop
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("media")
do while i < li_Count_i
    loo_JResp.I = i
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp