{"info":{"_postman_id":"4cc0a289-5263-4888-bf28-2fc067e0e789","name":"Unkle Api Exercise","description":"<html><head></head><body><h1 id=\"introduction\">Introduction</h1>\n<p>Test Backend for Unkle interview. </p>\n<h1 id=\"overview\">Overview</h1>\n<ul>\n<li>This REST Api handles different types of users (clients, and administrators) managing insurance contracts.</li>\n<li>When testing this API (I recommend through Postman), make sure Headers are set to 'Content-type: application/json'</li>\n</ul>\n<h1 id=\"authentication\">Authentication</h1>\n<p>Since this API is quite simple in its own way of working, authentification and authorization are not secured as it should be.\nThough and except for registration, routes require either to be authentificated as an administrator or a client.\nThis can be achieved by adding in the body request the pair (mail, password) as following:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>\"user\": {\n    \"email\": \"your_registered_email\",\n    \"password: \"your_password\"\n}\n\n</code></pre><h1 id=\"error-codes\">Error Codes</h1>\n<p>Error codes and messages can be summed up and paired as the following:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code>{\n    code: 501,\n    message: \"no client or option or starting date for the contract\"\n},\n\n{\n    code: 501\n    message: \"all clients and options have to be registered in database\"\n},\n\n\n{\n    code: 500,\n    message: \"failed to create new user\"\n},\n{\n    code: 500,\n    message: \"failed to fetch contracts\"\n},\n{\n    code: 500,\n    message: \"failed to create new option\"\"\n},\n{\n    code: 500,\n    message: \"failed to update contract\"\n},\n\n\n{\n    code: 403,\n    message: \"forbidden\"\n},\n\n\n{\n    code: 401,\n    message: \"user doesn't exist or wrong password\"\n},\n\n\n{\n    code: 400,\n    message: \"both name and description are required\"\n},\n{\n    code: 400\n    message: \"ending date has passed\"\n},\n</code></pre><h1 id=\"rate-limit\">Rate limit</h1>\n<p>Since this API is meant to run on your local machine, the only limit here is the sky, your bandwith and your computer ressources.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Introduction","slug":"introduction"},{"content":"Overview","slug":"overview"},{"content":"Authentication","slug":"authentication"},{"content":"Error Codes","slug":"error-codes"},{"content":"Rate limit","slug":"rate-limit"}],"owner":"13245077","collectionId":"4cc0a289-5263-4888-bf28-2fc067e0e789","publishedId":"TzJsfxoZ","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2021-04-19T02:55:23.000Z"},"item":[{"name":"Register a user","id":"73f468f0-0027-4b9e-ac17-4585d3a7e072","protocolProfileBehavior":{"disableBodyPruning":true,"disabledSystemHeaders":{"host":true,"user-agent":true,"accept-encoding":true,"connection":true,"accept":true}},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"_comment\": \"role is optional if different than 2. 2 means admin role\",\n    \"user\": {\n        \"name\": \"username\",\n        \"email\": \"usermail@domain\",\n        \"password\": \"userpassword\",\n        \"role\": \"2\" \n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/user/register","urlObject":{"protocol":"http","port":"5000","path":["user","register"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"73f468f0-0027-4b9e-ac17-4585d3a7e072"},{"name":"(client) get contracts","id":"a152f78d-0645-465b-91da-039e67837faf","protocolProfileBehavior":{"disableBodyPruning":true,"disabledSystemHeaders":{"connection":true,"accept":true,"accept-encoding":true,"user-agent":true,"host":true}},"request":{"method":"GET","header":[],"body":{"mode":"raw","raw":"{\n    \"user\":{\n        \"email\": \"gordon@mail.com\",\n        \"password\": \"gordon\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/client/contracts","description":"<p>Fetches all contracts related to an authentificated client.</p>\n","urlObject":{"protocol":"http","port":"5000","path":["client","contracts"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"a152f78d-0645-465b-91da-039e67837faf"},{"name":"(admin) Get all contracts","id":"8fb19dbc-a308-4827-93bc-f5d99ce14ce3","protocolProfileBehavior":{"disableBodyPruning":true,"disabledSystemHeaders":{"accept":true,"accept-encoding":true,"connection":true,"user-agent":true,"host":true}},"request":{"method":"GET","header":[],"body":{"mode":"raw","raw":"{\n    \"user\": {\n        \"email\": \"admin@mail.com\",\n        \"password\": \"admin\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/admin/contracts","description":"<p>Fetches all contracts in database.</p>\n","urlObject":{"protocol":"http","port":"5000","path":["admin","contracts"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"8fb19dbc-a308-4827-93bc-f5d99ce14ce3"},{"name":"(admin) Create contract","id":"a74b322f-781e-4540-9907-9b6b983313f2","protocolProfileBehavior":{"disableBodyPruning":true,"disabledSystemHeaders":{"host":true,"user-agent":true,"connection":true,"accept-encoding":true,"accept":true}},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"_comment\": \"endDate field can be omitted\",\n    \"user\": {\n        \"email\": \"admin@mail.com\",\n        \"password\": \"admin\"\n    },\n    \"contract\":{\n        \"startDate\": \"2022-01-01\", \n        \"endDate\": \"2023-01-01\", \n        \"options\": [{\"name\": \"vol\"}], \n        \"clients\": [{\"email\": \"gordon@mail.com\"}]\n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/admin/create","description":"<p>Creates a new contract.</p>\n","urlObject":{"protocol":"http","port":"5000","path":["admin","create"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"a74b322f-781e-4540-9907-9b6b983313f2"},{"name":"(admin) Add new option","id":"0e17acf8-1d82-4202-87e5-b76a7f6cb3bf","protocolProfileBehavior":{"disableBodyPruning":true,"disabledSystemHeaders":{"user-agent":true,"host":true,"accept-encoding":true,"connection":true,"accept":true}},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"user\": {\n        \"email\": \"admin@mail.com\",\n        \"password\": \"admin\"\n    },\n    \"option\": {\n        \"name\": \"mariage\",\n        \"description\": \"Scelle votre amour à double-tour.\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/admin/option","description":"<p>Creates a new option in the database.</p>\n","urlObject":{"protocol":"http","port":"5000","path":["admin","option"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"0e17acf8-1d82-4202-87e5-b76a7f6cb3bf"},{"name":"(client) Cancel contract","id":"243055e3-ad3d-42d1-8cf3-9cd7db701f8e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PUT","header":[],"body":{"mode":"raw","raw":"{\n    \"user\": {\n        \"email\": \"gordon@mail.com\",\n        \"password\": \"gordon\"\n    },\n    \"contract\": {\n        \"contractId\": 1,\n        \"endDate\": \"2040-05-10\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/client/contract","description":"<p>Updates an authentificated client's contract through its ending date.</p>\n","urlObject":{"protocol":"http","port":"5000","path":["client","contract"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"243055e3-ad3d-42d1-8cf3-9cd7db701f8e"},{"name":"(admin) Cancel contract","id":"3cfefa10-0883-4215-8e1d-f8b3975a80a7","protocolProfileBehavior":{"disableBodyPruning":true,"disabledSystemHeaders":{"connection":true,"accept-encoding":true,"accept":true,"user-agent":true,"host":true}},"request":{"method":"PUT","header":[],"body":{"mode":"raw","raw":"{\n    \"user\": {\n        \"email\": \"admin@mail.com\",\n        \"password\": \"admin\"\n    },\n    \"contract\": {\n        \"contractId\": 1,\n        \"endDate\": \"2055-01-01\"\n    }\n}","options":{"raw":{"language":"json"}}},"url":"http://localhost:5000/admin/contract","description":"<p>Updates a client's contract through its ending date.</p>\n","urlObject":{"protocol":"http","port":"5000","path":["admin","contract"],"host":["localhost"],"query":[],"variable":[]}},"response":[],"_postman_id":"3cfefa10-0883-4215-8e1d-f8b3975a80a7"}]}