Chilkat Online Tools

unicodeC / ORACLE Hospitality OPERA Cloud REST API Workflows / Post a Folio, required before checking out a guest

Back to Collection Items

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

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

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

    http = CkHttpW_Create();

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "criteria": {
    //     "reservationId": {
    //       "idContext": "OPERA",
    //       "id": 123,
    //       "type": "Reservation"
    //     },
    //     "profileId": {
    //       "idContext": "OPERA",
    //       "id": 123,
    //       "type": "Profile"
    //     },
    //     "fiscalFolioInstruction": "New",
    //     "allFolioWindow": false,
    //     "folioQueue": {
    //       "generateFiscalFolio": false
    //     },
    //     "cashierId": 4,
    //     "hotelId": "{{HotelId}}",
    //     "eventType": "CheckOut",
    //     "folioWindowNo": 1,
    //     "correction": false,
    //     "debitFolio": false
    //   }
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"criteria.reservationId.idContext",L"OPERA");
    CkJsonObjectW_UpdateInt(json,L"criteria.reservationId.id",123);
    CkJsonObjectW_UpdateString(json,L"criteria.reservationId.type",L"Reservation");
    CkJsonObjectW_UpdateString(json,L"criteria.profileId.idContext",L"OPERA");
    CkJsonObjectW_UpdateInt(json,L"criteria.profileId.id",123);
    CkJsonObjectW_UpdateString(json,L"criteria.profileId.type",L"Profile");
    CkJsonObjectW_UpdateString(json,L"criteria.fiscalFolioInstruction",L"New");
    CkJsonObjectW_UpdateBool(json,L"criteria.allFolioWindow",FALSE);
    CkJsonObjectW_UpdateBool(json,L"criteria.folioQueue.generateFiscalFolio",FALSE);
    CkJsonObjectW_UpdateInt(json,L"criteria.cashierId",4);
    CkJsonObjectW_UpdateString(json,L"criteria.hotelId",L"{{HotelId}}");
    CkJsonObjectW_UpdateString(json,L"criteria.eventType",L"CheckOut");
    CkJsonObjectW_UpdateInt(json,L"criteria.folioWindowNo",1);
    CkJsonObjectW_UpdateBool(json,L"criteria.correction",FALSE);
    CkJsonObjectW_UpdateBool(json,L"criteria.debitFolio",FALSE);

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

    resp = CkHttpW_PostJson3(http,L"https://domain.com/csh/v0/hotels/{{HotelId}}/reservations/{{ReservationId}}/folios",L"application/json",json);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        return;
    }

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


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);

    }

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "x-hotelid: {{HotelId}}"
	-H "x-app-key: {{AppKey}}"
	-d '{
    "criteria": {
        "reservationId": {
            "idContext": "OPERA",
            "id": {{ReservationId}},
            "type": "Reservation"
        },
        "profileId": {
            "idContext": "OPERA",
            "id": {{ProfileId}},
            "type": "Profile"
        },
        "fiscalFolioInstruction": "New",
        "allFolioWindow": false,
        "folioQueue": {
            "generateFiscalFolio": false
        },
        "cashierId": 4,
        "hotelId": "{{HotelId}}",
        "eventType": "CheckOut",
        "folioWindowNo": 1,
        "correction": false,
        "debitFolio": false
    }
}'
https://domain.com/csh/v0/hotels/{{HotelId}}/reservations/{{ReservationId}}/folios

Postman Collection Item JSON

{
  "name": "Post a Folio, required before checking out a guest",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{Token}}",
          "type": "string"
        }
      ]
    },
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "type": "text",
        "value": "application/json"
      },
      {
        "key": "x-hotelid",
        "type": "text",
        "value": "{{HotelId}}"
      },
      {
        "key": "x-app-key",
        "value": "{{AppKey}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n    \"criteria\": {\r\n        \"reservationId\": {\r\n            \"idContext\": \"OPERA\",\r\n            \"id\": {{ReservationId}},\r\n            \"type\": \"Reservation\"\r\n        },\r\n        \"profileId\": {\r\n            \"idContext\": \"OPERA\",\r\n            \"id\": {{ProfileId}},\r\n            \"type\": \"Profile\"\r\n        },\r\n        \"fiscalFolioInstruction\": \"New\",\r\n        \"allFolioWindow\": false,\r\n        \"folioQueue\": {\r\n            \"generateFiscalFolio\": false\r\n        },\r\n        \"cashierId\": 4,\r\n        \"hotelId\": \"{{HotelId}}\",\r\n        \"eventType\": \"CheckOut\",\r\n        \"folioWindowNo\": 1,\r\n        \"correction\": false,\r\n        \"debitFolio\": false\r\n    }\r\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{HostName}}/csh/v0/hotels/{{HotelId}}/reservations/{{ReservationId}}/folios",
      "host": [
        "{{HostName}}"
      ],
      "path": [
        "csh",
        "v0",
        "hotels",
        "{{HotelId}}",
        "reservations",
        "{{ReservationId}}",
        "folios"
      ],
      "query": [
        {
          "key": null,
          "value": "",
          "disabled": true
        }
      ]
    }
  },
  "response": [
  ]
}