{
	"info": {
		"name": "DepartCart API Collection",
		"description": "API collection for DepartCart with bearer token generation and encrypted URL creation",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"version": "1.0.0"
	},
	"item": [
		{
			"name": "Authentication",
			"description": "Authentication endpoints for generating bearer tokens",
			"item": [
				{
					"name": "Generate Bearer Token",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"api_key\": \"{{api_key}}\",\n  \"api_secret\": \"{{api_secret}}\",\n  \"duration_hours\": 24\n}"
						},
						"url": {
							"raw": "{{base_url}}/generate-bearer-token",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"generate-bearer-token"
							]
						},
						"description": "Generate a bearer token for authentication"
					},
					"response": [],
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has bearer token\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData).to.have.property('bearer_token');",
									"    pm.expect(jsonData).to.have.property('success', true);",
									"    ",
									"    // Save token to collection variable",
									"    pm.collectionVariables.set('bearer_token', jsonData.bearer_token);",
									"});"
								],
								"type": "text/javascript"
							}
						}
					]
				}
			]
		},
		{
			"name": "URL Generation",
			"description": "Endpoints for generating encrypted URLs with bearer token authentication",
			"item": [
				{
					"name": "Generate Encrypted URL",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{bearer_token}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"pnr\": \"WPCOEN\",\n  \"last_name\": \"APPLESEED\",\n  \"source\": \"api\",\n}"
						},
						"url": {
							"raw": "{{base_url}}/generate-encrypted-url",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"generate-encrypted-url"
							]
						},
						"description": "Generate encrypted seatmap, cart, and checkout URLs using bearer token authentication"
					},
					"response": [],
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"pm.test(\"Status code is 200\", function () {",
									"    pm.response.to.have.status(200);",
									"});",
									"",
									"pm.test(\"Response has encrypted URLs\", function () {",
									"    var jsonData = pm.response.json();",
									"    pm.expect(jsonData).to.have.property('success', true);",
									"    pm.expect(jsonData).to.have.property('seatmap_url');",
									"    pm.expect(jsonData).to.have.property('cart_url');",
									"    pm.expect(jsonData).to.have.property('checkout_url');",
									"    pm.expect(jsonData).to.have.property('encrypted_id');",
									"    ",
									"    console.log('Encrypted URLs generated:');",
									"    console.log('Seatmap URL:', jsonData.seatmap_url);",
									"    console.log('Cart URL:', jsonData.cart_url);",
									"    console.log('Checkout URL:', jsonData.checkout_url);",
									"});"
								],
								"type": "text/javascript"
							}
						}
					]
				}
			]
		}

	],
	"variable": [
		{
			"key": "base_url",
			"value": "https://departcart.com",
			"description": "Base URL for the DepartCart API"
		},
		{
			"key": "api_key",
			"value": "your_api_key_here",
			"description": "API key for authenticating requests"
		},
		{
			"key": "api_secret",
			"value": "your_api_secret_here",
			"description": "API secret for authenticating requests"
		},
		{
			"key": "bearer_token",
			"value": "your_bearer_token_here",
			"description": "Bearer token for authenticating requests"
		}
	]
}
