{
  "info": {
    "_postman_id": "da7fd10f-2909-4074-a99c-b7e884c2ea94",
    "name": "Amadeus Discover - Reporting",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "23145976"
  },
  "item": [
    {
      "name": "Keycloak - Authentication",
      "item": [
        {
          "name": "Token Keycloak - Username&Password",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test(\"Successful login\", () =>{\r",
                  "    pm.expect(pm.response.code).equal(200,\"Wrong status code! User is not authenticated correctly!\");\r",
                  "    pm.expect(pm.response.status).equal(\"OK\",\"Wrong status! User is not authenticated correctly!\");\r",
                  "    pm.environment.set(\"TOKEN_csm_api\",  pm.response.json().access_token);\r",
                  "});"
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "request": {
            "auth": {
              "type": "noauth"
            },
            "method": "POST",
            "header": [],
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "password",
                  "type": "text"
                },
                {
                  "key": "client_id",
                  "value": "consumer-api",
                  "type": "text"
                },
                {
                  "key": "username",
                  "value": "{{csm_api_username}}",
                  "type": "text"
                },
                {
                  "key": "password",
                  "value": "{{csm_api_password}}",
                  "type": "text"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/auth/realms/amadeus-discover/protocol/openid-connect/token",
              "host": ["{{base_url}}"],
              "path": ["auth", "realms", "amadeus-discover", "protocol", "openid-connect", "token"]
            }
          },
          "response": []
        },
        {
          "name": "Token Keycloak - Client ID&Secret",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "pm.test(\"Successful login\", () =>{\r",
                  "    pm.expect(pm.response.code).equal(200,\"Wrong status code! User is not authenticated correctly!\");\r",
                  "    pm.expect(pm.response.status).equal(\"OK\",\"Wrong status! User is not authenticated correctly!\");\r",
                  "    pm.environment.set(\"TOKEN_csm_api\",  pm.response.json().access_token);\r",
                  "});"
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "request": {
            "auth": {
              "type": "noauth"
            },
            "method": "POST",
            "header": [],
            "body": {
              "mode": "urlencoded",
              "urlencoded": [
                {
                  "key": "grant_type",
                  "value": "client_credentials",
                  "type": "text"
                },
                {
                  "key": "client_id",
                  "value": "{{client_id}}",
                  "type": "text"
                },
                {
                  "key": "client_secret",
                  "value": "{{client_secret}}",
                  "type": "text"
                }
              ]
            },
            "url": {
              "raw": "{{base_url}}/auth/realms/amadeus-discover/protocol/openid-connect/token",
              "host": ["{{base_url}}"],
              "path": ["auth", "realms", "amadeus-discover", "protocol", "openid-connect", "token"]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Reporting capabilities",
      "item": [
        {
          "name": "Get bookings list",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/reporting/v1/bookings?status=CONFIRMED",
              "host": ["{{base_url}}"],
              "path": ["reporting", "v1", "bookings"],
              "query": [
                {
                  "key": "status",
                  "value": "CONFIRMED"
                },
                {
                  "key": "bookedStartDate",
                  "value": "",
                  "disabled": true
                },
                {
                  "key": "bookedEndDate",
                  "value": "",
                  "disabled": true
                },
                {
                  "key": "bookingCode",
                  "value": "",
                  "disabled": true
                },
                {
                  "key": "externalClientId",
                  "value": "",
                  "disabled": true
                },
                {
                  "key": "page%5Boffset%5D",
                  "value": "",
                  "disabled": true
                },
                {
                  "key": "page%5Blimit%5D",
                  "value": "",
                  "disabled": true
                },
                {
                  "key": "confirmedStartDate",
                  "value": "2025-12-25",
                  "disabled": true
                },
                {
                  "key": "confirmedEndDate",
                  "value": "",
                  "disabled": true
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "Get booking details",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{base_url}}/reporting/v1/bookings/:bookingId",
              "host": ["{{base_url}}"],
              "path": ["reporting", "v1", "bookings", ":bookingId"],
              "variable": [
                {
                  "key": "bookingId",
                  "value": "{{booking_Id}}"
                }
              ]
            }
          },
          "response": []
        }
      ]
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{TOKEN_csm_api}}",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "pm.globals.set(\"amadeus.postman.lib\", `",
          "",
          "function Test_Check_Error_Validity(response, expectedError, errorSchema=\"sherpa_error_schema\"){",
          "    pm.test(pm.info.requestName +\" - HTTP response - Status check\", () =>{",
          "        if (errorSchema==\"shopping_error_schema\")",
          "        {",
          "            pm.response.to.have.status(expectedError.errors.first().status);",
          "        }",
          "        else",
          "            pm.response.to.have.status(expectedError.status);",
          "    });",
          "",
          "    pm.test(pm.info.requestName +\" - Error - Schema check\", () =>{",
          "        pm.response.to.have.jsonSchema(pm.globals.get(errorSchema));",
          "    });    ",
          "    pm.expect(",
          "                _.isEqual(",
          "                    response,",
          "                    expectedError",
          "                ),",
          "            \"Wrong Error! Expected \" + JSON.stringify(expectedError) + \". We got \" + JSON.stringify(response)).to.be.true;    ",
          "};",
          "`",
          ");"
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [""]
      }
    }
  ],
  "variable": [
    {
      "key": "organization_id",
      "value": "3965894",
      "type": "string",
      "disabled": true
    },
    {
      "key": "uniqueId",
      "value": ""
    },
    {
      "key": "channel_touchPointType",
      "value": ""
    },
    {
      "key": "channel_locationType",
      "value": ""
    },
    {
      "key": "channelUUID",
      "value": ""
    },
    {
      "key": "suggestionId",
      "value": ""
    },
    {
      "key": "suggestionSetId",
      "value": ""
    }
  ]
}
