{
  "info": {
    "_postman_id": "5b1e7c2a-94d4-4c1a-9e3b-0a9f4c7d2e14",
    "name": "Store API",
    "description": "Sample Postman collection for the Shift-Left API sandbox store (https://demo.totalshiftleft.ai). Made for Learning Center lesson 9.4: three folders, eight requests, six of them with pm.test scripts.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://demo.totalshiftleft.ai",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Products",
      "item": [
        {
          "name": "List products",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Returns a list of products\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.data).to.be.an(\"array\");",
                  "});",
                  "",
                  "pm.test(\"Responds in under 2 seconds\", function () {",
                  "    pm.expect(pm.response.responseTime).to.be.below(2000);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/products?limit=10",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "products"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "10"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "Get a product that doesn't exist",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status is 404\", function () {",
                  "    pm.response.to.have.status(404);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/products/:id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "products",
                ":id"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "00000000-0000-0000-0000-000000000000"
                }
              ]
            }
          },
          "response": []
        },
        {
          "name": "Get a product by ID",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Returns the wireless mouse\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.data.name).to.eql(\"Wireless Mouse\");",
                  "    pm.expect(json.data.price).to.be.a(\"number\");",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/products/:id",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "products",
                ":id"
              ],
              "variable": [
                {
                  "key": "id",
                  "value": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
                }
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Users",
      "item": [
        {
          "name": "Create a user without an email",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status is 400\", function () {",
                  "    pm.response.to.have.status(400);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Grace Hopper\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/v1/users",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "users"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Create a user",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status is 201\", function () {",
                  "    pm.response.to.have.status(201);",
                  "});",
                  "",
                  "const json = pm.response.json();",
                  "pm.test(\"Saves the email\", function () {",
                  "    pm.expect(json.data.email).to.eql(\"ada@example.com\");",
                  "});",
                  "",
                  "pm.environment.set(\"userId\", json.data.id);"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"name\": \"Ada Lovelace\",\n  \"email\": \"ada@example.com\",\n  \"role\": \"user\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/v1/users",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "users"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Get the new user",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Returns the user we created\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.data.email).to.eql(\"ada@example.com\");",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/users/{{userId}}",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "users",
                "{{userId}}"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Orders",
      "item": [
        {
          "name": "List orders",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/api/v1/orders",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "orders"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Create an order",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"user_id\": \"{{userId}}\",\n  \"product_id\": \"aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa\",\n  \"quantity\": 2\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/v1/orders",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "v1",
                "orders"
              ]
            }
          },
          "response": []
        }
      ]
    }
  ]
}