{
  "info": {
    "name": "LotGrids Wallet API",
    "description": "Fleet backend + driver app integration against the LotGrids Fleet Wallet API. See https://docs.lotgrids.com for full documentation.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://api.lotgrids.com", "type": "string" },
    { "key": "apiKey", "value": "lg_live_replace_me", "type": "string" },
    { "key": "driverToken", "value": "", "type": "string" },
    { "key": "driverEmail", "value": "test.driver@fleetco.com", "type": "string" },
    { "key": "chargerId", "value": "chg_04af1c", "type": "string" },
    { "key": "connectorId", "value": "conn_02", "type": "string" }
  ],
  "item": [
    {
      "name": "Mint Driver Token",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const body = pm.response.json();",
              "if (body.token) { pm.collectionVariables.set('driverToken', body.token); }"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "ApiKey {{apiKey}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": { "raw": "{{baseUrl}}/v1/driver-tokens", "host": ["{{baseUrl}}"], "path": ["v1", "driver-tokens"] },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"driverEmail\": \"{{driverEmail}}\"\n}"
        }
      }
    },
    {
      "name": "Quote Charge Session",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{driverToken}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": { "raw": "{{baseUrl}}/v1/sessions/quote", "host": ["{{baseUrl}}"], "path": ["v1", "sessions", "quote"] },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"chargerId\": \"{{chargerId}}\",\n  \"connectorId\": \"{{connectorId}}\",\n  \"driverEmail\": \"{{driverEmail}}\"\n}"
        }
      }
    },
    {
      "name": "Start Charge Session",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{driverToken}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": { "raw": "{{baseUrl}}/v1/sessions", "host": ["{{baseUrl}}"], "path": ["v1", "sessions"] },
        "body": {
          "mode": "raw",
          "raw": "{\n  \"chargerId\": \"{{chargerId}}\",\n  \"connectorId\": \"{{connectorId}}\",\n  \"driverEmail\": \"{{driverEmail}}\",\n  \"amount\": 5000\n}"
        }
      }
    }
  ]
}
