Chilkat Online Tools

PureBasic / ORACLE Hospitality OPERA Cloud REST API Workflows / Search For Available Tickets

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"

Procedure ChilkatExample()

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

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    queryParams.i = CkJsonObject::ckCreate()
    If queryParams.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(queryParams,"includeGroup","true")
    CkJsonObject::ckUpdateString(queryParams,"sellSeparate","true")
    CkJsonObject::ckUpdateString(queryParams,"startDate","2022-03-16")
    CkJsonObject::ckUpdateString(queryParams,"endDate","2022-03-21")
    CkJsonObject::ckUpdateInt(queryParams,"adults",1)
    CkJsonObject::ckUpdateInt(queryParams,"children",0)
    CkJsonObject::ckUpdateString(queryParams,"fetchInstructions","Header")
    CkJsonObject::ckUpdateString(queryParams,"fetchInstructions","CalculatedPrice")
    CkJsonObject::ckUpdateString(queryParams,"fetchInstructions","Items")
    CkJsonObject::ckUpdateString(queryParams,"ticketPostingRhythm","true")
    CkJsonObject::ckUpdateString(queryParams,"hotelId","{{HotelId}}")

    CkHttp::ckSetRequestHeader(http,"x-app-key","{{AppKey}}")
    CkHttp::ckSetRequestHeader(http,"x-hotelid","{{HotelId}}")
    ; Adds the "Authorization: Bearer <access_token>" header.
    CkHttp::setCkAuthToken(http, "<access_token>")

    resp.i = CkHttp::ckQuickRequestParams(http,"GET","https://domain.com/rtp/v0/packages",queryParams)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkJsonObject::ckDispose(queryParams)
        ProcedureReturn
    EndIf

    Debug Str(CkHttpResponse::ckStatusCode(resp))
    Debug CkHttpResponse::ckBodyStr(resp)
    CkHttpResponse::ckDispose(resp)



    CkHttp::ckDispose(http)
    CkJsonObject::ckDispose(queryParams)


    ProcedureReturn
EndProcedure

Curl Command

curl -G -d "includeGroup=true"
	-d "sellSeparate=true"
	-d "startDate=2022-03-16"
	-d "endDate=2022-03-21"
	-d "adults=1"
	-d "children=0"
	-d "fetchInstructions=Header"
	-d "fetchInstructions=CalculatedPrice"
	-d "fetchInstructions=Items"
	-d "ticketPostingRhythm=true"
	-d "hotelId=%7B%7BHotelId%7D%7D"
	-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": "Search For Available Tickets",
  "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",
        "type": "text",
        "value": "{{AppKey}}"
      }
    ],
    "url": {
      "raw": "{{HostName}}/rtp/v0/packages?includeGroup=true&sellSeparate=true&startDate=2022-03-16&endDate=2022-03-21&adults=1&children=0&fetchInstructions=Header&fetchInstructions=CalculatedPrice&fetchInstructions=Items&ticketPostingRhythm=true&hotelId={{HotelId}}",
      "host": [
        "{{HostName}}"
      ],
      "path": [
        "rtp",
        "v0",
        "packages"
      ],
      "query": [
        {
          "key": "includeGroup",
          "value": "true"
        },
        {
          "key": "sellSeparate",
          "value": "true"
        },
        {
          "key": "startDate",
          "value": "2022-03-16"
        },
        {
          "key": "endDate",
          "value": "2022-03-21"
        },
        {
          "key": "adults",
          "value": "1"
        },
        {
          "key": "children",
          "value": "0"
        },
        {
          "key": "fetchInstructions",
          "value": "Header"
        },
        {
          "key": "fetchInstructions",
          "value": "CalculatedPrice"
        },
        {
          "key": "fetchInstructions",
          "value": "Items"
        },
        {
          "key": "ticketPostingRhythm",
          "value": "true"
        },
        {
          "key": "hotelId",
          "value": "{{HotelId}}"
        }
      ]
    },
    "description": "Use this operation to search for available packages at a property. You can search by date range, to see what packages are available to add to a reservation for example."
  },
  "response": [
  ]
}