{"collection":{"info":{"_postman_id":"0d8e735e-6207-48a1-b8bb-9cc73386b7ae","name":"UNIQREWARDS Client API v3","schema":"https://schema.getpostman.com/json/collection/v2.1.0/collection.json","createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-22T08:15:24.000Z","lastUpdatedBy":"18476604","uid":"18476604-0d8e735e-6207-48a1-b8bb-9cc73386b7ae"},"item":[{"name":"Authentication","event":[{"listen":"test","script":{"id":"229023cb-5662-4161-92f8-9ebc1fdc7221","exec":["var jsonData = JSON.parse(responseBody);\r","pm.collectionVariables.set(\"access_token\", jsonData.access_token);\r","\r","pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});"],"type":"text/javascript","packages":{}}}],"id":"cd62dda2-92c7-4f6b-baa6-4938a331befe","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"basic","basic":[{"key":"password","value":"{{client_secret}}","type":"string"},{"key":"username","value":"{{client_id}}","type":"string"}]},"method":"POST","header":[],"body":{"mode":"urlencoded","urlencoded":[{"key":"grant_type","value":"client_credentials","type":"text"},{"key":"scope","value":"client_v3_demo/issue_vouchers client_v3_demo/read_catalogue client_v3_demo/read_vouchers","type":"text","description":"Space separated for several scopes"}]},"url":{"raw":"{{auth_service}}/oauth2/token","host":["{{auth_service}}"],"path":["oauth2","token"]},"description":"Obtains an auth token using id and secret and saves it into the collection variable `access_token` to be used in other requests."},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-22T07:53:04.000Z","uid":"18476604-cd62dda2-92c7-4f6b-baa6-4938a331befe"},{"name":"Retrieve catalogue of products","event":[{"listen":"test","script":{"id":"ca67e55a-8e5c-48cc-b140-d82ef18cadf1","exec":["pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});"],"type":"text/javascript","packages":{}}}],"id":"23046e28-8ec3-4bb1-bd9f-4c77426d62d8","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{access_token}}","type":"string"}]},"method":"GET","header":[],"url":{"raw":"{{api_base_url}}/products","host":["{{api_base_url}}"],"path":["products"]}},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-22T08:11:38.000Z","uid":"18476604-23046e28-8ec3-4bb1-bd9f-4c77426d62d8"},{"name":"Retrieve product MAMVDDMMYY01","event":[{"listen":"test","script":{"id":"ca67e55a-8e5c-48cc-b140-d82ef18cadf1","exec":["pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});"],"type":"text/javascript","packages":{}}}],"id":"fd8b1f6e-a915-4c89-a134-a16a9cdcd5ab","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{access_token}}","type":"string"}]},"method":"GET","header":[],"url":{"raw":"{{api_base_url}}/products/MAMVDDMMYY01","host":["{{api_base_url}}"],"path":["products","MAMVDDMMYY01"]},"description":"The product code `MAMVDDMMYY01` can be replaced in the path."},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-22T08:11:44.000Z","uid":"18476604-fd8b1f6e-a915-4c89-a134-a16a9cdcd5ab"},{"name":"Issue 1 voucher","event":[{"listen":"test","script":{"id":"ca67e55a-8e5c-48cc-b140-d82ef18cadf1","exec":["pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});\r","var jsonData = JSON.parse(responseBody);\r","pm.collectionVariables.set(\"voucher_id\", jsonData.vouchers[0].voucher_id);\r","pm.test('Number of vouchers = ' + jsonData.vouchers.length, function () {\r","    pm.expect(jsonData.vouchers.length).to.equal(1);\r","});"],"type":"text/javascript","packages":{}}},{"listen":"prerequest","script":{"id":"9ee90fe7-d6c1-41e2-a483-490bcde43031","exec":["var uuid = require('uuid');\r","var myUUID = uuid.v4();\r","pm.collectionVariables.set(\"idempotency_key\", myUUID);"],"type":"text/javascript","packages":{}}}],"id":"81826b3e-a1fc-4357-a1a0-fee0638a9bea","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{access_token}}","type":"string"}]},"method":"POST","header":[{"key":"Idempotency-Key","value":"{{idempotency_key}}","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"quantity\": 1\r\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"{{api_base_url}}/products/MAMVDDMMYY01","host":["{{api_base_url}}"],"path":["products","MAMVDDMMYY01"]},"description":"Issues 1 voucher.  \nGenerates an idempotency key before issuance and saves it to the variable `idempotency_key` to be reused if necessary."},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-22T08:04:32.000Z","uid":"18476604-81826b3e-a1fc-4357-a1a0-fee0638a9bea"},{"name":"Idempotent retry (for voucher issuance)","event":[{"listen":"test","script":{"id":"ca67e55a-8e5c-48cc-b140-d82ef18cadf1","exec":["pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});\r","var jsonData = JSON.parse(responseBody);\r","pm.test(\"Checks that the same voucher_id is received\", function () {\r","   pm.expect(jsonData.vouchers[0].voucher_id).to.equal(pm.collectionVariables.get(\"voucher_id\"));\r","});\r","\r","pm.test(\"Idempotency-Record is present\", function () {\r","    pm.response.to.have.header(\"Idempotency-Record\");\r","});\r",""],"type":"text/javascript","packages":{}}}],"id":"89e23ea2-5897-44c5-a91c-20bc8062ca61","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{access_token}}","type":"string"}]},"method":"POST","header":[{"key":"Idempotency-Key","value":"{{idempotency_key}}","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"quantity\": 1\r\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"{{api_base_url}}/products/MAMVDDMMYY01","host":["{{api_base_url}}"],"path":["products","MAMVDDMMYY01"]},"description":"Retry voucher issuance reusing the same idempotency key."},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-25T07:30:35.000Z","uid":"18476604-89e23ea2-5897-44c5-a91c-20bc8062ca61"},{"name":"Issue 1 open-value voucher","event":[{"listen":"test","script":{"id":"ca67e55a-8e5c-48cc-b140-d82ef18cadf1","exec":["pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});\r","var jsonData = JSON.parse(responseBody);\r","pm.collectionVariables.set(\"voucher_id\", jsonData.vouchers[0].voucher_id);\r","pm.test('Number of vouchers = ' + jsonData.vouchers.length, function () {\r","    pm.expect(jsonData.vouchers.length).to.equal(1);\r","});"],"type":"text/javascript","packages":{}}}],"id":"1c156fd4-c3bd-4e4b-8879-cc8d706327c6","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{access_token}}","type":"string"}]},"method":"POST","header":[{"key":"Idempotency-Key","value":"{{$randomUUID}}","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"quantity\": 1,\r\n    \"face_value\": 1010\r\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"{{api_base_url}}/products/UNIVDYNAMICTEST01","host":["{{api_base_url}}"],"path":["products","UNIVDYNAMICTEST01"]},"description":"Requires a `face_value` in the request body as the product is dynamic value-based."},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-25T10:07:11.000Z","uid":"18476604-1c156fd4-c3bd-4e4b-8879-cc8d706327c6"},{"name":"Issue 2 vouchers","event":[{"listen":"test","script":{"id":"ca67e55a-8e5c-48cc-b140-d82ef18cadf1","exec":["pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});\r","var jsonData = JSON.parse(responseBody);\r","pm.collectionVariables.set(\"voucher_id\", jsonData.vouchers[0].voucher_id);\r","pm.collectionVariables.set(\"voucher_id_2\", jsonData.vouchers[1].voucher_id);\r","pm.test('Number of vouchers = ' + jsonData.vouchers.length, function () {\r","    pm.expect(jsonData.vouchers.length).to.equal(2);\r","});"],"type":"text/javascript","packages":{}}}],"id":"ae828c62-93cd-4232-829b-bbd786deaac6","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{access_token}}","type":"string"}]},"method":"POST","header":[{"key":"Idempotency-Key","value":"{{$randomUUID}}","type":"text"}],"body":{"mode":"raw","raw":"{\r\n    \"quantity\": 2\r\n}","options":{"raw":{"language":"json"}}},"url":{"raw":"{{api_base_url}}/products/MAMVDDMMYY01","host":["{{api_base_url}}"],"path":["products","MAMVDDMMYY01"]},"description":"Issues 2 vouchers and saves their ID into collection variables to be reused as input for retrieve vouchers requests."},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-25T07:30:25.000Z","uid":"18476604-ae828c62-93cd-4232-829b-bbd786deaac6"},{"name":"Retrieve voucher","event":[{"listen":"test","script":{"id":"ca67e55a-8e5c-48cc-b140-d82ef18cadf1","exec":["pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});"],"type":"text/javascript","packages":{}}}],"id":"d264eff3-7aa6-4a4c-b01d-73f1c2d17563","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{access_token}}","type":"string"}]},"method":"GET","header":[],"url":{"raw":"{{api_base_url}}/vouchers/{{voucher_id}}","host":["{{api_base_url}}"],"path":["vouchers","{{voucher_id}}"]}},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-25T07:30:27.000Z","uid":"18476604-d264eff3-7aa6-4a4c-b01d-73f1c2d17563"},{"name":"Retrieve 2 vouchers","event":[{"listen":"test","script":{"id":"ca67e55a-8e5c-48cc-b140-d82ef18cadf1","exec":["pm.test(\"Status code is 200\", function () {\r","    pm.response.to.have.status(200);\r","});"],"type":"text/javascript","packages":{}}}],"id":"996de14f-a1cf-4792-8c58-bc67ebff8e51","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{access_token}}","type":"string"}]},"method":"GET","header":[],"url":{"raw":"{{api_base_url}}/vouchers?id={{voucher_id}},{{voucher_id_2}}","host":["{{api_base_url}}"],"path":["vouchers"],"query":[{"key":"id","value":"{{voucher_id}},{{voucher_id_2}}"}]}},"response":[],"createdAt":"2024-04-22T07:38:05.000Z","updatedAt":"2024-04-25T07:30:30.000Z","uid":"18476604-996de14f-a1cf-4792-8c58-bc67ebff8e51"}],"event":[{"listen":"prerequest","script":{"id":"5bfb1ad8-dbf8-4c2d-91f8-4770e0043e5a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"df598fbb-dc97-46e4-aff1-1c3b282441ea","type":"text/javascript","exec":[""]}}],"variable":[{"key":"auth_service","value":"https://uniqgift-qa.auth.ap-southeast-1.amazoncognito.com","type":"string"},{"key":"client_id","value":"","type":"string"},{"key":"client_secret","value":"","type":"string"},{"key":"access_token","value":""},{"key":"api_base_url","value":"https://api.demo.uniqrewards.com/v3","type":"string"},{"key":"voucher_id","value":""},{"key":"voucher_id_2","value":""},{"key":"idempotency_key","value":""}]}}