{
	"info": {
		"_postman_id": "aa60e955-cac1-4983-a34f-0c114c241d76",
		"name": "Iterate CSV file to bulk create bookings on MotionTools",
		"description": "This collection shows how you can loop over the same request while changing the parameters using the Collection Runner and the `postman.setNextRequest()` function.\n\nTo try it out, open the collection, then click on \"Run\" to open the collection runner. Select the query you want to run and run it!\n \nThis is an answer to the two following questions on the Postman Community Forum:\n- https://community.postman.com/t/running-a-request-multiple-times-with-different-data-sets/1064\n- https://community.postman.com/t/how-to-loop-through-array-and-use-its-values-in-a-request/6771",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "21705382"
	},
	"item": [
		{
			"name": "Create a 2-stop booking (Pickup, Drop-off)",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				},
				{
					"listen": "test",
					"script": {
						"exec": [
							"const Booking_scheduled_at = pm.collectionVariables.get(\"Booking_scheduled_at\");\r",
							"\r",
							"if (Booking_scheduled_at && Booking_scheduled_at.length > 0){\r",
							"    postman.setNextRequest(\"Loop Post Parameter\");\r",
							"} else {\r",
							"    postman.setNextRequest(null);\r",
							"}\r",
							"\r",
							"pm.test(\"Status code is 200\", function () {\r",
							"    pm.response.to.have.status(200);\r",
							"});"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"auth": {
					"type": "apikey",
					"apikey": [
						{
							"key": "value",
							"value": "{{api_key}}",
							"type": "string"
						},
						{
							"key": "key",
							"value": "Authorization",
							"type": "string"
						}
					]
				},
				"method": "POST",
				"header": [],
				"body": {
					"mode": "raw",
					"raw": "{\"booking\":{\r\n    \"stops\":[\r\n\r\n        {\"lat\":{{Pickup_lat}},\"lng\":{{Pickup_lng}},\"street\":\"{{Pickup_street}}\",\"number\":\"{{Pickup_house_number}}\",\"zip_code\":\"{{Pickup_zip_code}}\",\"city\":\"{{Pickup_city}}\",\"location_name\":\"{{Pickup_location_name}}\",\"additional_line\":\"{{Pickup_additional_address_line}}\",\"type\":\"pickup\",\"flow\":\"single_step\",\r\n        \"metadata\":{{{Pickup_metadata}}},\"content\":[{{Pickup_custom_content}}]\r\n        },\r\n\r\n        {\"lat\":{{Dropoff_lat}},\"lng\":{{Dropoff_lng}},\"street\":\"{{Dropoff_street}}\",\"number\":\"{{Dropoff_house_number}}\",\"zip_code\":\"{{Dropoff_zip_code}}\",\"city\":\"{{Dropoff_city}}\",\"location_name\":\"{{Dropoff_location_name}}\",\"additional_line\":\"{{Dropoff_additional_address_line}}\",\"type\":\"dropoff\",\"expected_arrival_at\":\"{{Dropoff_expected_arrival_at}}\",\"expected_departure_at\":\"{{Dropoff_expected_departure_at}}\",\"metadata\":{{{Dropoff_metadata}}},\"content\":[{{Dropoff_custom_content}}]\r\n        }\r\n\r\n    ],\r\n\"requested_capabilities\":{{{Booking_requested_capabilities}}},\r\n\"scheduled_at\":\"{{Booking_scheduled_at}}\",\r\n\"customer_id\":\"{{Booking_customer_id}}\",\r\n\"service_id\":\"{{Booking_service_id}}\",\r\n\"version\":2,\"metadata\":{{{Booking_metadata}}},\r\n\"payment_method\":null,\r\n\"managing_organizations\":[{{Booking_managing_organizations}}]\r\n    }\r\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{base_url}}/api/hailing/bookings",
					"host": [
						"{{base_url}}"
					],
					"path": [
						"api",
						"hailing",
						"bookings"
					]
				}
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "Booking_service_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "Booking_requested_capabilities",
			"value": "",
			"type": "string"
		},
		{
			"key": "Booking_customer_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "Booking_scheduled_at",
			"value": "",
			"type": "string"
		},
		{
			"key": "Booking_additional_information",
			"value": "",
			"type": "string"
		},
		{
			"key": "Booking_metadata",
			"value": "",
			"type": "string"
		},
		{
			"key": "Booking_managing_organizations",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_location_name",
			"value": ""
		},
		{
			"key": "Pickup_lat",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_lng",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_street",
			"value": ""
		},
		{
			"key": "Pickup_house_number",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_zip_code",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_city",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_country",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_additional_address_line",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_additional_information",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_first_name",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_last_name",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_phone_number",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_email",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_expected_arrival_at",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_expected_departure_at",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_custom_content",
			"value": "",
			"type": "string"
		},
		{
			"key": "Pickup_metadata",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_location_name",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_lat",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_lng",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_street",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_house_number",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_zip_code",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_city",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_country",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_additional_address_line",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_additional_information",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_first_name",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_last_name",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_phone_number",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_email",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_expected_arrival_at",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_expected_departure_at",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_custom_content",
			"value": "",
			"type": "string"
		},
		{
			"key": "Dropoff_metadata",
			"value": "",
			"type": "string"
		}
	]
}