Back to Collection Items
func chilkatTest() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = CkoHttp()!
var success: Bool
// 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
// }
// }
let json = CkoJsonObject()!
json.update("ratePlan.primaryDetails.description.defaultText", value: "Description of rate code ")
json.update("ratePlan.primaryDetails.startSellDate", value: "2021-07-03")
json.update("ratePlan.primaryDetails.endSellDate", value: "2021-08-31")
json.updateBool("ratePlan.primaryDetails.privilegedRate", value: false)
json.updateBool("ratePlan.primaryDetails.privilegedRateRestriction", value: false)
json.update("ratePlan.primaryDetails.lockStatus", value: "Unlocked")
json.update("ratePlan.classifications.rateCategory", value: "PHONE")
json.update("ratePlan.classifications.marketCode", value: "BUSINESS")
json.update("ratePlan.roomTypeList[0].code", value: "ECO")
json.update("ratePlan.roomTypeList[1].code", value: "SUP")
json.updateBool("ratePlan.mobileCheckinAllowed", value: false)
json.updateBool("ratePlan.mobileCheckoutAllowed", value: false)
json.update("ratePlan.hotelId", value: "{{HotelId}}")
json.update("ratePlan.ratePlanCode", value: "{{RatePlanCode}}")
json.updateBool("ratePlan.supressRate", value: false)
json.updateBool("ratePlan.printRate", value: true)
json.updateBool("ratePlan.discountAllowed", value: false)
json.updateBool("ratePlan.redemption", value: false)
json.updateBool("ratePlan.bARRate", value: false)
json.updateBool("ratePlan.daily", value: false)
json.updateBool("ratePlan.tiered", value: false)
json.updateBool("ratePlan.dayUse", value: false)
json.updateBool("ratePlan.dayType", value: false)
json.updateBool("ratePlan.complimentary", value: false)
json.updateBool("ratePlan.houseUse", value: false)
json.updateBool("ratePlan.negotiated", value: false)
json.updateBool("ratePlan.ownerRate", value: false)
json.updateBool("ratePlan.membershipEligible", value: true)
json.updateBool("ratePlan.advancedDailyBase", value: false)
json.updateBool("ratePlan.advancedDailyRate", value: false)
http.setRequestHeader("Content-Type", value: "application/json;charset=UTF-8")
http.setRequestHeader("x-hotelid", value: "{{HotelId}}")
// Adds the "Authorization: Bearer <access_token>" header.
http.authToken = "<access_token>"
http.setRequestHeader("Accept", value: "application/json;charset=UTF-8")
http.setRequestHeader("x-app-key", value: "{{AppKey}}")
let sbRequestBody = CkoStringBuilder()!
json.emitSb(sbRequestBody)
var resp: CkoHttpResponse? = http.pTextSb("PUT", url: "https://domain.com/rtp/v0/hotels/{{HotelId}}/ratePlans/{{RatePlanCode}}", textData: sbRequestBody, charset: "utf-8", contentType: "application/json;charset=UTF-8", md5: false, gzip: false)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
print("\(resp!.statusCode.intValue)")
print("\(resp!.bodyStr!)")
resp = nil
}
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": [
]
}