{
	"info": {
		"_postman_id": "96d345f6-0e98-4683-905e-7321da9b856f",
		"name": "Sunset Pacific Transportation API",
		"description": "Official flow for the Sunset Pacific Transportation API.\n\nHOW TO USE\n1. Import this collection AND one of the provided environments in Postman:\n   - Sunset Pacific - Production (baseUrl = https://api.sunsetpacific.com)\n   - Sunset Pacific - Test (baseUrl = https://apisunsetpacificstage.azurewebsites.net)\n2. Select the imported environment in the top-right selector. The baseUrl is already set, so you never copy a URL.\n3. Open the environment (eye icon > Edit) and set `username` and `password` (your API username, NOT your email). Make sure your account has been enabled by a Sunset Pacific administrator.\n4. Run the request \"1. Login (Get Token)\". Its test script automatically stores the returned `access_token`.\n5. All other requests inherit `Authorization: Bearer {{access_token}}` from the collection, so you never copy/paste the token. The token is valid for 60 minutes.\n\nThe requests \"Create Quote\" / \"Create Quote By Zip Code\" also auto-save the returned QuoteId into the `quoteId` variable, used by Get Quote, Tender and Upload Tender File.\n\nNote: if no environment is selected, the collection falls back to its own variables (baseUrl defaults to the Test URL).",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"auth": {
		"type": "bearer",
		"bearer": [
			{
				"key": "token",
				"value": "{{access_token}}",
				"type": "string"
			}
		]
	},
	"variable": [
		{
			"key": "baseUrl",
			"value": "https://apisunsetpacificstage.azurewebsites.net",
			"type": "string"
		},
		{
			"key": "username",
			"value": "",
			"type": "string"
		},
		{
			"key": "password",
			"value": "",
			"type": "string"
		},
		{
			"key": "access_token",
			"value": "",
			"type": "string"
		},
		{
			"key": "quoteId",
			"value": "",
			"type": "string"
		},
		{
			"key": "orderNumber",
			"value": "",
			"type": "string"
		},
		{
			"key": "proNumber",
			"value": "",
			"type": "string"
		}
	],
	"item": [
		{
			"name": "1. Login (Get Token)",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"pm.test(\"Status code is 200\", function () {",
							"    pm.response.to.have.status(200);",
							"});",
							"",
							"var json = pm.response.json();",
							"if (json && json.access_token) {",
							"    pm.collectionVariables.set(\"access_token\", json.access_token);",
							"    console.log(\"access_token saved to collection variable. Valid for \" + json.expires_in + \" seconds.\");",
							"} else {",
							"    console.warn(\"No access_token in the response.\");",
							"}"
						]
					}
				}
			],
			"request": {
				"auth": {
					"type": "noauth"
				},
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "urlencoded",
					"urlencoded": [
						{
							"key": "grant_type",
							"value": "password",
							"type": "text"
						},
						{
							"key": "username",
							"value": "{{username}}",
							"type": "text"
						},
						{
							"key": "password",
							"value": "{{password}}",
							"type": "text"
						}
					]
				},
				"url": {
					"raw": "{{baseUrl}}/token",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"token"
					]
				},
				"description": "Authenticate and obtain the access_token. The test script stores it automatically; you do not need to copy it. The token is valid for 60 minutes."
			}
		},
		{
			"name": "2. Create Quote",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var json = pm.response.json();",
							"if (json && json.QuoteId) {",
							"    pm.collectionVariables.set(\"quoteId\", json.QuoteId);",
							"    console.log(\"quoteId saved: \" + json.QuoteId);",
							"}"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"Origin\": 1,\n    \"Destination\": 30401,\n    \"PickUpDate\": \"2016-01-01\",\n    \"LinealFootageKnown\": 33.66,\n    \"Weight\": 10000,\n    \"IsFloorLoaded\": null,\n    \"NonFloorLoadeds\": [],\n    \"FloorLoadeds\": [],\n    \"ShippingRemarks\": null,\n    \"MeasurementLFT\": 2\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrl}}/api/Quotes",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"Quotes"
					]
				},
				"description": "Create a new quote using the numeric Origin. The returned QuoteId is stored in the quoteId variable."
			}
		},
		{
			"name": "3. Create Quote By Zip Code",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var json = pm.response.json();",
							"if (json && json.QuoteId) {",
							"    pm.collectionVariables.set(\"quoteId\", json.QuoteId);",
							"    console.log(\"quoteId saved: \" + json.QuoteId);",
							"}"
						]
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"OriginZipCode\": 85001,\n    \"Destination\": 1588,\n    \"PickUpDate\": \"2016-01-01\",\n    \"LinealFootageKnown\": 33.66,\n    \"Weight\": 10000,\n    \"IsFloorLoaded\": null,\n    \"NonFloorLoadeds\": [],\n    \"FloorLoadeds\": [],\n    \"ShippingRemarks\": null,\n    \"MeasurementLFT\": 2\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrl}}/api/Quotes/QuoteByZipCode",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"Quotes",
						"QuoteByZipCode"
					]
				},
				"description": "Evolution of Create Quote: pass the origin as a ZIP code (OriginZipCode) instead of the numeric Origin."
			}
		},
		{
			"name": "4. Get Quote",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					}
				],
				"url": {
					"raw": "{{baseUrl}}/api/Quotes/{{quoteId}}",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"Quotes",
						"{{quoteId}}"
					]
				},
				"description": "Retrieve an existing quote by its id (uses the quoteId variable set by Create Quote)."
			}
		},
		{
			"name": "5. Tender",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"quoteId\": {{quoteId}},\n    \"shipper\": {\n        \"shipperName\": \"Alberth Einstein\",\n        \"contactName\": \"Pablo James\",\n        \"city\": \"Chino Hills\",\n        \"state\": \"CA\",\n        \"address\": \"5378 Buttonwood Court\",\n        \"zip\": \"91709\",\n        \"email\": \"any@any.com\",\n        \"phone\": \"9096067899\"\n    },\n    \"finalDestination\": {\n        \"consigneeName\": \"CEGA Security HQ - Test\",\n        \"contactName\": \"Tania Lopez\",\n        \"city\": \"Tustin\",\n        \"state\": \"NY\",\n        \"address\": \"1234 Test Ave\",\n        \"zip\": \"30331\",\n        \"email\": \"any@any.com\",\n        \"phone\": \"9096067899\"\n    },\n    \"shippingRemarks\": \"DA / SAT\",\n    \"commodityDescription\": \"any text\",\n    \"billingReference\": \"billing reference number: LL0524\",\n    \"pickupInformation\": {\n        \"pickupDate\": \"2017-01-26\",\n        \"pickUpTimeFrom\": 0,\n        \"pickUpTimeTo\": 0\n    },\n    \"numberReference\": \"My number 198223\",\n    \"deliveryInformation\": {\n        \"dueDateType\": 1,\n        \"dueMustDelivery\": \"2017-01-26\",\n        \"duePreSetAppt\": \"2017-01-26\",\n        \"dueDateInit\": \"2017-01-26\",\n        \"dueDateEnd\": \"2017-01-26\",\n        \"dueDateEndTime\": 0,\n        \"dueDateEndTimeSelector\": 0\n    },\n    \"deliveryReference\": \"any text\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrl}}/api/tender",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"tender"
					]
				},
				"description": "Tender an existing quote. pickUpTimeFrom / pickUpTimeTo are indexes of the aHours array (index 0 = 00:00, +1 = 30 min)."
			}
		},
		{
			"name": "6. Upload Tender File",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "multipart/form-data"
					}
				],
				"body": {
					"mode": "formdata",
					"formdata": [
						{
							"key": "file",
							"type": "file",
							"src": []
						}
					]
				},
				"url": {
					"raw": "{{baseUrl}}/api/tender/{{quoteId}}/UploadFile",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"tender",
						"{{quoteId}}",
						"UploadFile"
					]
				},
				"description": "Upload documents for a tendered quote. Select a file in the Body > form-data 'file' field before sending."
			}
		},
		{
			"name": "7. Tracking",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					}
				],
				"url": {
					"raw": "{{baseUrl}}/api/Tracking/{{orderNumber}}",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"Tracking",
						"{{orderNumber}}"
					]
				},
				"description": "Track an existing order by orderNumber. Set the orderNumber collection variable first."
			}
		},
		{
			"name": "8. Document",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					}
				],
				"url": {
					"raw": "{{baseUrl}}/api/Document/{{orderNumber}}",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"Document",
						"{{orderNumber}}"
					]
				},
				"description": "Retrieve the documents of an order by orderNumber."
			}
		},
		{
			"name": "9. Tracking by ProNumber",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					}
				],
				"url": {
					"raw": "{{baseUrl}}/api/TrackingByPRONumber/{{proNumber}}",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"TrackingByPRONumber",
						"{{proNumber}}"
					]
				},
				"description": "Track an order by ProNumber. The first call may return Status = Pending; wait 5 minutes and retry."
			}
		},
		{
			"name": "10. Document by ProNumber",
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					}
				],
				"url": {
					"raw": "{{baseUrl}}/api/DocumentByPRONumber/{{proNumber}}",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"DocumentByPRONumber",
						"{{proNumber}}"
					]
				},
				"description": "Retrieve the documents of an order by ProNumber."
			}
		},
		{
			"name": "11. Tender (24-hour pickup format)",
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "Accept",
						"value": "application/json"
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"quoteId\": {{quoteId}},\n    \"shipper\": {\n        \"shipperName\": \"Alberth Einstein\",\n        \"city\": \"Chino Hills\",\n        \"state\": \"CA\",\n        \"address\": \"5378 Buttonwood Court\",\n        \"zip\": \"91709\",\n        \"email\": \"any@any.com\",\n        \"phone\": \"9096067899\"\n    },\n    \"finalDestination\": {\n        \"consigneeName\": \"CEGA Security HQ - Test\",\n        \"city\": \"Tustin\",\n        \"state\": \"NY\",\n        \"address\": \"1234 Test Ave\",\n        \"zip\": \"30331\",\n        \"email\": \"any@any.com\",\n        \"phone\": \"9096067899\"\n    },\n    \"shippingRemarks\": \"DA / SAT\",\n    \"commodityDescription\": \"any text\",\n    \"billingReference\": \"billing reference number: LL0524\",\n    \"pickupInformation\": {\n        \"pickupDate\": \"2017-01-26\",\n        \"pickUpTimeFrom\": \"00:00\",\n        \"pickUpTimeTo\": \"13:00\"\n    },\n    \"numberReference\": \"My number 198223\",\n    \"deliveryInformation\": {\n        \"dueDateType\": 1,\n        \"dueMustDelivery\": \"2017-01-26\",\n        \"duePreSetAppt\": \"2017-01-26\",\n        \"dueDateInit\": \"2017-01-26\",\n        \"dueDateEnd\": \"2017-01-26\",\n        \"dueDateEndTime\": 0,\n        \"dueDateEndTimeSelector\": 0\n    },\n    \"deliveryReference\": \"any text\"\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{baseUrl}}/api/v2/tender",
					"host": [
						"{{baseUrl}}"
					],
					"path": [
						"api",
						"v2",
						"tender"
					]
				},
				"description": "Version 2 of Tender. pickUpTimeFrom / pickUpTimeTo are strings in 24-hour format (e.g. \"09:00\"). A minimum 4-hour window is required."
			}
		}
	]
}
