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": "Rate Code Description Goes Here"
// },
// "startSellDate": "2021-01-03",
// "endSellDate": "2021-12-31",
// "privilegedRate": false,
// "privilegedRateRestriction": false,
// "lockStatus": "Unlocked"
// },
// "classifications": {
// "rateCategory": "HOTEL",
// "marketCode": "LEISURE"
// },
// "transactionDetails": {
// "folioText": {
// "defaultText": "Accommodation"
// },
// "transactionCode": "1000",
// "currencyCode": "USD",
// "rateIncludesTax": true
// },
// "rateCommission": {},
// "roomTypeList": [
// {
// "code": "ECO"
// },
// {
// "code": "SGL"
// },
// {
// "code": "DBL"
// },
// {
// "code": "SUP"
// },
// {
// "code": "JSUI"
// },
// {
// "code": "SUI"
// }
// ],
// "ratePackages": {
// "packages": [
// ],
// "packageGroups": [
// ]
// },
// "controls": {
// "sell": {
// "minimumStayThrough": "1",
// "minimumLengthOfStay": "1"
// },
// "yield": {
// "yieldable": "NonYieldable"
// }
// },
// "distribution": {
// "restrictionUpdate": false,
// "rateUpdate": false,
// "myFidelioUploadAllowed": false,
// "channelRateMappingExists": false,
// "channelAllowed": false
// },
// "ratePlanBasedOnRates": [
// {
// "basedOnRatePlanType": "None"
// }
// ],
// "approvalNotes": [
// {}
// ],
// "mobileCheckinAllowed": false,
// "mobileCheckoutAllowed": false,
// "hotelId": "{{HotelId}}",
// "ratePlanCode": "RACK123",
// "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.UpdateString("ratePlan.primaryDetails.description.defaultText", value: "Rate Code Description Goes Here")
json.UpdateString("ratePlan.primaryDetails.startSellDate", value: "2021-01-03")
json.UpdateString("ratePlan.primaryDetails.endSellDate", value: "2021-12-31")
json.UpdateBool("ratePlan.primaryDetails.privilegedRate", value: false)
json.UpdateBool("ratePlan.primaryDetails.privilegedRateRestriction", value: false)
json.UpdateString("ratePlan.primaryDetails.lockStatus", value: "Unlocked")
json.UpdateString("ratePlan.classifications.rateCategory", value: "HOTEL")
json.UpdateString("ratePlan.classifications.marketCode", value: "LEISURE")
json.UpdateString("ratePlan.transactionDetails.folioText.defaultText", value: "Accommodation")
json.UpdateString("ratePlan.transactionDetails.transactionCode", value: "1000")
json.UpdateString("ratePlan.transactionDetails.currencyCode", value: "USD")
json.UpdateBool("ratePlan.transactionDetails.rateIncludesTax", value: true)
json.UpdateNewObject("ratePlan.rateCommission")
json.UpdateString("ratePlan.roomTypeList[0].code", value: "ECO")
json.UpdateString("ratePlan.roomTypeList[1].code", value: "SGL")
json.UpdateString("ratePlan.roomTypeList[2].code", value: "DBL")
json.UpdateString("ratePlan.roomTypeList[3].code", value: "SUP")
json.UpdateString("ratePlan.roomTypeList[4].code", value: "JSUI")
json.UpdateString("ratePlan.roomTypeList[5].code", value: "SUI")
json.UpdateNewArray("ratePlan.ratePackages.packages")
json.UpdateNewArray("ratePlan.ratePackages.packageGroups")
json.UpdateString("ratePlan.controls.sell.minimumStayThrough", value: "1")
json.UpdateString("ratePlan.controls.sell.minimumLengthOfStay", value: "1")
json.UpdateString("ratePlan.controls.yield.yieldable", value: "NonYieldable")
json.UpdateBool("ratePlan.distribution.restrictionUpdate", value: false)
json.UpdateBool("ratePlan.distribution.rateUpdate", value: false)
json.UpdateBool("ratePlan.distribution.myFidelioUploadAllowed", value: false)
json.UpdateBool("ratePlan.distribution.channelRateMappingExists", value: false)
json.UpdateBool("ratePlan.distribution.channelAllowed", value: false)
json.UpdateString("ratePlan.ratePlanBasedOnRates[0].basedOnRatePlanType", value: "None")
json.UpdateBool("ratePlan.mobileCheckinAllowed", value: false)
json.UpdateBool("ratePlan.mobileCheckoutAllowed", value: false)
json.UpdateString("ratePlan.hotelId", value: "{{HotelId}}")
json.UpdateString("ratePlan.ratePlanCode", value: "RACK123")
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}}")
var resp: CkoHttpResponse? = http.PostJson3("https://domain.com/rtp/v0/hotels/{{HotelId}}/ratePlans", contentType: "application/json;charset=UTF-8", json: json)
if http.LastMethodSuccess == false {
print("\(http.LastErrorText)")
return
}
print("\(resp!.StatusCode.intValue)")
print("\(resp!.BodyStr)")
resp = nil
}
Curl Command
curl -X POST
-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": "Rate Code Description Goes Here"
},
"startSellDate": "2021-01-03",
"endSellDate": "2021-12-31",
"privilegedRate": false,
"privilegedRateRestriction": false,
"lockStatus": "Unlocked"
},
"classifications": {
"rateCategory": "HOTEL",
"marketCode": "LEISURE"
},
"transactionDetails": {
"folioText": {
"defaultText": "Accommodation"
},
"transactionCode": "1000",
"currencyCode": "USD",
"rateIncludesTax": true
},
"rateCommission": {},
"roomTypeList": [
{
"code": "ECO"
},
{
"code": "SGL"
},
{
"code": "DBL"
},
{
"code": "SUP"
},
{
"code": "JSUI"
},
{
"code": "SUI"
}
],
"ratePackages": {
"packages": [],
"packageGroups": []
},
"controls": {
"sell": {
"minimumStayThrough": "1",
"minimumLengthOfStay": "1"
},
"yield": {
"yieldable": "NonYieldable"
}
},
"distribution": {
"restrictionUpdate": false,
"rateUpdate": false,
"myFidelioUploadAllowed": false,
"channelRateMappingExists": false,
"channelAllowed": false
},
"ratePlanBasedOnRates": [
{
"basedOnRatePlanType": "None"
}
],
"approvalNotes": [
{}
],
"mobileCheckinAllowed": false,
"mobileCheckoutAllowed": false,
"hotelId": "{{HotelId}}",
"ratePlanCode": "RACK123",
"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
Postman Collection Item JSON
{
"name": "Create a new Rate Plans",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{Token}}",
"type": "string"
}
]
},
"method": "POST",
"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\": \"Rate Code Description Goes Here\"\r\n },\r\n \"startSellDate\": \"2021-01-03\",\r\n \"endSellDate\": \"2021-12-31\",\r\n \"privilegedRate\": false,\r\n \"privilegedRateRestriction\": false,\r\n \"lockStatus\": \"Unlocked\"\r\n },\r\n \"classifications\": {\r\n \"rateCategory\": \"HOTEL\",\r\n \"marketCode\": \"LEISURE\"\r\n },\r\n \"transactionDetails\": {\r\n \"folioText\": {\r\n \"defaultText\": \"Accommodation\"\r\n },\r\n \"transactionCode\": \"1000\",\r\n \"currencyCode\": \"USD\",\r\n \"rateIncludesTax\": true\r\n },\r\n \"rateCommission\": {},\r\n \"roomTypeList\": [\r\n {\r\n \"code\": \"ECO\"\r\n },\r\n {\r\n \"code\": \"SGL\"\r\n },\r\n {\r\n \"code\": \"DBL\"\r\n },\r\n {\r\n \"code\": \"SUP\"\r\n },\r\n {\r\n \"code\": \"JSUI\"\r\n },\r\n {\r\n \"code\": \"SUI\"\r\n }\r\n ],\r\n \"ratePackages\": {\r\n \"packages\": [],\r\n \"packageGroups\": []\r\n },\r\n \"controls\": {\r\n \"sell\": {\r\n \"minimumStayThrough\": \"1\",\r\n \"minimumLengthOfStay\": \"1\"\r\n },\r\n \"yield\": {\r\n \"yieldable\": \"NonYieldable\"\r\n }\r\n },\r\n \"distribution\": {\r\n \"restrictionUpdate\": false,\r\n \"rateUpdate\": false,\r\n \"myFidelioUploadAllowed\": false,\r\n \"channelRateMappingExists\": false,\r\n \"channelAllowed\": false\r\n },\r\n \"ratePlanBasedOnRates\": [\r\n {\r\n \"basedOnRatePlanType\": \"None\"\r\n }\r\n ],\r\n \"approvalNotes\": [\r\n {}\r\n ],\r\n \"mobileCheckinAllowed\": false,\r\n \"mobileCheckoutAllowed\": false,\r\n \"hotelId\": \"{{HotelId}}\",\r\n \"ratePlanCode\": \"RACK123\",\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",
"host": [
"{{HostName}}"
],
"path": [
"rtp",
"v0",
"hotels",
"{{HotelId}}",
"ratePlans"
]
}
},
"response": [
]
}