Chilkat Online Tools

Swift3 / Booking Management API v2021.12 / 1. Shop (BFM)

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.

    // {
    //   "OTA_AirLowFareSearchRQ": {
    //     "Version": "1",
    //     "POS": {
    //       "Source": [
    //         {
    //           "PseudoCityCode": "{{pcc}}",
    //           "RequestorID": {
    //             "Type": "1",
    //             "ID": "1",
    //             "CompanyName": {
    //               "Code": "TN"
    //             }
    //           }
    //         }
    //       ]
    //     },
    //     "OriginDestinationInformation": [
    //       {
    //         "RPH": "1",
    //         "DepartureDateTime": "{{start_date}}T00:00:00",
    //         "OriginLocation": {
    //           "LocationCode": "KRK"
    //         },
    //         "DestinationLocation": {
    //           "LocationCode": "WAW"
    //         }
    //       }
    //     ],
    //     "TravelPreferences": {
    //       "MaxStopsQuantity": 0,
    //       "CabinPref": [
    //         {
    //           "PreferLevel": "Preferred",
    //           "Cabin": "Y"
    //         }
    //       ],
    //       "TPA_Extensions": {
    //         "NumTrips": {
    //           "Number": 10
    //         },
    //         "DataSources": {
    //           "NDC": "Disable",
    //           "ATPCO": "Enable",
    //           "LCC": "Disable"
    //         }
    //       }
    //     },
    //     "TravelerInfoSummary": {
    //       "AirTravelerAvail": [
    //         {
    //           "PassengerTypeQuantity": [
    //             {
    //               "Code": "ADT",
    //               "Quantity": 1
    //             }
    //           ]
    //         }
    //       ]
    //     },
    //     "TPA_Extensions": {
    //       "IntelliSellTransaction": {
    //         "RequestType": {
    //           "Name": "200ITINS"
    //         }
    //       }
    //     }
    //   }
    // }

    let json = CkoJsonObject()!
    json.update("OTA_AirLowFareSearchRQ.Version", value: "1")
    json.update("OTA_AirLowFareSearchRQ.POS.Source[0].PseudoCityCode", value: "{{pcc}}")
    json.update("OTA_AirLowFareSearchRQ.POS.Source[0].RequestorID.Type", value: "1")
    json.update("OTA_AirLowFareSearchRQ.POS.Source[0].RequestorID.ID", value: "1")
    json.update("OTA_AirLowFareSearchRQ.POS.Source[0].RequestorID.CompanyName.Code", value: "TN")
    json.update("OTA_AirLowFareSearchRQ.OriginDestinationInformation[0].RPH", value: "1")
    json.update("OTA_AirLowFareSearchRQ.OriginDestinationInformation[0].DepartureDateTime", value: "{{start_date}}T00:00:00")
    json.update("OTA_AirLowFareSearchRQ.OriginDestinationInformation[0].OriginLocation.LocationCode", value: "KRK")
    json.update("OTA_AirLowFareSearchRQ.OriginDestinationInformation[0].DestinationLocation.LocationCode", value: "WAW")
    json.updateInt("OTA_AirLowFareSearchRQ.TravelPreferences.MaxStopsQuantity", value: 0)
    json.update("OTA_AirLowFareSearchRQ.TravelPreferences.CabinPref[0].PreferLevel", value: "Preferred")
    json.update("OTA_AirLowFareSearchRQ.TravelPreferences.CabinPref[0].Cabin", value: "Y")
    json.updateInt("OTA_AirLowFareSearchRQ.TravelPreferences.TPA_Extensions.NumTrips.Number", value: 10)
    json.update("OTA_AirLowFareSearchRQ.TravelPreferences.TPA_Extensions.DataSources.NDC", value: "Disable")
    json.update("OTA_AirLowFareSearchRQ.TravelPreferences.TPA_Extensions.DataSources.ATPCO", value: "Enable")
    json.update("OTA_AirLowFareSearchRQ.TravelPreferences.TPA_Extensions.DataSources.LCC", value: "Disable")
    json.update("OTA_AirLowFareSearchRQ.TravelerInfoSummary.AirTravelerAvail[0].PassengerTypeQuantity[0].Code", value: "ADT")
    json.updateInt("OTA_AirLowFareSearchRQ.TravelerInfoSummary.AirTravelerAvail[0].PassengerTypeQuantity[0].Quantity", value: 1)
    json.update("OTA_AirLowFareSearchRQ.TPA_Extensions.IntelliSellTransaction.RequestType.Name", value: "200ITINS")

    http.setRequestHeader("Conversation-ID", value: "{{conv_id}}")
    http.setRequestHeader("Content-Type", value: "application/json")
    // Adds the "Authorization: Bearer <access_token>" header.
    http.authToken = "<access_token>"

    var resp: CkoHttpResponse? = http.postJson3("https://domain.com/v2/offers/shop", contentType: "application/json", 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"
	-H "Conversation-ID: {{conv_id}}"
	-d '{
    "OTA_AirLowFareSearchRQ": {
        "Version": "1",
        "POS": {
            "Source": [{
                    "PseudoCityCode": "{{pcc}}",
                    "RequestorID": {
                        "Type": "1",
                        "ID": "1",
                        "CompanyName": {
                            "Code": "TN"
                        }
                    }
                }
            ]
        },
        "OriginDestinationInformation": [{
                "RPH": "1",
                "DepartureDateTime": "{{start_date}}T00:00:00",
                "OriginLocation": {
                    "LocationCode": "KRK"
                },
                "DestinationLocation": {
                    "LocationCode": "WAW"
                }
            }
        ],
        "TravelPreferences": {
            "MaxStopsQuantity": 0,
            "CabinPref": [
                {
                    "PreferLevel": "Preferred",
                    "Cabin": "Y"
                }
            ],
            "TPA_Extensions": {
                "NumTrips": {
                    "Number": 10
                },
                "DataSources": {
                    "NDC": "Disable",
                    "ATPCO": "Enable",
                    "LCC": "Disable"
                }

 

            }
        },
        "TravelerInfoSummary": {
            "AirTravelerAvail": [{
                    "PassengerTypeQuantity": [{
                            "Code": "ADT",
                            "Quantity": 1
                        }
                    ]
                }
            ]
        },
        "TPA_Extensions": {
            "IntelliSellTransaction": {
                "RequestType": {
                    "Name": "200ITINS"
                }
            }
        }
    }
}'
https://domain.com/v2/offers/shop

