{
  "info": {
    "_postman_id": "4ce10d2b-7c58-42ce-bd2b-6b8be0fe31b2",
    "name": "Modor MC Mobile Auth API",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "http://127.0.0.1:8000"
    },
    {
      "key": "login_email",
      "value": "demo@modomines.com"
    },
    {
      "key": "login_password",
      "value": "password"
    },
    {
      "key": "login_mobile",
      "value": "6767676767"
    },
    {
      "key": "mobile_otp",
      "value": ""
    },
    {
      "key": "bearer_token",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Email Login",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"email\": \"{{login_email}}\",\n  \"password\": \"{{login_password}}\"\n}"
        },
        "url": {
          "raw": "{{base_url}}/api/auth/login",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "auth",
            "login"
          ]
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"login returns 200\", function () {",
              "    pm.response.to.have.status(200);",
              "});",
              "",
              "const response = pm.response.json();",
              "pm.test(\"response contains bearer token\", function () {",
              "    pm.expect(response.status).to.eql(true);",
              "    pm.expect(response.access_token).to.be.a(\"string\").and.not.empty;",
              "});",
              "",
              "pm.collectionVariables.set(\"bearer_token\", response.access_token);"
            ]
          }
        }
      ]
    },
    {
      "name": "Mobile Send OTP",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"mobile\": \"{{login_mobile}}\"\n}"
        },
        "url": {
          "raw": "{{base_url}}/api/auth/login",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "auth",
            "login"
          ]
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"otp request returns 200\", function () {",
              "    pm.response.to.have.status(200);",
              "});",
              "",
              "const response = pm.response.json();",
              "pm.test(\"otp was requested\", function () {",
              "    pm.expect(response.status).to.eql(true);",
              "    pm.expect(response.otp_required).to.eql(true);",
              "});",
              "",
              "if (response.debug_otp) {",
              "    pm.collectionVariables.set(\"mobile_otp\", response.debug_otp);",
              "}"
            ]
          }
        }
      ]
    },
    {
      "name": "Mobile Verify OTP Login",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"mobile\": \"{{login_mobile}}\",\n  \"otp\": \"{{mobile_otp}}\"\n}"
        },
        "url": {
          "raw": "{{base_url}}/api/auth/login",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "auth",
            "login"
          ]
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"mobile otp login returns 200\", function () {",
              "    pm.response.to.have.status(200);",
              "});",
              "",
              "const response = pm.response.json();",
              "pm.test(\"mobile otp login returns token\", function () {",
              "    pm.expect(response.status).to.eql(true);",
              "    pm.expect(response.access_token).to.be.a(\"string\").and.not.empty;",
              "});",
              "",
              "pm.collectionVariables.set(\"bearer_token\", response.access_token);"
            ]
          }
        }
      ]
    },
    {
      "name": "Mobile Logout",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Accept",
            "value": "application/json"
          },
          {
            "key": "Authorization",
            "value": "Bearer {{bearer_token}}"
          }
        ],
        "url": {
          "raw": "{{base_url}}/api/auth/logout",
          "host": [
            "{{base_url}}"
          ],
          "path": [
            "api",
            "auth",
            "logout"
          ]
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"logout returns 200\", function () {",
              "    pm.response.to.have.status(200);",
              "});",
              "",
              "const response = pm.response.json();",
              "pm.test(\"logout succeeded\", function () {",
              "    pm.expect(response.status).to.eql(true);",
              "    pm.expect(response.message).to.eql(\"Logged out successfully\");",
              "});"
            ]
          }
        }
      ]
    }
  ]
}
