{
	"info": {
		"_postman_id": "7b8f9e20-338b-4a57-8142-f8b8682d3345",
		"name": "DevLivery - Smart Delivery & E-Commerce Integration API",
		"description": "مجموعة طلبات Postman لربط أي متجر إلكتروني خارجي بنظام التوصيل السريع وإسناد المناديب الذكي وحساب الأسعار والتتبع المباشر.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"variable": [
		{
			"key": "base_url",
			"value": "http://localhost:8000",
			"type": "string"
		},
		{
			"key": "api_key",
			"value": "123456789",
			"type": "string"
		},
		{
			"key": "tracking_code",
			"value": "DEL-20261020-0001",
			"type": "string"
		}
	],
	"item": [
		{
			"name": "0. Merchant & Store Connection (ربط وتسجيل المتجر)",
			"item": [
				{
					"name": "Connect Store / Register Merchant (ربط المتجر واعتماده كتاجر)",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"name\": \"متجر الأناقة الحديثة\",\n  \"contact_person_name\": \"سعد الدوسري\",\n  \"phone\": \"0501122334\",\n  \"email\": \"store@modern-elegance.com\",\n  \"address\": \"الرياض، حي السلي، مستودع رقم 12\",\n  \"platform\": \"custom_store\",\n  \"webhook_url\": \"https://modern-elegance.com/api/webhooks/delivery\"\n}",
							"options": {
								"raw": {
									"language": "json"
								}
							}
						},
						"url": {
							"raw": "{{base_url}}/api/v1/merchants/connect",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"v1",
								"merchants",
								"connect"
							]
						},
						"description": "تسجيل المتجر كتاجر معتمد في النظام ليظهر في قائمة التجار بكافة تفاصيله وشحناته."
					},
					"response": []
				}
			]
		},
		{
			"name": "1. Shipping Calculator (حاسبة التكلفة والوقت قبل الشحن)",
			"item": [
				{
					"name": "Calculate Shipping Rate (حساب تكلفة ووقت التوصيل للحي)",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"city_name\": \"الرياض\",\n  \"district_name\": \"الملقا\",\n  \"weight_kg\": 2.5,\n  \"items_count\": 2\n}",
							"options": {
								"raw": {
									"language": "json"
								}
							}
						},
						"url": {
							"raw": "{{base_url}}/api/v1/shipping/calculate",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"v1",
								"shipping",
								"calculate"
							]
						},
						"description": "يستخدم في صفحة الدفع (Checkout) بموقعك لحساب تكلفة الشحن والوقت المتوقع قبل أن يتم العميل عملية الشراء."
					},
					"response": []
				}
			]
		},
		{
			"name": "2. Orders Management (إدارة الشحنات والطلبات)",
			"item": [
				{
					"name": "Create Single Order (إنشاء طلب توصيل فوري)",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"var jsonData = pm.response.json();",
									"if (jsonData.status && jsonData.data && jsonData.data.tracking_code) {",
									"    pm.collectionVariables.set('tracking_code', jsonData.data.tracking_code);",
									"}"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"reference_id\": \"STORE-ORD-98214\",\n  \"platform\": \"custom_store\",\n  \"notes\": \"يرجى الاتصال بالعميل قبل الوصول بربع ساعة\",\n  \"cod_amount\": 150.00,\n  \"currency\": \"SAR\",\n  \"webhook_url\": \"https://my-store.com/api/webhooks/delivery\",\n  \"customer\": {\n    \"name\": \"عبدالله محمد الشمري\",\n    \"phone\": \"0551234567\",\n    \"email\": \"customer@example.com\",\n    \"city\": \"الرياض\",\n    \"district_name\": \"الملقا\",\n    \"address\": \"طريق أنس بن مالك، عمارة 14، شقة 5\",\n    \"lat\": 24.810231,\n    \"lng\": 46.618420\n  },\n  \"pickup\": {\n    \"name\": \"مستودع المتجر الرئيسي\",\n    \"phone\": \"0509876543\",\n    \"address\": \"حي السلي، مخرج 16، مستودع رقم 3\",\n    \"lat\": 24.641200,\n    \"lng\": 46.829100\n  },\n  \"items\": [\n    {\n      \"name\": \"عطر مخلط ملكي 100 مل\",\n      \"quantity\": 2,\n      \"unit_price\": 75.00\n    }\n  ]\n}",
							"options": {
								"raw": {
									"language": "json"
								}
							}
						},
						"url": {
							"raw": "{{base_url}}/api/v1/orders",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"v1",
								"orders"
							]
						},
						"description": "إرسال طلب بيع جديد لنظام التوصيل. يقوم النظام آلياً بتحديد الحي وإسناد المندوب الأقرب وتوليد كود التتبع ورابط التتبع المباشر."
					},
					"response": []
				},
				{
					"name": "Batch Create Orders (إنشاء شحنات متعددة دفعة واحدة)",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"orders\": [\n    {\n      \"reference_id\": \"ORD-101\",\n      \"cod_amount\": 0,\n      \"customer\": {\n        \"name\": \"سارة أحمد\",\n        \"phone\": \"0501112233\",\n        \"city\": \"الرياض\",\n        \"district_name\": \"الياسمين\",\n        \"address\": \"شارع العليا، فيلا 22\"\n      }\n    },\n    {\n      \"reference_id\": \"ORD-102\",\n      \"cod_amount\": 220.00,\n      \"customer\": {\n        \"name\": \"فهد التميمي\",\n        \"phone\": \"0559998877\",\n        \"city\": \"الرياض\",\n        \"district_name\": \"النرجس\",\n        \"address\": \"حي النرجس، مجمع 4\"\n      }\n    }\n  ]\n}",
							"options": {
								"raw": {
									"language": "json"
								}
							}
						},
						"url": {
							"raw": "{{base_url}}/api/v1/orders/batch",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"v1",
								"orders",
								"batch"
							]
						},
						"description": "إنشاء شحنات متعددة بطلب واحد للسرعة عند معالجة طلبات نهاية اليوم."
					},
					"response": []
				},
				{
					"name": "Track Order (تتبع حالة الطلب وتفاصيل المندوب)",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/v1/orders/{{tracking_code}}",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"v1",
								"orders",
								"{{tracking_code}}"
							]
						},
						"description": "جلب حالة الطلب وسجل التحديثات الزمني (Timeline) وبيانات المندوب الحالي سواء عبر كود التتبع DEL-... أو عبر رقم طلبك reference_id."
					},
					"response": []
				},
				{
					"name": "Cancel Order (إلغاء الطلب)",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Accept",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "Content-Type",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\n  \"reason\": \"طلب العميل إلغاء الشحنة قبل خروج المندوب\"\n}",
							"options": {
								"raw": {
									"language": "json"
								}
							}
						},
						"url": {
							"raw": "{{base_url}}/api/v1/orders/{{tracking_code}}/cancel",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"v1",
								"orders",
								"{{tracking_code}}",
								"cancel"
							]
						},
						"description": "إلغاء الطلب في حال لم يتم تسليمه بعد."
					},
					"response": []
				}
			]
		},
		{
			"name": "3. Coverage & Geography (التغطية والأحياء)",
			"item": [
				{
					"name": "List Cities (قائمة المدن المدعومة)",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/v1/cities",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"v1",
								"cities"
							]
						}
					},
					"response": []
				},
				{
					"name": "List Districts (قائمة أحياء الرياض المشمولة)",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Accept",
								"value": "application/json",
								"type": "text"
							},
							{
								"key": "api-key",
								"value": "{{api_key}}",
								"type": "text"
							}
						],
						"url": {
							"raw": "{{base_url}}/api/v1/districts?city_name=الرياض",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"api",
								"v1",
								"districts"
							],
							"query": [
								{
									"key": "city_name",
									"value": "الرياض"
								}
							]
						}
					},
					"response": []
				}
			]
		}
	]
}