{"info":{"_postman_id":"87fb8b41-536e-4aae-9653-62a69b33ced7","name":"Dynamic mock","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json"},"item":[{"name":"Set Initial Data","event":[{"listen":"prerequest","script":{"id":"8bb3e395-7c08-4993-93bc-af9226d33e22","exec":["var products = [\r","\t{\r","\t\t\"Id\": 1,\r","\t\t\"Name\": \"Product mock 1\",\r","\t\t\"Price\": 24.5,\r","\t\t\"Currency\": {\r","\t\t\t\"Code\": \"USD\",\r","\t\t\t\"ExchangeRatePLN\": 3.8\r","\t\t}\r","\t},\r","\t{\r","\t\t\"Id\": 2,\r","\t\t\"Name\": \"Product mock 2\",\r","\t\t\"Price\": 137.9,\r","\t\t\"Currency\": {\r","\t\t\t\"Code\": \"USD\",\r","\t\t\t\"ExchangeRatePLN\": 3.95\r","\t\t}\r","\t},\r","    {\r","\t\t\"Id\": 3,\r","\t\t\"Name\": \"Product mock 3\",\r","\t\t\"Price\": 58.4,\r","\t\t\"Currency\": {\r","\t\t\t\"Code\": \"USD\",\r","\t\t\t\"ExchangeRatePLN\": 3.76\r","\t\t}\r","\t}\r","];\r","\r","pm.environment.set(\"ProductList\", JSON.stringify(products));\r","pm.environment.set(\"ProductIndex\", 3);\r","pm.environment.set(\"ProductId\", 3);"],"type":"text/javascript"}}],"id":"301a17be-cc52-4831-81c7-372288143fc5","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PURGE","header":[],"url":"https://d34ffff1-a4d1-48cb-ac82-8de84b63562e.mock.pstmn.io"},"response":[{"id":"04ff72d8-06b3-42c7-a991-2655e69ab4a5","name":"Set Initial Data","originalRequest":{"method":"PURGE","header":[],"url":"https://d34ffff1-a4d1-48cb-ac82-8de84b63562e.mock.pstmn.io"},"status":"No Content","code":204,"_postman_previewlanguage":"json","header":[{"key":"Access-Control-Allow-Origin","value":"*"},{"key":"Content-Encoding","value":"gzip"},{"key":"Content-Type","value":"application/json; charset=utf-8"},{"key":"Date","value":"Wed, 15 Jan 2020 13:22:47 GMT"},{"key":"ETag","value":"W/\"96-TmaW8mJnRKK42sZor5CoHUxYs00\""},{"key":"Server","value":"nginx"},{"key":"Vary","value":"Accept-Encoding"},{"key":"x-srv-span","value":"v=1;s=ab2f30eb94535c74"},{"key":"x-srv-trace","value":"v=1;t=838ea49fdb4c7cbb"},{"key":"Content-Length","value":"135"},{"key":"Connection","value":"keep-alive"}],"cookie":[],"responseTime":null,"body":"{\n    \"info\": \"Mock data has been reset..\"\n}"}],"_postman_id":"301a17be-cc52-4831-81c7-372288143fc5"},{"name":"Products list","event":[{"listen":"test","script":{"id":"2ecda3f7-bbd6-47e9-9e5d-64336cba2ae1","exec":[""],"type":"text/javascript"}}],"id":"b8899969-312e-4ea8-aa4a-b179d19cbc11","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"https://d34ffff1-a4d1-48cb-ac82-8de84b63562e.mock.pstmn.io/api/Products"},"response":[{"id":"ccbcd139-eee2-4e2c-aa32-39ffa94999c2","name":"Products list","originalRequest":{"method":"GET","header":[],"url":"https://localhost:5000/api/Products"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json","description":"","type":"text"}],"cookie":[],"responseTime":null,"body":"{{ProductList}}"}],"_postman_id":"b8899969-312e-4ea8-aa4a-b179d19cbc11"},{"name":"Product By Id","event":[{"listen":"prerequest","script":{"id":"3189a8bd-c5b6-4e0d-b5ba-799c20236e99","exec":["var min = 1;","var max = parseInt(pm.environment.get(\"ProductIndex\"), 10);","var id = Math.floor(Math.random() * (max - min)) + min;","// Set ProductId value","pm.environment.set(\"ProductId\", id);"],"type":"text/javascript"}},{"listen":"test","script":{"id":"2b4bb458-c0b5-4367-9b4b-e05edcb735f9","exec":["var body = JSON.parse(responseBody);","console.log(body);","pm.environment.set(\"SingleProduct\", responseBody);"],"type":"text/javascript"}}],"id":"6ccada0e-a49d-4f48-88be-177f29bddd57","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"https://d34ffff1-a4d1-48cb-ac82-8de84b63562e.mock.pstmn.io/api/Product/{{ProductId}}"},"response":[{"id":"6a3daffb-ef56-4975-aff5-84315f510ccf","name":"Product By Id = 1","originalRequest":{"method":"GET","header":[],"url":"https://localhost:5000/api/Product/1"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":null,"cookie":[],"responseTime":null,"body":"{\n    \"Id\": 1,\n    \"Name\": \"Product mock 1\",\n    \"Price\": 24.5,\n    \"Currency\": {\n        \"Code\": \"USD\",\n        \"ExchangeRatePLN\": 3.8\n    }\n}"},{"id":"b163b05a-661b-4902-afc1-175c1a73310a","name":"Product By Id = 3","originalRequest":{"method":"GET","header":[],"url":"https://localhost:5000/api/Product/3"},"_postman_previewlanguage":"json","header":null,"cookie":[],"responseTime":null,"body":"{\n    \"Id\": 3,\n    \"Name\": \"Product mock 3\",\n    \"Price\": 58.4,\n    \"Currency\": {\n        \"Code\": \"USD\",\n        \"ExchangeRatePLN\": 3.76\n    }\n}"},{"id":"c296700a-26ba-494a-ab99-759cac1079b2","name":"Product By Id = 2","originalRequest":{"method":"GET","header":[],"url":"https://localhost:5000/api/Product/2"},"_postman_previewlanguage":"json","header":null,"cookie":[],"responseTime":null,"body":"{\n    \"Id\": 2,\n    \"Name\": \"Product mock 2\",\n    \"Price\": 137.9,\n    \"Currency\": {\n        \"Code\": \"USD\",\n        \"ExchangeRatePLN\": 3.95\n    }\n}"}],"_postman_id":"6ccada0e-a49d-4f48-88be-177f29bddd57"},{"name":"Update product","event":[{"listen":"prerequest","script":{"id":"af3dd129-136b-4dde-aa1a-070868239c45","exec":["var product = JSON.parse(pm.environment.get(\"SingleProduct\"));","var productId = pm.environment.get(\"ProductId\");","","product.Name = `Product ${productId} updated`;","pm.environment.set(\"SingleProduct\", JSON.stringify(product));","","var products = JSON.parse(pm.environment.get(\"ProductList\")); ","","products[productId-1] = product;","pm.environment.set(\"ProductList\", JSON.stringify(products));",""],"type":"text/javascript"}}],"id":"8f028ba3-feda-4b9e-8551-0c491208d435","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"PUT","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{{SingleProduct}}"},"url":"https://d34ffff1-a4d1-48cb-ac82-8de84b63562e.mock.pstmn.io/api/Product/{{ProductId}}"},"response":[{"id":"37f8ba19-34d6-4d5c-b873-657f60bf278e","name":"Update product","originalRequest":{"method":"PUT","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{{SingleProduct}}","options":{"raw":{"language":"json"}}},"url":"https://localhost:5000/api/Product/{{ProductId}}"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":null,"cookie":[],"responseTime":null,"body":""}],"_postman_id":"8f028ba3-feda-4b9e-8551-0c491208d435"},{"name":"Create Product","event":[{"listen":"prerequest","script":{"id":"d0d79703-3177-485b-ab23-dbe754f6942d","exec":["var id = parseInt(pm.environment.get(\"ProductIndex\"), 10) + 1;","pm.environment.set(\"ProductIndex\", id);",""],"type":"text/javascript"}},{"listen":"test","script":{"id":"96f41523-d36d-4e22-ab42-16b11d755f29","exec":["var product = JSON.parse(pm.request.body.raw);","var products = JSON.parse(pm.environment.get(\"ProductList\")); ","products.push(product);","pm.environment.set(\"SingleProduct\", JSON.stringify(product));","pm.environment.set(\"ProductId\", product.Id);","pm.environment.set(\"ProductList\", JSON.stringify(products));"],"type":"text/javascript"}}],"id":"77d0d142-9ee8-43d6-960e-a9aa3908cc65","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","name":"Content-Type","value":"application/json","type":"text"}],"body":{"mode":"raw","raw":"{\n\t\"Id\": {{ProductIndex}},\n\t\"Name\": \"{{$randomProductName}}\",\n\t\"Price\": {{$randomPrice}},\n\t\"Currency\": {\n\t\t\"Code\": \"USD\",\n\t\t\"ExchangeRatePLN\": 3.8\n\t}\n}"},"url":"https://d34ffff1-a4d1-48cb-ac82-8de84b63562e.mock.pstmn.io/api/Product/"},"response":[{"id":"070b31b7-dbe7-4fd5-a989-0bfe4260c76a","name":"Created","originalRequest":{"method":"POST","header":[],"url":"https://localhost:5000/api/Product/1"},"status":"Created","code":201,"_postman_previewlanguage":"json","header":null,"cookie":[],"responseTime":null,"body":""}],"_postman_id":"77d0d142-9ee8-43d6-960e-a9aa3908cc65"}],"event":[{"listen":"prerequest","script":{"id":"73bb0929-a615-45cb-bf9e-38202bf315fc","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"b476b42a-835f-424b-b3cb-1a3e721dc52a","type":"text/javascript","exec":[""]}}]}