{"info":{"_postman_id":"04a69a77-f021-42fa-a341-84a8687a62d7","name":"RBAC-api","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"description":"<html><head></head><body></body></html>","owner":"25537013","collectionId":"04a69a77-f021-42fa-a341-84a8687a62d7","publishedId":"2s9YynkPDa","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2024-01-23T17:00:40.000Z"},"item":[{"name":"User SignUp","event":[{"listen":"test","script":{"id":"5475d0b1-7f7a-4a22-8745-a3d845912a1d","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});"],"type":"text/javascript"}}],"id":"007c3e36-f04c-4587-aac6-a578f1baffcf","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"email\": \"userC@example.com\",\r\n    \"password\": \"string\",\r\n    \"role\": \"Admin\"\r\n}","options":{"raw":{"language":"json"}}},"url":"{{base_url}}/auth/signup","description":"<p>This POST endpoint is used to create/sign up a new user. The role field can only allow either \"Admin\" or \"Customer\".</p>\n","urlObject":{"path":["auth","signup"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"423106f4-ec5b-40cc-9132-629c58545395","name":"User Signup","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"email\": \"customer03@example.com\",\r\n    \"password\": \"string\",\r\n    \"role\": \"Customer\"\r\n}","options":{"raw":{"language":"json"}}},"url":"{{base_url}}/auth/signup"},"status":"Created","code":201,"_postman_previewlanguage":"json","header":[{"key":"X-Powered-By","value":"Express"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Content-Length","value":"176"},{"key":"ETag","value":"W/\"b0-cj3wKw5GPJQOBVaJ/k2B4lLZtSk\""},{"key":"Date","value":"Wed, 24 Jan 2024 01:03:43 GMT"},{"key":"Connection","value":"keep-alive"},{"key":"Keep-Alive","value":"timeout=5"}],"cookie":[],"responseTime":null,"body":"{\n    \"message\": \"User account created\",\n    \"data\": {\n        \"id\": 11,\n        \"email\": \"customer03@example.com\",\n        \"password\": \"$2b$10$XZ7arE6H4fspyJZs7YAu8OBL6dIy0rEeem30ZVDVYvrYf3UTn3bei\",\n        \"role\": \"Customer\"\n    }\n}"}],"_postman_id":"007c3e36-f04c-4587-aac6-a578f1baffcf"},{"name":"User Log-In","event":[{"listen":"test","script":{"id":"5475d0b1-7f7a-4a22-8745-a3d845912a1d","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});"],"type":"text/javascript"}}],"id":"963c09e5-c8d1-4b6f-8e23-d97220e0f59b","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"email\": \"userA@example.com\",\r\n    \"password\": \"string\"\r\n}","options":{"raw":{"language":"json"}}},"url":"{{base_url}}/auth/login","description":"<p>This POST endpoint is used to log a user in. It returns an access token that will be used to authorise access to all the other endpoints.</p>\n","urlObject":{"path":["auth","login"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"5dc76131-3d00-4067-8d1f-d0ec99472c58","name":"User Login","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n    \"email\": \"customer03@example.com\",\r\n    \"password\": \"string\"\r\n}","options":{"raw":{"language":"json"}}},"url":"{{base_url}}/auth/login"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"X-Powered-By","value":"Express"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Content-Length","value":"227"},{"key":"ETag","value":"W/\"e3-61C/U4RZqfykLilrmPu/xF/9+/I\""},{"key":"Date","value":"Wed, 24 Jan 2024 01:05:16 GMT"},{"key":"Connection","value":"keep-alive"},{"key":"Keep-Alive","value":"timeout=5"}],"cookie":[],"responseTime":null,"body":"{\n    \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjExLCJlbWFpbCI6ImN1c3RvbWVyMDNAZXhhbXBsZS5jb20iLCJyb2xlIjoiQ3VzdG9tZXIiLCJpYXQiOjE3MDYwNTgzMTYsImV4cCI6MTcwNjMxNzUxNn0.pjV0-7CroddPDzGkbWTMUn2bNnnZPSGzG1dJYcCBUSw\"\n}"}],"_postman_id":"963c09e5-c8d1-4b6f-8e23-d97220e0f59b"},{"name":"Get Users","event":[{"listen":"test","script":{"id":"5475d0b1-7f7a-4a22-8745-a3d845912a1d","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});"],"type":"text/javascript"}}],"id":"89e06771-83c2-44bb-9b59-db8f318c01c6","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{bearer_token}}"}]},"isInherited":false},"method":"GET","header":[],"body":{"mode":"raw","raw":"","options":{"raw":{"language":"json"}}},"url":"{{base_url}}/users","description":"<p>This GET endpoint is used to retrieve all signed up user's details. The endpoint also takes an optional role query to retrieve users by their role of either \"Admin\" or 'Customer\" (i.e attach ?role=Admin or ?role=Customer to the endpoint).  </p>\n<p>Requires access token.</p>\n","urlObject":{"path":["users"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"f8e70fab-f5bb-4455-8c3a-c80bc4c6b7bf","name":"Get Users","originalRequest":{"method":"GET","header":[],"url":"{{base_url}}/users"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"X-Powered-By","value":"Express"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Content-Length","value":"110"},{"key":"ETag","value":"W/\"6e-GEzL0S/nhDwVS/gEwIjr5m4Mq2k\""},{"key":"Date","value":"Tue, 23 Jan 2024 16:38:25 GMT"},{"key":"Connection","value":"keep-alive"},{"key":"Keep-Alive","value":"timeout=5"}],"cookie":[],"responseTime":null,"body":"[\n    {\n        \"id\": 1,\n        \"email\": \"test@example.com\",\n        \"role\": \"Admin\"\n    },\n    {\n        \"id\": 2,\n        \"email\": \"customer@example.com\",\n        \"role\": \"Customer\"\n    }\n]"},{"id":"b56f5833-f21b-43d4-a9f6-b76d818f66da","name":"Get Users By Admin Role","originalRequest":{"method":"GET","header":[],"url":{"raw":"{{base_url}}/users?role=Admin","host":["{{base_url}}"],"path":["users"],"query":[{"key":"role","value":"Admin"}]}},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"X-Powered-By","value":"Express"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Content-Length","value":"52"},{"key":"ETag","value":"W/\"34-ZS1CzSzcw23lKRm8f8ddiPPQw3g\""},{"key":"Date","value":"Tue, 23 Jan 2024 16:41:34 GMT"},{"key":"Connection","value":"keep-alive"},{"key":"Keep-Alive","value":"timeout=5"}],"cookie":[],"responseTime":null,"body":"[\n    {\n        \"id\": 1,\n        \"email\": \"test@example.com\",\n        \"role\": \"Admin\"\n    }\n]"},{"id":"4280d59c-d8da-4feb-9684-c11ff1f55d95","name":"Get Users By Customer Role","originalRequest":{"method":"GET","header":[],"url":{"raw":"{{base_url}}/users?role=Customer","host":["{{base_url}}"],"path":["users"],"query":[{"key":"role","value":"Customer"}]}},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"X-Powered-By","value":"Express"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Content-Length","value":"59"},{"key":"ETag","value":"W/\"3b-xWPeoDCjFJ2+9gjej/AjgRA1rAA\""},{"key":"Date","value":"Tue, 23 Jan 2024 16:42:09 GMT"},{"key":"Connection","value":"keep-alive"},{"key":"Keep-Alive","value":"timeout=5"}],"cookie":[],"responseTime":null,"body":"[\n    {\n        \"id\": 2,\n        \"email\": \"customer@example.com\",\n        \"role\": \"Customer\"\n    }\n]"}],"_postman_id":"89e06771-83c2-44bb-9b59-db8f318c01c6"},{"name":"Submit User Input","event":[{"listen":"test","script":{"id":"5475d0b1-7f7a-4a22-8745-a3d845912a1d","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});"],"type":"text/javascript"}}],"id":"03c51ccc-8fcf-4e1c-b18e-eee96af362d9","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{bearer_token}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n  \"companyName\": \"Lincoln Inc.\",\r\n  \"numberOfUsers\": 30,\r\n  \"numberOfProducts\": 80\r\n}","options":{"raw":{"language":"json"}}},"url":"{{base_url}}/users/{{customer_id}}/input","description":"<p>This POST endpoint is used to submit/input user data. It is not restricted to users of the \"Customer\" role alone, as the \"customer_id\" variable in the URL above might make it appear so.</p>\n<p>Requires access token.</p>\n","urlObject":{"path":["users","{{customer_id}}","input"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"3386211a-07cb-4b3d-a0ae-454a8243c5bf","name":"Create User Copy","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\r\n  \"companyName\": \"Robin Inc.\",\r\n  \"numberOfUsers\": 29,\r\n  \"numberOfProducts\": 51\r\n}","options":{"raw":{"language":"json"}}},"url":"{{base_url}}/users/{{customer_id}}}/input"},"status":"Created","code":201,"_postman_previewlanguage":"json","header":[{"key":"X-Powered-By","value":"Express"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Content-Length","value":"179"},{"key":"ETag","value":"W/\"b3-VP6z7ITd4Tcz5XgK7FCdI+MgeBo\""},{"key":"Date","value":"Tue, 23 Jan 2024 16:39:13 GMT"},{"key":"Connection","value":"keep-alive"},{"key":"Keep-Alive","value":"timeout=5"}],"cookie":[],"responseTime":null,"body":"{\n    \"message\": \"Input received.\",\n    \"data\": {\n        \"id\": 3,\n        \"userId\": 2,\n        \"companyName\": \"Robin Inc.\",\n        \"numberOfUsers\": 29,\n        \"numberOfProducts\": 51,\n        \"percentage\": 56,\n        \"createdAt\": \"2024-01-23T16:39:13.039Z\"\n    }\n}"}],"_postman_id":"03c51ccc-8fcf-4e1c-b18e-eee96af362d9"},{"name":"Get Most Recent User Inputs","event":[{"listen":"test","script":{"id":"5475d0b1-7f7a-4a22-8745-a3d845912a1d","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});"],"type":"text/javascript"}}],"id":"3907a404-c65c-4c1f-8e94-abaa131e2b8f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{bearer_token}}"}]},"isInherited":false},"method":"GET","header":[],"body":{"mode":"raw","raw":"","options":{"raw":{"language":"json"}}},"url":"{{base_url}}/users/{{admin_id}}/inputs/{{customer_id}}","description":"<p>This GET endpoint is used to retrieve all recent inputs of a user with the \"Customer\" role. The endpoint is restricted to users with the \"Admin\" role (i.e users with the \"Customer\" role are unauthorised).</p>\n<p>Requires access token.</p>\n","urlObject":{"path":["users","{{admin_id}}","inputs","{{customer_id}}"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"994ebfe3-d81a-4873-8abf-c1acab5263cc","name":"Get Most Recent User Inputs","originalRequest":{"method":"GET","header":[],"url":"{{base_url}}/users/{{id}}/inputs/{{customer_id}}"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"X-Powered-By","value":"Express"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Content-Length","value":"434"},{"key":"ETag","value":"W/\"1b2-Vf8jHu3YPRsxezeKa5CMph2dsrA\""},{"key":"Date","value":"Tue, 23 Jan 2024 16:39:26 GMT"},{"key":"Connection","value":"keep-alive"},{"key":"Keep-Alive","value":"timeout=5"}],"cookie":[],"responseTime":null,"body":"[\n    {\n        \"id\": 3,\n        \"userId\": 2,\n        \"companyName\": \"Robin Inc.\",\n        \"numberOfUsers\": 29,\n        \"numberOfProducts\": 51,\n        \"percentage\": 56,\n        \"createdAt\": \"2024-01-23T16:39:13.039Z\"\n    },\n    {\n        \"id\": 2,\n        \"userId\": 2,\n        \"companyName\": \"BatCave Inc.\",\n        \"numberOfUsers\": 29,\n        \"numberOfProducts\": 51,\n        \"percentage\": 56,\n        \"createdAt\": \"2024-01-23T16:38:52.406Z\"\n    },\n    {\n        \"id\": 1,\n        \"userId\": 2,\n        \"companyName\": \"BatCave Inc.\",\n        \"numberOfUsers\": 25,\n        \"numberOfProducts\": 50,\n        \"percentage\": 50,\n        \"createdAt\": \"2024-01-23T16:38:38.690Z\"\n    }\n]"}],"_postman_id":"3907a404-c65c-4c1f-8e94-abaa131e2b8f"},{"name":"Upload Image File","event":[{"listen":"test","script":{"id":"5475d0b1-7f7a-4a22-8745-a3d845912a1d","exec":["pm.test(\"Status code is 200\", function () {","    pm.response.to.have.status(200);","});"],"type":"text/javascript"}}],"id":"a65d3921-dba2-4999-9a24-3947b1e3f973","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{bearer_token}}"}]},"isInherited":false},"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"targetCustomerUserId","value":"{{customer_id}}","type":"text"},{"key":"imageDescription","value":"Reference Image","type":"text"},{"key":"file","type":"file","fileNotInWorkingDirectoryWarning":"This file isn't in your working directory. Teammates you share this request with won't be able to use this file. To make collaboration easier you can setup your working directory in Settings.","filesNotInWorkingDirectory":["/C:/Users/del/Pictures/Screenshots/Screenshot (3569).png"],"src":"/C:/Users/del/Pictures/Screenshots/Screenshot (3569).png"}]},"url":"{{base_url}}/users/{{admin_id}}/upload","description":"<p>This POST endpoint is used to upload an image to a user with a \"Customer\" role's account. It is restricted only to users with the \"Admin\" role.<br />The data is sent as form-data to the backend.</p>\n<p>Requires access token.</p>\n","urlObject":{"path":["users","{{admin_id}}","upload"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"11df2afb-bf5d-460a-9f09-b4df769fd1eb","name":"Upload Image File","originalRequest":{"method":"POST","header":[],"body":{"mode":"formdata","formdata":[{"key":"targetUserId","value":"2","type":"text"},{"key":"imageDescription","value":"Any Image Desc","type":"text"},{"key":"file","type":"file","src":"/C:/Users/del/Pictures/04.06.2023_01.02.44_REC.png"}]},"url":"{{base_url}}/users/{{id}}/upload"},"status":"Created","code":201,"_postman_previewlanguage":"json","header":[{"key":"X-Powered-By","value":"Express"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Content-Length","value":"299"},{"key":"ETag","value":"W/\"12b-ShZ9UxQimDVs0DmZio4HtZat0Js\""},{"key":"Date","value":"Tue, 23 Jan 2024 16:39:59 GMT"},{"key":"Connection","value":"keep-alive"},{"key":"Keep-Alive","value":"timeout=5"}],"cookie":[],"responseTime":null,"body":"{\n    \"message\": \"Image upload successfull\",\n    \"data\": {\n        \"id\": \"clrql0t2j0000asil2nrtasvc\",\n        \"imageUrl\": \"https://storage.googleapis.com/comms-api.appspot.com/04.06.2023_01.02.44_REC.png\",\n        \"imageDescription\": \"Any Image Desc\",\n        \"targetCustomerUserId\": 2,\n        \"uploaderAdminUserId\": 1,\n        \"uploadedAt\": \"2024-01-23T16:39:59.275Z\"\n    }\n}"}],"_postman_id":"a65d3921-dba2-4999-9a24-3947b1e3f973"},{"name":"Get Uploaded Images (Customer)","id":"66fbe4c5-b853-4af1-be12-31b98ac8973e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"auth":{"type":"bearer","bearer":{"basicConfig":[{"key":"token","value":"{{bearer_token}}"}]},"isInherited":false},"method":"GET","header":[],"url":"{{base_url}}/users/{{customer_id}}/uploads","description":"<p>This GET endpoint is used to retrieve images uploaded to a user's account. It is restricted to users with the 'Customer\" role.</p>\n<p>Requires access token.</p>\n","urlObject":{"path":["users","{{customer_id}}","uploads"],"host":["{{base_url}}"],"query":[],"variable":[]}},"response":[{"id":"fd1ebd3e-f6d5-48c8-a43c-0ae8c0229f32","name":"Get Uploaded Images (Customer)","originalRequest":{"method":"GET","header":[],"url":"{{base_url}}/users/{{customer_id}}/uploads"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Date","value":"Thu, 25 Jan 2024 06:56:15 GMT"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Transfer-Encoding","value":"chunked"},{"key":"Connection","value":"keep-alive"},{"key":"CF-Ray","value":"84ae9d8109de662d-AMS"},{"key":"CF-Cache-Status","value":"DYNAMIC"},{"key":"ETag","value":"W/\"1ee-zuzdFwZOZwYOHFLtjzEG6QEgDoM\""},{"key":"Vary","value":"Accept-Encoding"},{"key":"rndr-id","value":"1cb39a1a-bbcd-40e4"},{"key":"x-powered-by","value":"Express"},{"key":"x-render-origin-server","value":"Render"},{"key":"Server","value":"cloudflare"},{"key":"Content-Encoding","value":"br"},{"key":"alt-svc","value":"h3=\":443\"; ma=86400"}],"cookie":[],"responseTime":null,"body":"[\n    {\n        \"id\": \"clrrr02f50000hih5rl9wgufd\",\n        \"imageUrl\": \"https://storage.googleapis.com/comms-api.appspot.com/Screenshot (3278).png\",\n        \"imageDescription\": \"SpotiStats\",\n        \"targetCustomerUserId\": 1,\n        \"uploaderAdminUserId\": 2,\n        \"uploadedAt\": \"2024-01-24T12:15:08.610Z\"\n    },\n    {\n        \"id\": \"clrsv1d7v00005bfd0otpo5xq\",\n        \"imageUrl\": \"https://storage.googleapis.com/comms-api.appspot.com/Screenshot (3569).png\",\n        \"imageDescription\": \"Reference Image\",\n        \"targetCustomerUserId\": 1,\n        \"uploaderAdminUserId\": 2,\n        \"uploadedAt\": \"2024-01-25T06:55:53.899Z\"\n    }\n]"}],"_postman_id":"66fbe4c5-b853-4af1-be12-31b98ac8973e"}],"event":[{"listen":"prerequest","script":{"id":"6bceceff-8c6a-4165-b9f6-631bf922b624","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d5f79cb8-870a-42a7-a7c4-d31805620f80","type":"text/javascript","exec":[""]}}],"variable":[{"key":"id","value":"{{id}}"},{"key":"base_url","value":"{{base_url}}"},{"key":"customer_id","value":"{{customer_id}}"},{"key":"bearer_token","value":"{{bearer_token}}","type":"string"},{"key":"admin_id","value":"{{admin_id}}"}]}