Chilkat Online Tools

Foxpro / ORACLE Hospitality OPERA Cloud REST API Workflows / Update the Block's Status

Back to Collection Items

LOCAL loHttp
LOCAL lnSuccess
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loResp

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

loHttp = CreateObject('Chilkat_9_5_0.Http')

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

* The following JSON is sent in the request body.

* {
*   "verificationOnly": false,
*   "changeBlockStatus": {
*     "hotelId": "{{HotelId}}",
*     "blockId": {
*       "type": "Block",
*       "idContext": "OPERA",
*       "id": "{{BlockId}}"
*     },
*     "currentBlockStatus": "TEN",
*     "newBlockStatus": "DEF",
*     "reservationType": "GRPGTD",
*     "overbookAll": true,
*     "cancelAllPMReservations": false,
*     "applyChangesToCateringSatus": false,
*     "overrideEventsProcessingWarnings": true
*   }
* }

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateBool("verificationOnly",0)
loJson.UpdateString("changeBlockStatus.hotelId","{{HotelId}}")
loJson.UpdateString("changeBlockStatus.blockId.type","Block")
loJson.UpdateString("changeBlockStatus.blockId.idContext","OPERA")
loJson.UpdateString("changeBlockStatus.blockId.id","{{BlockId}}")
loJson.UpdateString("changeBlockStatus.currentBlockStatus","TEN")
loJson.UpdateString("changeBlockStatus.newBlockStatus","DEF")
loJson.UpdateString("changeBlockStatus.reservationType","GRPGTD")
loJson.UpdateBool("changeBlockStatus.overbookAll",1)
loJson.UpdateBool("changeBlockStatus.cancelAllPMReservations",0)
loJson.UpdateBool("changeBlockStatus.applyChangesToCateringSatus",0)
loJson.UpdateBool("changeBlockStatus.overrideEventsProcessingWarnings",1)

loHttp.SetRequestHeader("x-app-key","{{AppKey}}")
loHttp.SetRequestHeader("x-hotelid","{{HotelId}}")
* Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"

loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)

loResp = loHttp.PTextSb("PUT","https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/status",loSbRequestBody,"utf-8","application/json",0,0)
IF (loHttp.LastMethodSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loJson
    RELEASE loSbRequestBody
    CANCEL
ENDIF

? STR(loResp.StatusCode)
? loResp.BodyStr
RELEASE loResp

RELEASE loHttp
RELEASE loJson
RELEASE loSbRequestBody

Curl Command

curl -X PUT
	-H "Authorization: Bearer <access_token>"
	-H "x-hotelid: {{HotelId}}"
	-H "x-app-key: {{AppKey}}"
	-d '{
    "verificationOnly": false,
    "changeBlockStatus": {
        "hotelId": "{{HotelId}}",
        "blockId": {
            "type": "Block",
            "idContext": "OPERA",
            "id": "{{BlockId}}"
        },
        "currentBlockStatus": "TEN",
        "newBlockStatus": "DEF",
        "reservationType": "GRPGTD",
        "overbookAll": true,
        "cancelAllPMReservations": false,
        "applyChangesToCateringSatus": false,
        "overrideEventsProcessingWarnings": true
    }
}'
https://domain.com/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/status

Postman Collection Item JSON

{
  "name": "Update the Block's Status",
  "request": {
    "auth": {
      "type": "bearer",
      "bearer": [
        {
          "key": "token",
          "value": "{{Token}}",
          "type": "string"
        }
      ]
    },
    "method": "PUT",
    "header": [
      {
        "key": "x-hotelid",
        "value": "{{HotelId}}"
      },
      {
        "key": "x-app-key",
        "value": "{{AppKey}}"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n    \"verificationOnly\": false,\r\n    \"changeBlockStatus\": {\r\n        \"hotelId\": \"{{HotelId}}\",\r\n        \"blockId\": {\r\n            \"type\": \"Block\",\r\n            \"idContext\": \"OPERA\",\r\n            \"id\": \"{{BlockId}}\"\r\n        },\r\n        \"currentBlockStatus\": \"TEN\",\r\n        \"newBlockStatus\": \"DEF\",\r\n        \"reservationType\": \"GRPGTD\",\r\n        \"overbookAll\": true,\r\n        \"cancelAllPMReservations\": false,\r\n        \"applyChangesToCateringSatus\": false,\r\n        \"overrideEventsProcessingWarnings\": true\r\n    }\r\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{HostName}}/blk/v0/hotels/{{HotelId}}/blocks/{{BlockId}}/status",
      "host": [
        "{{HostName}}"
      ],
      "path": [
        "blk",
        "v0",
        "hotels",
        "{{HotelId}}",
        "blocks",
        "{{BlockId}}",
        "status"
      ]
    },
    "description": "\"overbookAll\": true/ false.  Set this to false, to ensure relevant warnings are returned about changing the status.   Set to true, to override all warnings."
  },
  "response": [
  ]
}