Chilkat Online Tools

unicodeC / ORACLE Hospitality OPERA Cloud REST API Workflows / Get available packages

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW queryParams;
    HCkHttpResponseW resp;

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

    http = CkHttpW_Create();

    queryParams = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(queryParams,L"fetchInstructions",L"Header");
    CkJsonObjectW_UpdateString(queryParams,L"fetchInstructions",L"Items");
    CkJsonObjectW_UpdateString(queryParams,L"startDate",L"2021-04-07");
    CkJsonObjectW_UpdateString(queryParams,L"endDate",L"2021-04-08");
    CkJsonObjectW_UpdateInt(queryParams,L"children",0);
    CkJsonObjectW_UpdateInt(queryParams,L"adults",1);
    CkJsonObjectW_UpdateString(queryParams,L"hotelId",L"{{HotelId}}");
    CkJsonObjectW_UpdateString(queryParams,L"packageCode",L"CHAMP");

    CkHttpW_SetRequestHeader(http,L"x-app-key",L"{{AppKey}}");
    CkHttpW_SetRequestHeader(http,L"x-hotelid",L"{{HotelId}}");
    // Adds the "Authorization: Bearer <access_token>" header.
    CkHttpW_putAuthToken(http,L"<access_token>");

    resp = CkHttpW_QuickRequestParams(http,L"GET",L"https://domain.com/rtp/v0/packages",queryParams);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(queryParams);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(queryParams);

    }

Curl Command

curl -G -d "fetchInstructions=Header"
	-d "fetchInstructions=Items"
	-d "startDate=2021-04-07"
	-d "endDate=2021-04-08"
	-d "children=0"
	-d "adults=1"
	-d "hotelId=%7B%7BHotelId%7D%7D"
	-d "packageCode=CHAMP"
	-H "Authorization: Bearer <access_token>"
	-H "x-hotelid: {{HotelId}}"
	-H "x-app-key: {{AppKey}}"
https://domain.com/rtp/v0/packages

Postman Collection Item JSON

{
  "name": "Get available packages",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{Token}}",
          "type": "string"
        }
      ]
    },
    "method": "GET",
    "header": [
      {
        "key": "x-hotelid",
        "type": "text",
        "value": "{{HotelId}}"
      },
      {
        "key": "x-app-key",
        "value": "{{AppKey}}",
        "type": "text"
      }
    ],
    "url": {
      "raw": "{{HostName}}/rtp/v0/packages?fetchInstructions=Header&fetchInstructions=Items&startDate=2021-04-07&endDate=2021-04-08&children=0&adults=1&hotelId={{HotelId}}&packageCode=CHAMP",
      "host": [
        "{{HostName}}"
      ],
      "path": [
        "rtp",
        "v0",
        "packages"
      ],
      "query": [
        {
          "key": "includeGroup",
          "value": "true",
          "disabled": true
        },
        {
          "key": "sellSeparate",
          "value": "true",
          "disabled": true
        },
        {
          "key": "fetchInstructions",
          "value": "Header"
        },
        {
          "key": "fetchInstructions",
          "value": "CalculatedPrice",
          "disabled": true
        },
        {
          "key": "fetchInstructions",
          "value": "Items"
        },
        {
          "key": "startDate",
          "value": "2021-04-07"
        },
        {
          "key": "endDate",
          "value": "2021-04-08"
        },
        {
          "key": "children",
          "value": "0"
        },
        {
          "key": "adults",
          "value": "1"
        },
        {
          "key": "hotelId",
          "value": "{{HotelId}}"
        },
        {
          "key": "ticketPostingRhythm",
          "value": "false",
          "disabled": true
        },
        {
          "key": "packageCode",
          "value": "CHAMP"
        },
        {
          "key": "descriptionWildCard",
          "value": "",
          "disabled": true
        }
      ]
    }
  },
  "response": [
  ]
}