Back to Collection Items
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "ratePlan": {
// "primaryDetails": {
// "description": {
// "defaultText": "Description of rate code "
// },
// "startSellDate": "2021-07-03",
// "endSellDate": "2021-08-31",
// "privilegedRate": false,
// "privilegedRateRestriction": false,
// "lockStatus": "Unlocked"
// },
// "classifications": {
// "rateCategory": "PHONE",
// "marketCode": "BUSINESS"
// },
// "roomTypeList": [
// {
// "code": "ECO"
// },
// {
// "code": "SUP"
// }
// ],
// "mobileCheckinAllowed": false,
// "mobileCheckoutAllowed": false,
// "hotelId": "{{HotelId}}",
// "ratePlanCode": "{{RatePlanCode}}",
// "supressRate": false,
// "printRate": true,
// "discountAllowed": false,
// "redemption": false,
// "bARRate": false,
// "daily": false,
// "tiered": false,
// "dayUse": false,
// "dayType": false,
// "complimentary": false,
// "houseUse": false,
// "negotiated": false,
// "ownerRate": false,
// "membershipEligible": true,
// "advancedDailyBase": false,
// "advancedDailyRate": false
// }
// }
loJson = createobject("CkJsonObject")
loJson.UpdateString("ratePlan.primaryDetails.description.defaultText","Description of rate code ")
loJson.UpdateString("ratePlan.primaryDetails.startSellDate","2021-07-03")
loJson.UpdateString("ratePlan.primaryDetails.endSellDate","2021-08-31")
loJson.UpdateBool("ratePlan.primaryDetails.privilegedRate",.F.)
loJson.UpdateBool("ratePlan.primaryDetails.privilegedRateRestriction",.F.)
loJson.UpdateString("ratePlan.primaryDetails.lockStatus","Unlocked")
loJson.UpdateString("ratePlan.classifications.rateCategory","PHONE")
loJson.UpdateString("ratePlan.classifications.marketCode","BUSINESS")
loJson.UpdateString("ratePlan.roomTypeList[0].code","ECO")
loJson.UpdateString("ratePlan.roomTypeList[1].code","SUP")
loJson.UpdateBool("ratePlan.mobileCheckinAllowed",.F.)
loJson.UpdateBool("ratePlan.mobileCheckoutAllowed",.F.)
loJson.UpdateString("ratePlan.hotelId","{{HotelId}}")
loJson.UpdateString("ratePlan.ratePlanCode","{{RatePlanCode}}")
loJson.UpdateBool("ratePlan.supressRate",.F.)
loJson.UpdateBool("ratePlan.printRate",.T.)
loJson.UpdateBool("ratePlan.discountAllowed",.F.)
loJson.UpdateBool("ratePlan.redemption",.F.)
loJson.UpdateBool("ratePlan.bARRate",.F.)
loJson.UpdateBool("ratePlan.daily",.F.)
loJson.UpdateBool("ratePlan.tiered",.F.)
loJson.UpdateBool("ratePlan.dayUse",.F.)
loJson.UpdateBool("ratePlan.dayType",.F.)
loJson.UpdateBool("ratePlan.complimentary",.F.)
loJson.UpdateBool("ratePlan.houseUse",.F.)
loJson.UpdateBool("ratePlan.negotiated",.F.)
loJson.UpdateBool("ratePlan.ownerRate",.F.)
loJson.UpdateBool("ratePlan.membershipEligible",.T.)
loJson.UpdateBool("ratePlan.advancedDailyBase",.F.)
loJson.UpdateBool("ratePlan.advancedDailyRate",.F.)
loHttp.SetRequestHeader("Content-Type","application/json;charset=UTF-8")
loHttp.SetRequestHeader("x-hotelid","{{HotelId}}")
// Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"
loHttp.SetRequestHeader("Accept","application/json;charset=UTF-8")
loHttp.SetRequestHeader("x-app-key","{{AppKey}}")
loSbRequestBody = createobject("CkStringBuilder")
loJson.EmitSb(loSbRequestBody)
loResp = loHttp.PTextSb("PUT","https://domain.com/rtp/v0/hotels/{{HotelId}}/ratePlans/{{RatePlanCode}}",loSbRequestBody,"utf-8","application/json;charset=UTF-8",.F.,.F.)
if (loHttp.LastMethodSuccess = .F.) then
? loHttp.LastErrorText
release loHttp
release loJson
release loSbRequestBody
return
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 "Content-Type: application/json;charset=UTF-8"
-H "Accept: application/json;charset=UTF-8"
-H "x-hotelid: {{HotelId}}"
-H "x-app-key: {{AppKey}}"
-d '{
"ratePlan": {
"primaryDetails": {
"description": {
"defaultText": "Description of rate code "
},
"startSellDate": "2021-07-03",
"endSellDate": "2021-08-31",
"privilegedRate": false,
"privilegedRateRestriction": false,
"lockStatus": "Unlocked"
},
"classifications": {
"rateCategory": "PHONE",
"marketCode": "BUSINESS"
},
"roomTypeList": [
{
"code": "ECO"
},
{
"code": "SUP"
}
],
"mobileCheckinAllowed": false,
"mobileCheckoutAllowed": false,
"hotelId": "{{HotelId}}",
"ratePlanCode": "{{RatePlanCode}}",
"supressRate": false,
"printRate": true,
"discountAllowed": false,
"redemption": false,
"bARRate": false,
"daily": false,
"tiered": false,
"dayUse": false,
"dayType": false,
"complimentary": false,
"houseUse": false,
"negotiated": false,
"ownerRate": false,
"membershipEligible": true,
"advancedDailyBase": false,
"advancedDailyRate": false
}
}'
https://domain.com/rtp/v0/hotels/{{HotelId}}/ratePlans/{{RatePlanCode}}
Postman Collection Item JSON
{
"name": "Update an existing Rate Plan",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "PUT",
"header": [
{
"key": "Content-Type",
"type": "text",
"value": "application/json;charset=UTF-8"
},
{
"key": "Accept",
"type": "text",
"value": "application/json;charset=UTF-8"
},
{
"key": "x-hotelid",
"type": "text",
"value": "{{HotelId}}"
},
{
"key": "x-app-key",
"type": "text",
"value": "{{AppKey}}"
}
],
"body": {
"mode": "raw",
"raw": "{\r\n \"ratePlan\": {\r\n \"primaryDetails\": {\r\n \"description\": {\r\n \"defaultText\": \"Description of rate code \"\r\n },\r\n \"startSellDate\": \"2021-07-03\",\r\n \"endSellDate\": \"2021-08-31\",\r\n \"privilegedRate\": false,\r\n \"privilegedRateRestriction\": false,\r\n \"lockStatus\": \"Unlocked\"\r\n },\r\n \"classifications\": {\r\n \"rateCategory\": \"PHONE\",\r\n \"marketCode\": \"BUSINESS\"\r\n },\r\n \"roomTypeList\": [\r\n {\r\n \"code\": \"ECO\"\r\n },\r\n {\r\n \"code\": \"SUP\"\r\n }\r\n ],\r\n \"mobileCheckinAllowed\": false,\r\n \"mobileCheckoutAllowed\": false,\r\n \"hotelId\": \"{{HotelId}}\",\r\n \"ratePlanCode\": \"{{RatePlanCode}}\",\r\n \"supressRate\": false,\r\n \"printRate\": true,\r\n \"discountAllowed\": false,\r\n \"redemption\": false,\r\n \"bARRate\": false,\r\n \"daily\": false,\r\n \"tiered\": false,\r\n \"dayUse\": false,\r\n \"dayType\": false,\r\n \"complimentary\": false,\r\n \"houseUse\": false,\r\n \"negotiated\": false,\r\n \"ownerRate\": false,\r\n \"membershipEligible\": true,\r\n \"advancedDailyBase\": false,\r\n \"advancedDailyRate\": false\r\n }\r\n}"
},
"url": {
"raw": "{{HostName}}/rtp/v0/hotels/{{HotelId}}/ratePlans/{{RatePlanCode}}",
"host": [
"{{HostName}}"
],
"path": [
"rtp",
"v0",
"hotels",
"{{HotelId}}",
"ratePlans",
"{{RatePlanCode}}"
]
}
},
"response": [
]
}