Last active
August 8, 2024 07:25
-
-
Save encikpulasan/146c75bd7ede529ccb07d7216261f4a1 to your computer and use it in GitHub Desktop.
Collection of Procurement API request
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "info": { | |
| "_postman_id": "your-postman-id", | |
| "name": "Procurement API", | |
| "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" | |
| }, | |
| "variable": [ | |
| { | |
| "key": "base_url", | |
| "value": "http://localhost:3000" | |
| }, | |
| { | |
| "key": "client_token", | |
| "value": "" | |
| }, | |
| { | |
| "key": "vendor_token", | |
| "value": "" | |
| }, | |
| { | |
| "key": "project_id", | |
| "value": "" | |
| }, | |
| { | |
| "key": "procurement_id", | |
| "value": "" | |
| } | |
| ], | |
| "item": [ | |
| { | |
| "name": "User Management", | |
| "item": [ | |
| { | |
| "name": "Register Client", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 201\", function () {", | |
| " pm.response.to.have.status(201);", | |
| "});", | |
| "", | |
| "pm.test(\"User created successfully\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData.message).to.eql(\"User created successfully\");", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "method": "POST", | |
| "header": [], | |
| "body": { | |
| "mode": "raw", | |
| "raw": "{\n \"email\": \"client@example.com\",\n \"password\": \"password123\",\n \"userType\": \"client\"\n}", | |
| "options": { | |
| "raw": { | |
| "language": "json" | |
| } | |
| } | |
| }, | |
| "url": { | |
| "raw": "{{base_url}}/register", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "register" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Register Vendor", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 201\", function () {", | |
| " pm.response.to.have.status(201);", | |
| "});", | |
| "", | |
| "pm.test(\"User created successfully\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData.message).to.eql(\"User created successfully\");", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "method": "POST", | |
| "header": [], | |
| "body": { | |
| "mode": "raw", | |
| "raw": "{\n \"email\": \"vendor@example.com\",\n \"password\": \"password123\",\n \"userType\": \"vendor\"\n}", | |
| "options": { | |
| "raw": { | |
| "language": "json" | |
| } | |
| } | |
| }, | |
| "url": { | |
| "raw": "{{base_url}}/register", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "register" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Login Client", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 200\", function () {", | |
| " pm.response.to.have.status(200);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains access token\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData.accessToken).to.be.a('string');", | |
| " pm.collectionVariables.set(\"client_token\", jsonData.accessToken);", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "method": "POST", | |
| "header": [], | |
| "body": { | |
| "mode": "raw", | |
| "raw": "{\n \"email\": \"client@example.com\",\n \"password\": \"password123\"\n}", | |
| "options": { | |
| "raw": { | |
| "language": "json" | |
| } | |
| } | |
| }, | |
| "url": { | |
| "raw": "{{base_url}}/login", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "login" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Login Vendor", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 200\", function () {", | |
| " pm.response.to.have.status(200);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains access token\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData.accessToken).to.be.a('string');", | |
| " pm.collectionVariables.set(\"vendor_token\", jsonData.accessToken);", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "method": "POST", | |
| "header": [], | |
| "body": { | |
| "mode": "raw", | |
| "raw": "{\n \"email\": \"vendor@example.com\",\n \"password\": \"password123\"\n}", | |
| "options": { | |
| "raw": { | |
| "language": "json" | |
| } | |
| } | |
| }, | |
| "url": { | |
| "raw": "{{base_url}}/login", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "login" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| } | |
| ] | |
| }, | |
| { | |
| "name": "Project Management", | |
| "item": [ | |
| { | |
| "name": "Create Project", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 201\", function () {", | |
| " pm.response.to.have.status(201);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains project details\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData.id).to.be.a('string');", | |
| " pm.expect(jsonData.name).to.eql(\"Test Project\");", | |
| " pm.collectionVariables.set(\"project_id\", jsonData.id);", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "auth": { | |
| "type": "bearer", | |
| "bearer": [ | |
| { | |
| "key": "token", | |
| "value": "{{client_token}}", | |
| "type": "string" | |
| } | |
| ] | |
| }, | |
| "method": "POST", | |
| "header": [], | |
| "body": { | |
| "mode": "raw", | |
| "raw": "{\n \"name\": \"Test Project\",\n \"description\": \"This is a test project\"\n}", | |
| "options": { | |
| "raw": { | |
| "language": "json" | |
| } | |
| } | |
| }, | |
| "url": { | |
| "raw": "{{base_url}}/projects", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "projects" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Get Projects List", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 200\", function () {", | |
| " pm.response.to.have.status(200);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains projects array\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData).to.be.an('array');", | |
| " pm.expect(jsonData.length).to.be.at.least(1);", | |
| "});", | |
| "", | |
| "pm.test(\"Projects have correct structure\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " if (jsonData.length > 0) {", | |
| " pm.expect(jsonData[0]).to.have.property('id');", | |
| " pm.expect(jsonData[0]).to.have.property('name');", | |
| " pm.expect(jsonData[0]).to.have.property('description');", | |
| " pm.expect(jsonData[0]).to.have.property('clientId');", | |
| " pm.expect(jsonData[0]).to.have.property('createdAt');", | |
| " }", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "auth": { | |
| "type": "bearer", | |
| "bearer": [ | |
| { | |
| "key": "token", | |
| "value": "{{client_token}}", | |
| "type": "string" | |
| } | |
| ] | |
| }, | |
| "method": "GET", | |
| "header": [], | |
| "url": { | |
| "raw": "{{base_url}}/projects", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "projects" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| } | |
| ] | |
| }, | |
| { | |
| "name": "Procurement Management", | |
| "item": [ | |
| { | |
| "name": "Submit Procurement", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 201\", function () {", | |
| " pm.response.to.have.status(201);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains procurement details\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData.id).to.be.a('string');", | |
| " pm.expect(jsonData.title).to.eql(\"Test Procurement\");", | |
| " pm.collectionVariables.set(\"procurement_id\", jsonData.id);", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "auth": { | |
| "type": "bearer", | |
| "bearer": [ | |
| { | |
| "key": "token", | |
| "value": "{{vendor_token}}", | |
| "type": "string" | |
| } | |
| ] | |
| }, | |
| "method": "POST", | |
| "header": [], | |
| "body": { | |
| "mode": "formdata", | |
| "formdata": [ | |
| { | |
| "key": "title", | |
| "value": "Test Procurement", | |
| "type": "text" | |
| }, | |
| { | |
| "key": "description", | |
| "value": "This is a test procurement", | |
| "type": "text" | |
| }, | |
| { | |
| "key": "amount", | |
| "value": "1000", | |
| "type": "text" | |
| }, | |
| { | |
| "key": "projectId", | |
| "value": "{{project_id}}", | |
| "type": "text" | |
| }, | |
| { | |
| "key": "pdf", | |
| "type": "file", | |
| "src": "/path/to/your/test.pdf" | |
| } | |
| ] | |
| }, | |
| "url": { | |
| "raw": "{{base_url}}/procurements", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "procurements" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Get Project Procurements", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 200\", function () {", | |
| " pm.response.to.have.status(200);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains procurements array\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData).to.be.an('array');", | |
| " pm.expect(jsonData.length).to.be.at.least(1);", | |
| "});", | |
| "", | |
| "pm.test(\"Procurements have correct structure\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " if (jsonData.length > 0) {", | |
| " pm.expect(jsonData[0]).to.have.property('id');", | |
| " pm.expect(jsonData[0]).to.have.property('title');", | |
| " pm.expect(jsonData[0]).to.have.property('description');", | |
| " pm.expect(jsonData[0]).to.have.property('amount');", | |
| " pm.expect(jsonData[0]).to.have.property('vendorId');", | |
| " pm.expect(jsonData[0]).to.have.property('projectId');", | |
| " }", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "auth": { | |
| "type": "bearer", | |
| "bearer": [ | |
| { | |
| "key": "token", | |
| "value": "{{client_token}}", | |
| "type": "string" | |
| } | |
| ] | |
| }, | |
| "method": "GET", | |
| "header": [], | |
| "url": { | |
| "raw": "{{base_url}}/projects/{{project_id}}/procurements", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "projects", | |
| "{{project_id}}", | |
| "procurements" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Get Vendor Procurements", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 200\", function () {", | |
| " pm.response.to.have.status(200);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains procurements array\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData).to.be.an('array');", | |
| "});", | |
| "", | |
| "pm.test(\"Procurements have correct structure\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " if (jsonData.length > 0) {", | |
| " pm.expect(jsonData[0]).to.have.property('id');", | |
| " pm.expect(jsonData[0]).to.have.property('title');", | |
| " pm.expect(jsonData[0]).to.have.property('description');", | |
| " pm.expect(jsonData[0]).to.have.property('amount');", | |
| " pm.expect(jsonData[0]).to.have.property('projectId');", | |
| " }", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "auth": { | |
| "type": "bearer", | |
| "bearer": [ | |
| { | |
| "key": "token", | |
| "value": "{{vendor_token}}", | |
| "type": "string" | |
| } | |
| ] | |
| }, | |
| "method": "GET", | |
| "header": [], | |
| "url": { | |
| "raw": "{{base_url}}/vendor/procurements", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "vendor", | |
| "procurements" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Update Procurement", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 200\", function () {", | |
| " pm.response.to.have.status(200);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains updated procurement details\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData.id).to.eql(pm.collectionVariables.get(\"procurement_id\"));", | |
| " pm.expect(jsonData.title).to.eql(\"Updated Test Procurement\");", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "auth": { | |
| "type": "bearer", | |
| "bearer": [ | |
| { | |
| "key": "token", | |
| "value": "{{vendor_token}}", | |
| "type": "string" | |
| } | |
| ] | |
| }, | |
| "method": "PUT", | |
| "header": [], | |
| "body": { | |
| "mode": "raw", | |
| "raw": "{\n \"title\": \"Updated Test Procurement\",\n \"description\": \"This is an updated test procurement\",\n \"amount\": 1500\n}", | |
| "options": { | |
| "raw": { | |
| "language": "json" | |
| } | |
| } | |
| }, | |
| "url": { | |
| "raw": "{{base_url}}/procurements/{{procurement_id}}", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "procurements", | |
| "{{procurement_id}}" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Search Procurements", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 200\", function () {", | |
| " pm.response.to.have.status(200);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains procurements array\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData).to.be.an('array');", | |
| "});", | |
| "", | |
| "pm.test(\"Procurements match search criteria\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " jsonData.forEach(function(procurement) {", | |
| " pm.expect(procurement.title.toLowerCase()).to.include('test');", | |
| " });", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "auth": { | |
| "type": "bearer", | |
| "bearer": [ | |
| { | |
| "key": "token", | |
| "value": "{{client_token}}", | |
| "type": "string" | |
| } | |
| ] | |
| }, | |
| "method": "GET", | |
| "header": [], | |
| "url": { | |
| "raw": "{{base_url}}/procurements/search?query=test&status=available", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "procurements", | |
| "search" | |
| ], | |
| "query": [ | |
| { | |
| "key": "query", | |
| "value": "test" | |
| }, | |
| { | |
| "key": "status", | |
| "value": "available" | |
| } | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| }, | |
| { | |
| "name": "Add Comment", | |
| "event": [ | |
| { | |
| "listen": "test", | |
| "script": { | |
| "exec": [ | |
| "pm.test(\"Status code is 201\", function () {", | |
| " pm.response.to.have.status(201);", | |
| "});", | |
| "", | |
| "pm.test(\"Body contains comment details\", function () {", | |
| " var jsonData = pm.response.json();", | |
| " pm.expect(jsonData.id).to.be.a('string');", | |
| " pm.expect(jsonData.text).to.eql(\"This is a test comment\");", | |
| "});" | |
| ], | |
| "type": "text/javascript" | |
| } | |
| } | |
| ], | |
| "request": { | |
| "auth": { | |
| "type": "bearer", | |
| "bearer": [ | |
| { | |
| "key": "token", | |
| "value": "{{client_token}}", | |
| "type": "string" | |
| } | |
| ] | |
| }, | |
| "method": "POST", | |
| "header": [], | |
| "body": { | |
| "mode": "raw", | |
| "raw": "{\n \"text\": \"This is a test comment\"\n}", | |
| "options": { | |
| "raw": { | |
| "language": "json" | |
| } | |
| } | |
| }, | |
| "url": { | |
| "raw": "{{base_url}}/procurements/{{procurement_id}}/comments", | |
| "host": [ | |
| "{{base_url}}" | |
| ], | |
| "path": [ | |
| "procurements", | |
| "{{procurement_id}}", | |
| "comments" | |
| ] | |
| } | |
| }, | |
| "response": [] | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment