{
    "info": {
        "_postman_id": "marzsms-api-collection",
        "name": "MarzSms API",
        "description": "Official Postman collection for the MarzSms SMS API. Set collection variables apiKey and apiSecret.\n\nDocs: https://sms.wearemarz.com/docs",
        "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
    },
    "auth": {
        "type": "basic",
        "basic": [
            {
                "key": "username",
                "value": "{{apiKey}}",
                "type": "string"
            },
            {
                "key": "password",
                "value": "{{apiSecret}}",
                "type": "string"
            }
        ]
    },
    "variable": [
        {
            "key": "baseUrl",
            "value": "https://sms.wearemarz.com/api/v1"
        },
        {
            "key": "apiKey",
            "value": ""
        },
        {
            "key": "apiSecret",
            "value": ""
        },
        {
            "key": "reference",
            "value": ""
        },
        {
            "key": "airtimeReference",
            "value": ""
        }
    ],
    "item": [
        {
            "name": "SMS",
            "item": [
                {
                    "name": "POST /sms/send",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"recipient\": \"+256700000000\",\n  \"message\": \"Hello from MarzSMS\"\n}"
                        },
                        "url": "{{baseUrl}}/sms/send"
                    }
                },
                {
                    "name": "GET /sms/history",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/sms/history?page=1&per_page=20",
                            "host": ["{{baseUrl}}"],
                            "path": ["sms", "history"],
                            "query": [
                                {
                                    "key": "page",
                                    "value": "1"
                                },
                                {
                                    "key": "per_page",
                                    "value": "20"
                                }
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Account",
            "item": [
                {
                    "name": "GET /account/balance",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{baseUrl}}/account/balance"
                    }
                },
                {
                    "name": "POST /account/topup",
                    "event": [
                        {
                            "listen": "prerequest",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "if (!pm.collectionVariables.get('reference')) {",
                                    "  pm.collectionVariables.set('reference', pm.variables.replaceIn('{{$guid}}'));",
                                    "}"
                                ]
                            }
                        },
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "const json = pm.response.json();",
                                    "if (json && json.data && json.data.reference) {",
                                    "  pm.collectionVariables.set('reference', json.data.reference);",
                                    "}"
                                ]
                            }
                        }
                    ],
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"amount\": 10000,\n  \"phone_number\": \"+256700000000\",\n  \"reference\": \"{{reference}}\",\n  \"description\": \"MarzSMS API top-up\"\n}"
                        },
                        "url": "{{baseUrl}}/account/topup"
                    }
                },
                {
                    "name": "GET /account/topup/{reference}",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{baseUrl}}/account/topup/{{reference}}"
                    }
                }
            ]
        },
        {
            "name": "Airtime & Data",
            "item": [
                {
                    "name": "GET /airtime/catalog",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{baseUrl}}/airtime/catalog"
                    }
                },
                {
                    "name": "GET /airtime/detect-network",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/airtime/detect-network?msisdn=256771234567",
                            "host": ["{{baseUrl}}"],
                            "path": ["airtime", "detect-network"],
                            "query": [
                                {
                                    "key": "msisdn",
                                    "value": "256771234567"
                                }
                            ]
                        }
                    }
                },
                {
                    "name": "POST /airtime (airtime)",
                    "event": [
                        {
                            "listen": "prerequest",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "pm.collectionVariables.set('airtimeReference', pm.variables.replaceIn('{{$guid}}'));"
                                ]
                            }
                        },
                        {
                            "listen": "test",
                            "script": {
                                "type": "text/javascript",
                                "exec": [
                                    "const json = pm.response.json();",
                                    "if (json && json.data && json.data.reference) {",
                                    "  pm.collectionVariables.set('airtimeReference', json.data.reference);",
                                    "}"
                                ]
                            }
                        }
                    ],
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"purchase_type\": \"airtime\",\n  \"msisdn\": \"256771234567\",\n  \"amount\": 5000,\n  \"reference\": \"{{airtimeReference}}\"\n}"
                        },
                        "url": "{{baseUrl}}/airtime"
                    }
                },
                {
                    "name": "POST /airtime (bundle)",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"purchase_type\": \"bundle\",\n  \"msisdn\": \"256771234567\",\n  \"bundle_id\": \"RACT_UG_Data_201\"\n}"
                        },
                        "url": "{{baseUrl}}/airtime"
                    }
                },
                {
                    "name": "GET /airtime/{reference}",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{baseUrl}}/airtime/{{airtimeReference}}"
                    }
                },
                {
                    "name": "GET /airtime (history)",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": {
                            "raw": "{{baseUrl}}/airtime?page=1&per_page=20",
                            "host": ["{{baseUrl}}"],
                            "path": ["airtime"],
                            "query": [
                                {
                                    "key": "page",
                                    "value": "1"
                                },
                                {
                                    "key": "per_page",
                                    "value": "20"
                                }
                            ]
                        }
                    }
                }
            ]
        },
        {
            "name": "Phone Verification (airtime/data add-on)",
            "item": [
                {
                    "name": "POST /phone-verification/verify",
                    "request": {
                        "method": "POST",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            },
                            {
                                "key": "Content-Type",
                                "value": "application/json"
                            }
                        ],
                        "body": {
                            "mode": "raw",
                            "raw": "{\n  \"phone_number\": \"256771234567\"\n}"
                        },
                        "url": "{{baseUrl}}/phone-verification/verify"
                    }
                },
                {
                    "name": "GET /phone-verification/service",
                    "request": {
                        "method": "GET",
                        "header": [
                            {
                                "key": "Accept",
                                "value": "application/json"
                            }
                        ],
                        "url": "{{baseUrl}}/phone-verification/service"
                    }
                }
            ]
        }
    ]
}
