{
    "info": {
        "name": "Toome",
        "_postman_id": "toome-developer-api",
        "description": "Toome Developer API + Toome Auth OTP.\n\nFull reference: https://toome.cloud/docs",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "variable": [
        {
            "key": "base_url",
            "value": "https://toome.cloud/api/v1"
        },
        {
            "key": "base_url_otp",
            "value": "https://toome.cloud/api/auth/v1"
        },
        {
            "key": "client_id",
            "value": ""
        },
        {
            "key": "client_secret",
            "value": ""
        },
        {
            "key": "access_token",
            "value": ""
        },
        {
            "key": "otp_api_key",
            "value": ""
        },
        {
            "key": "otp_app_secret",
            "value": ""
        },
        {
            "key": "phone",
            "value": "201012345678"
        },
        {
            "key": "request_id",
            "value": ""
        },
        {
            "key": "product_id",
            "value": ""
        }
    ],
    "auth": {
        "type": "bearer",
        "bearer": [
            {
                "key": "token",
                "value": "{{access_token}}",
                "type": "string"
            }
        ]
    },
    "item": [
        {
            "name": "Authentication",
            "item": [
                {
                    "name": "Get Access Token",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/token",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"client_id\": \"{{client_id}}\",\n    \"client_secret\": \"{{client_secret}}\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "auth": {
                            "type": "noauth"
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "if (pm.response.code === 200) {",
                                    "    const data = pm.response.json();",
                                    "    pm.collectionVariables.set('access_token', data.access_token);",
                                    "    console.log('access_token saved to collection variable');",
                                    "}"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Test Connection",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/test-connection"
                    }
                }
            ]
        },
        {
            "name": "Notifications",
            "item": [
                {
                    "name": "List Templates",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/templates"
                    }
                },
                {
                    "name": "Send Template Notification",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/notify",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"phone\": \"{{phone}}\",\n    \"template_name\": \"order_confirmed\",\n    \"variables\": [\n        \"Ahmed\",\n        \"#1042\",\n        \"150 EGP\"\n    ]\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    }
                },
                {
                    "name": "Send Order Status Notification",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/notifications/order",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"phone\": \"{{phone}}\",\n    \"status\": \"order_confirmed\",\n    \"tracking\": \"ORD-1042\",\n    \"customer_name\": \"Ahmed Ali\",\n    \"store_name\": \"My Store\",\n    \"total\": \"350 EGP\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    }
                }
            ]
        },
        {
            "name": "Customers",
            "item": [
                {
                    "name": "Create or Update Customer",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/customers",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"phone\": \"{{phone}}\",\n    \"name\": \"Ahmed Ali\",\n    \"email\": \"ahmed@example.com\",\n    \"source\": \"shopify\",\n    \"status\": \"customer\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    }
                },
                {
                    "name": "List Customers",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/customers?status=customer&search=ahmed&per_page=20",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "customers"
                            ],
                            "query": [
                                {
                                    "key": "status",
                                    "value": "customer"
                                },
                                {
                                    "key": "search",
                                    "value": "ahmed"
                                },
                                {
                                    "key": "per_page",
                                    "value": "20"
                                }
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Orders",
            "item": [
                {
                    "name": "Create Order",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/orders",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"order_ref\": \"ORD-1042\",\n    \"customer_phone\": \"{{phone}}\",\n    \"customer_name\": \"Ahmed Ali\",\n    \"total\": 350,\n    \"currency\": \"EGP\",\n    \"items\": [\n        {\n            \"name\": \"White T-Shirt\",\n            \"qty\": 2,\n            \"price\": 175\n        }\n    ],\n    \"notify_template\": \"order_confirmed\",\n    \"notify_variables\": [\n        \"Ahmed\",\n        \"ORD-1042\"\n    ]\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    }
                },
                {
                    "name": "List Orders",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/orders?per_page=20",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "orders"
                            ],
                            "query": [
                                {
                                    "key": "per_page",
                                    "value": "20"
                                }
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Products",
            "item": [
                {
                    "name": "List Products",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url}}/products?per_page=20",
                            "host": [
                                "{{base_url}}"
                            ],
                            "path": [
                                "products"
                            ],
                            "query": [
                                {
                                    "key": "per_page",
                                    "value": "20"
                                }
                            ]
                        }
                    }
                },
                {
                    "name": "Create or Update Product",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/products",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"name\": \"Product 1\",\n    \"name_en\": \"Product 1\",\n    \"sku\": \"P001\",\n    \"price\": 100,\n    \"stock\": 50,\n    \"description\": \"Sample product description\",\n    \"is_active\": true\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    }
                },
                {
                    "name": "Sync Products (Batch)",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/products/sync",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"products\": [\n        {\n            \"name\": \"Product 1\",\n            \"sku\": \"P001\",\n            \"price\": 100\n        },\n        {\n            \"name\": \"Product 2\",\n            \"sku\": \"P002\",\n            \"price\": 200\n        }\n    ]\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        }
                    }
                },
                {
                    "name": "Delete Product",
                    "request": {
                        "method": "DELETE",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{base_url}}/products/{{product_id}}"
                    }
                }
            ]
        },
        {
            "name": "\ud83d\udd10 Toome Auth OTP",
            "item": [
                {
                    "name": "Send OTP",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{otp_app_secret}}"
                            }
                        ],
                        "url": "{{base_url_otp}}/otp/send",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"phone\": \"{{phone}}\",\n    \"channel\": \"whatsapp\",\n    \"locale\": \"en\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{otp_api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    },
                    "event": [
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "if (pm.response.code === 200) {",
                                    "    const data = pm.response.json();",
                                    "    pm.collectionVariables.set('request_id', data.request_id);",
                                    "    console.log('request_id saved to collection variable');",
                                    "}"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "Verify OTP",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{otp_app_secret}}"
                            }
                        ],
                        "url": "{{base_url_otp}}/otp/verify",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"request_id\": \"{{request_id}}\",\n    \"code\": \"482917\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{otp_api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    }
                },
                {
                    "name": "Resend OTP",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            },
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{otp_app_secret}}"
                            }
                        ],
                        "url": "{{base_url_otp}}/otp/resend",
                        "body": {
                            "mode": "raw",
                            "raw": "{\n    \"request_id\": \"{{request_id}}\"\n}",
                            "options": {
                                "raw": {
                                    "language": "json"
                                }
                            }
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{otp_api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    }
                },
                {
                    "name": "Get OTP Status",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{otp_app_secret}}"
                            }
                        ],
                        "url": "{{base_url_otp}}/otp/status/{{request_id}}",
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{otp_api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    }
                },
                {
                    "name": "Cancel OTP",
                    "request": {
                        "method": "DELETE",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{otp_app_secret}}"
                            }
                        ],
                        "url": "{{base_url_otp}}/otp/{{request_id}}",
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{otp_api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    }
                },
                {
                    "name": "List OTP Logs",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{otp_app_secret}}"
                            }
                        ],
                        "url": {
                            "raw": "{{base_url_otp}}/otp/logs?per_page=20&page=1",
                            "host": [
                                "{{base_url_otp}}"
                            ],
                            "path": [
                                "otp",
                                "logs"
                            ],
                            "query": [
                                {
                                    "key": "per_page",
                                    "value": "20"
                                },
                                {
                                    "key": "page",
                                    "value": "1"
                                }
                            ]
                        },
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{otp_api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    }
                },
                {
                    "name": "App Stats",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "X-App-Secret",
                                "value": "{{otp_app_secret}}"
                            }
                        ],
                        "url": "{{base_url_otp}}/apps/stats",
                        "auth": {
                            "type": "bearer",
                            "bearer": [
                                {
                                    "key": "token",
                                    "value": "{{otp_api_key}}",
                                    "type": "string"
                                }
                            ]
                        }
                    }
                }
            ]
        }
    ]
}