Postman Collection Item JSON

{
  "name": "1. Shop (BFM)",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "const itinNumber = 0;",
          "",
          "var jsonData = JSON.parse(responseBody);",
          "var outboundData = jsonData.groupedItineraryResponse.scheduleDescs[0];",
          "",
          "",
          "pm.environment.set(\"oFlightNumber\", outboundData.carrier.marketingFlightNumber);",
          "pm.environment.set(\"oResBookDesigCode\", outboundData.ResBookDesigCode);",
          "pm.environment.set(\"oDepartureTime\", outboundData.departure.time.substring(0, 5));",
          "pm.environment.set(\"oDepartureAirport\", outboundData.departure.airport);",
          "pm.environment.set(\"oArrivalAirport\", outboundData.arrival.airport);",
          "pm.environment.set(\"oMarketingAirline\", outboundData.carrier.marketing);",
          "pm.environment.set(\"oOperatingAirline\", outboundData.carrier.operating);",
          "",
          ""
        ],
        "type": "text/javascript"
      }
    },
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      },
      {
        "key": "Conversation-ID",
        "value": "{{conv_id}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"OTA_AirLowFareSearchRQ\": {\n        \"Version\": \"1\",\n        \"POS\": {\n            \"Source\": [{\n                    \"PseudoCityCode\": \"{{pcc}}\",\n                    \"RequestorID\": {\n                        \"Type\": \"1\",\n                        \"ID\": \"1\",\n                        \"CompanyName\": {\n                            \"Code\": \"TN\"\n                        }\n                    }\n                }\n            ]\n        },\n        \"OriginDestinationInformation\": [{\n                \"RPH\": \"1\",\n                \"DepartureDateTime\": \"{{start_date}}T00:00:00\",\n                \"OriginLocation\": {\n                    \"LocationCode\": \"KRK\"\n                },\n                \"DestinationLocation\": {\n                    \"LocationCode\": \"WAW\"\n                }\n            }\n        ],\n        \"TravelPreferences\": {\n            \"MaxStopsQuantity\": 0,\n            \"CabinPref\": [\n                {\n                    \"PreferLevel\": \"Preferred\",\n                    \"Cabin\": \"Y\"\n                }\n            ],\n            \"TPA_Extensions\": {\n                \"NumTrips\": {\n                    \"Number\": 10\n                },\n                \"DataSources\": {\n                    \"NDC\": \"Disable\",\n                    \"ATPCO\": \"Enable\",\n                    \"LCC\": \"Disable\"\n                }\n\n \n\n            }\n        },\n        \"TravelerInfoSummary\": {\n            \"AirTravelerAvail\": [{\n                    \"PassengerTypeQuantity\": [{\n                            \"Code\": \"ADT\",\n                            \"Quantity\": 1\n                        }\n                    ]\n                }\n            ]\n        },\n        \"TPA_Extensions\": {\n            \"IntelliSellTransaction\": {\n                \"RequestType\": {\n                    \"Name\": \"200ITINS\"\n                }\n            }\n        }\n    }\n}"
    },
    "url": {
      "raw": "{{rest_endpoint}}/v2/offers/shop",
      "host": [
        "{{rest_endpoint}}"
      ],
      "path": [
        "v2",
        "offers",
        "shop"
      ]
    },
    "description": "[//]: # \"Start\"\n\n<b>[Description](https://developer.sabre.com/docs/rest_apis/air/search/bargain_finder_max/versions/v430), [Resources](https://developer.sabre.com/docs/rest_apis/air/search/bargain_finder_max/versions/v430/reference-documentation)</b>\n\n[//]: # \"End\""
  },
  "response": [
  ]
}