{
  "info": {
    "_postman_id": "b59d8cf3-3d55-4aa2-b231-0e92857adbe3",
    "name": "Customer updates",
    "description": "Authenticated client contract for CIF and biometric update journeys. Run Get customer update status first. The collection captures the first start token, the active customer update ID, and the current step ID when the API returns them.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      { "key": "token", "value": "{{ACCESS_TOKEN}}", "type": "string" }
    ]
  },
  "variable": [
    { "key": "BASE_URL", "value": "http://localhost:5000/v1/digitalonboarding" },
    { "key": "ACCESS_TOKEN", "value": "" },
    { "key": "customer_update_id", "value": "" },
    { "key": "step_id", "value": "email_address" },
    { "key": "start_token", "value": "" }
  ],
  "item": [
    {
      "name": "Get customer update status",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Status is successful', function () { pm.expect(pm.response.code).to.equal(200); });",
              "const body = pm.response.json().responseObject;",
              "const startable = body.journeys.find((journey) => journey.startToken);",
              "const active = body.journeys.find((journey) => journey.customerUpdateId);",
              "if (startable) pm.collectionVariables.set('start_token', startable.startToken);",
              "if (active) pm.collectionVariables.set('customer_update_id', active.customerUpdateId);"
            ]
          }
        }
      ],
      "request": { "method": "GET", "url": "{{BASE_URL}}/customer-updates/status" },
      "response": [
        {
          "name": "Incomplete catalog",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": {\n    \"overallStatus\": \"incomplete\",\n    \"progress\": { \"completedSteps\": 7, \"totalSteps\": 10, \"percentage\": 0.7 },\n    \"journeys\": [\n      {\n        \"journeyId\": \"customer_information_update\",\n        \"displayOrder\": 1,\n        \"title\": \"Customer information\",\n        \"subtitle\": \"Fill in your physical address and occupation information.\",\n        \"lifecycle\": \"not_started\",\n        \"availability\": \"available\",\n        \"customerUpdateId\": null,\n        \"startToken\": \"opaque-short-lived-token\"\n      },\n      {\n        \"journeyId\": \"biometric_fingerprints_update\",\n        \"displayOrder\": 2,\n        \"title\": \"Capture your biometrics\",\n        \"subtitle\": \"Share your biometric information.\",\n        \"lifecycle\": \"not_started\",\n        \"availability\": \"available\",\n        \"customerUpdateId\": null,\n        \"startToken\": \"opaque-short-lived-token\"\n      }\n    ]\n  },\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        },
        {
          "name": "Not eligible",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": { \"overallStatus\": \"notEligible\", \"progress\": null, \"journeys\": [] },\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        }
      ]
    },
    {
      "name": "Start or resume customer update",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Start is successful', function () { pm.expect(pm.response.code).to.equal(200); });",
              "const body = pm.response.json().responseObject;",
              "pm.collectionVariables.set('customer_update_id', body.customerUpdateId);",
              "pm.collectionVariables.set('step_id', body.currentStepId);"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": { "mode": "raw", "raw": "{\n  \"startToken\": \"{{start_token}}\"\n}", "options": { "raw": { "language": "json" } } },
        "url": "{{BASE_URL}}/customer-updates"
      },
      "response": [
        {
          "name": "Started or resumed",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": {\n    \"customerUpdateId\": \"019c0000-0000-7000-8000-000000000001\",\n    \"journeyId\": \"customer_information_update\",\n    \"lifecycle\": \"active\",\n    \"currentStepId\": \"email_address\"\n  },\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        }
      ]
    },
    {
      "name": "Get resolved journey config",
      "request": { "method": "GET", "url": "{{BASE_URL}}/customer-updates/{{customer_update_id}}/journey-config" },
      "response": [
        {
          "name": "Resolved journey",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": {\n    \"customerUpdateId\": \"019c0000-0000-7000-8000-000000000001\",\n    \"journeyId\": \"customer_information_update\",\n    \"journeyVersion\": 2,\n    \"progress\": { \"completedSteps\": 1, \"totalSteps\": 4, \"percentage\": 0.25 },\n    \"steps\": [\n      { \"stepId\": \"email_address\", \"sequence\": 1, \"formKey\": \"profile_email_validation\", \"formVersion\": 2, \"title\": \"Email address\", \"type\": \"Form\", \"status\": \"Validated\" },\n      { \"stepId\": \"preferred_address\", \"sequence\": 2, \"formKey\": \"profile_preferred_address\", \"formVersion\": 1, \"title\": \"Preferred address\", \"type\": \"Form\", \"status\": \"NotStarted\" },\n      { \"stepId\": \"review_information\", \"sequence\": 3, \"formKey\": \"review_information\", \"formVersion\": 1, \"title\": \"Review information\", \"type\": \"ReviewForm\", \"status\": \"NotStarted\" },\n      { \"stepId\": \"confirm\", \"sequence\": 4, \"formKey\": \"confirm\", \"formVersion\": 1, \"title\": \"Confirm\", \"type\": \"ConfirmForm\", \"status\": \"NotStarted\" }\n    ],\n    \"branches\": []\n  },\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        }
      ]
    },
    {
      "name": "Get current step",
      "request": { "method": "GET", "url": "{{BASE_URL}}/customer-updates/{{customer_update_id}}/current-step" },
      "response": [
        {
          "name": "Current form step",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": {\n    \"customerUpdateId\": \"019c0000-0000-7000-8000-000000000001\",\n    \"currentStepId\": \"preferred_address\",\n    \"stepType\": \"Form\",\n    \"status\": \"NotStarted\",\n    \"onboardingStatus\": \"InProgress\",\n    \"countryCode\": \"KE\",\n    \"documentType\": null,\n    \"documentNumber\": null,\n    \"data\": { \"country\": \"KE\", \"city\": \"NBO\" },\n    \"form\": {\n      \"formKey\": \"profile_preferred_address\",\n      \"formVersion\": 1,\n      \"schema\": { \"type\": \"object\", \"properties\": { \"town\": { \"type\": \"string\" }, \"building\": { \"type\": \"string\" } }, \"required\": [\"town\", \"building\"] },\n      \"uiSchema\": {},\n      \"statusPage\": null,\n      \"hash\": \"sha256:example\",\n      \"context\": {}\n    },\n    \"resolvedBranches\": {}\n  },\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        }
      ]
    },
    {
      "name": "Get step",
      "request": { "method": "GET", "url": "{{BASE_URL}}/customer-updates/{{customer_update_id}}/steps/{{step_id}}" },
      "response": [
        {
          "name": "Requested form step",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": {\n    \"customerUpdateId\": \"019c0000-0000-7000-8000-000000000001\",\n    \"currentStepId\": \"email_address\",\n    \"stepType\": \"Form\",\n    \"status\": \"Validated\",\n    \"onboardingStatus\": \"InProgress\",\n    \"countryCode\": \"KE\",\n    \"documentType\": null,\n    \"documentNumber\": null,\n    \"data\": { \"emailAddress\": \"customer@example.test\" },\n    \"form\": { \"formKey\": \"profile_email_validation\", \"formVersion\": 2, \"schema\": {}, \"uiSchema\": {}, \"statusPage\": null, \"hash\": \"sha256:example\", \"context\": {} },\n    \"resolvedBranches\": {}\n  },\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        }
      ]
    },
    {
      "name": "Submit or save step",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": { "mode": "raw", "raw": "{\n  \"requestId\": \"{{$guid}}\",\n  \"isDraft\": false,\n  \"payload\": {\n    \"town\": \"Westlands\",\n    \"building\": \"Delta Corner\"\n  }\n}", "options": { "raw": { "language": "json" } } },
        "url": "{{BASE_URL}}/customer-updates/{{customer_update_id}}/steps/{{step_id}}/submit"
      },
      "response": [
        {
          "name": "Step validated",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": {\n    \"status\": \"Validated\",\n    \"onboardingStatus\": \"InProgress\",\n    \"currentStepId\": \"preferred_address\",\n    \"nextStepId\": \"review_information\",\n    \"nextStepType\": \"ReviewForm\",\n    \"validation\": null,\n    \"nextStep\": null,\n    \"documentType\": null,\n    \"documentNumber\": null,\n    \"resolvedBranches\": {},\n    \"existingCustomerUpdateId\": null\n  },\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        },
        {
          "name": "Confirmation still processing",
          "status": "Accepted",
          "code": 202,
          "header": [
            { "key": "Content-Type", "value": "application/json" },
            { "key": "Location", "value": "{{BASE_URL}}/customer-updates/status" }
          ],
          "cookie": [],
          "body": "{\n  \"responseObject\": {\n    \"lifecycle\": \"processing\",\n    \"submissionReference\": \"019c0000-0000-7000-8000-000000000099\",\n    \"statusUrl\": \"{{BASE_URL}}/customer-updates/status\"\n  },\n  \"successful\": true,\n  \"statusMessage\": \"We are processing your request.\",\n  \"statusCode\": 202\n}"
        }
      ]
    },
    {
      "name": "Verify OTP",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "body": { "mode": "raw", "raw": "{\n  \"otp\": \"123456\"\n}", "options": { "raw": { "language": "json" } } },
        "url": "{{BASE_URL}}/customer-updates/{{customer_update_id}}/otp/verify"
      },
      "response": [
        {
          "name": "OTP verified",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": null,\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        }
      ]
    },
    {
      "name": "Regenerate OTP",
      "request": { "method": "POST", "url": "{{BASE_URL}}/customer-updates/{{customer_update_id}}/otp/regenerate" },
      "response": [
        {
          "name": "OTP regenerated",
          "status": "OK",
          "code": 200,
          "header": [{ "key": "Content-Type", "value": "application/json" }],
          "cookie": [],
          "body": "{\n  \"responseObject\": null,\n  \"successful\": true,\n  \"statusMessage\": \"Success\",\n  \"statusCode\": 200\n}"
        }
      ]
    }
  ]
}
