{
  "openapi": "3.0.1",
  "info": {
    "title": "Webshop API",
    "description": "Webshop service",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://webshop.api.test.snokam.no"
    }
  ],
  "paths": {
    "/v1.1/GetWebshopProducts": {
      "get": {
        "tags": [
          "Webshop"
        ],
        "summary": "Gets webshop products",
        "description": "Retrieves a list of webshop products.",
        "operationId": "GetWebshopProducts",
        "responses": {
          "200": {
            "description": "List of webshop products retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/equipment"
                  }
                }
              }
            },
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.1/GetMyOrders": {
      "get": {
        "tags": [
          "Orders"
        ],
        "summary": "Gets user's orders",
        "description": "Retrieves the orders of the authenticated user.",
        "operationId": "GetMyOrders",
        "responses": {
          "200": {
            "description": "User's orders retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/innerOrder"
                  }
                }
              }
            },
            "x-ms-summary": "Success"
          },
          "401": {
            "description": "User is not authenticated",
            "x-ms-summary": "Unauthorized"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.1/PlaceMyOrder": {
      "post": {
        "tags": [
          "Orders"
        ],
        "summary": "Places an order",
        "description": "Places a new order for the authenticated user.",
        "operationId": "PlaceMyOrder",
        "requestBody": {
          "description": "Order details",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/order"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Order placed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/order"
                }
              }
            },
            "x-ms-summary": "Success"
          },
          "401": {
            "description": "User is not authenticated",
            "x-ms-summary": "Unauthorized"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.1/RemoveMyOrder": {
      "post": {
        "tags": [
          "Orders"
        ],
        "summary": "Removes an order",
        "description": "Removes an order for the authenticated user.",
        "operationId": "RemoveMyOrder",
        "requestBody": {
          "description": "Sanity document ID of the order to remove",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/removeOrder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Order removed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "boolean"
                }
              }
            },
            "x-ms-summary": "Success"
          },
          "401": {
            "description": "User is not authenticated",
            "x-ms-summary": "Unauthorized"
          },
          "500": {
            "description": "Failed to remove order",
            "x-ms-summary": "Internal Server Error"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.1/GetAllOrdersGroupedByEmployee": {
      "get": {
        "tags": [
          "Orders"
        ],
        "summary": "Gets all orders grouped by employee",
        "description": "Retrieves all orders grouped by employee.",
        "operationId": "GetAllOrdersGroupedByEmployee",
        "responses": {
          "200": {
            "description": "Orders grouped by employee retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "$ref": "#/components/schemas/list_adminOrder"
                  }
                }
              }
            },
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.1/GetAllOrdersGroupedByEquipment": {
      "get": {
        "tags": [
          "Orders"
        ],
        "summary": "Gets all orders grouped by equipment",
        "description": "Retrieves all orders grouped by equipment.",
        "operationId": "GetAllOrdersGroupedByEquipment",
        "responses": {
          "200": {
            "description": "Orders grouped by equipment retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": {
                    "$ref": "#/components/schemas/list_adminOrder"
                  }
                }
              }
            },
            "x-ms-summary": "Success"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    },
    "/v1.1/AssignOrdersToEmployees": {
      "post": {
        "tags": [
          "Orders"
        ],
        "summary": "Assigns orders to employees",
        "description": "Assigns orders to employees for the current year.",
        "operationId": "AssignOrdersToEmployees",
        "requestBody": {
          "description": "List of order IDs to assign",
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Orders assigned to employees successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "x-ms-summary": "Success"
          },
          "401": {
            "description": "User is not authenticated",
            "x-ms-summary": "Unauthorized"
          }
        },
        "security": [
          {
            "Implicit": [
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default"
            ]
          },
          {
            "ApiKey": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "adminOrder": {
        "required": [
          "orderId",
          "equipmentId",
          "employee"
        ],
        "type": "object",
        "properties": {
          "orderId": {
            "minLength": 1,
            "type": "string"
          },
          "equipmentId": {
            "minLength": 1,
            "type": "string"
          },
          "employee": {
            "minLength": 1,
            "type": "string"
          },
          "size": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "other": {
            "type": "string"
          },
          "image": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "price": {
            "type": "number",
            "format": "float",
            "nullable": true
          },
          "offeredPrice": {
            "type": "number",
            "format": "float",
            "nullable": true
          },
          "choosenVariant": {
            "$ref": "#/components/schemas/availableVariants"
          },
          "date": {
            "type": "string"
          }
        }
      },
      "availableVariants": {
        "type": "object",
        "properties": {
          "size": {
            "type": "string"
          },
          "inventory": {
            "type": "number",
            "format": "double",
            "nullable": true
          }
        }
      },
      "description": {
        "type": "object",
        "properties": {
          "descriptionChildren": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/descriptionChild"
            }
          },
          "sanityType": {
            "type": "string"
          },
          "sanityKey": {
            "type": "string"
          }
        }
      },
      "descriptionChild": {
        "type": "object",
        "properties": {
          "marks": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "text": {
            "type": "string"
          },
          "sanityType": {
            "type": "string"
          },
          "sanityKey": {
            "type": "string"
          }
        }
      },
      "employee": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "startDate": {
            "type": "string"
          },
          "ownership": {
            "type": "number",
            "format": "float",
            "nullable": true
          },
          "boardMember": {
            "type": "boolean",
            "nullable": true
          },
          "imageUrl": {
            "type": "string"
          }
        }
      },
      "equipment": {
        "type": "object",
        "properties": {
          "sanityId": {
            "type": "string"
          },
          "sanityType": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "date": {
            "type": "string"
          },
          "available": {
            "type": "boolean",
            "nullable": true
          },
          "availableSex": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "availableVariants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/variant"
            }
          },
          "price": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "offeredPrice": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "descriptions": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/description"
            }
          },
          "images": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/image"
            }
          }
        }
      },
      "image": {
        "type": "object",
        "properties": {
          "sanityType": {
            "type": "string"
          },
          "sanityKey": {
            "type": "string"
          },
          "asset": {
            "$ref": "#/components/schemas/imageAsset"
          }
        }
      },
      "imageAsset": {
        "type": "object",
        "properties": {
          "sanityType": {
            "type": "string"
          },
          "mimeType": {
            "type": "string"
          },
          "originalFilename": {
            "type": "string"
          },
          "url": {
            "type": "string"
          }
        }
      },
      "innerOrder": {
        "required": [
          "equipmentId"
        ],
        "type": "object",
        "properties": {
          "sanityId": {
            "type": "string"
          },
          "equipmentId": {
            "minLength": 1,
            "type": "string"
          },
          "size": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "other": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "employee": {
            "$ref": "#/components/schemas/employee"
          }
        }
      },
      "list_adminOrder": {
        "type": "array",
        "items": {
          "$ref": "#/components/schemas/adminOrder"
        }
      },
      "order": {
        "required": [
          "equipmentId",
          "size",
          "kind",
          "other",
          "quantity"
        ],
        "type": "object",
        "properties": {
          "equipmentId": {
            "minLength": 1,
            "type": "string",
            "description": "Equipment uuid"
          },
          "size": {
            "minLength": 1,
            "type": "string"
          },
          "kind": {
            "minLength": 1,
            "type": "string"
          },
          "other": {
            "minLength": 1,
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        }
      },
      "removeOrder": {
        "required": [
          "orderId"
        ],
        "type": "object",
        "properties": {
          "orderId": {
            "minLength": 1,
            "type": "string"
          }
        }
      },
      "variant": {
        "type": "object",
        "properties": {
          "size": {
            "type": "string"
          },
          "inventory": {
            "type": "number",
            "format": "double"
          }
        }
      }
    },
    "securitySchemes": {
      "Implicit": {
        "type": "oauth2",
        "flows": {
          "implicit": {
            "authorizationUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize",
            "tokenUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token",
            "refreshUrl": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token",
            "scopes": {
              "api://b2c47b20-df4a-49b5-a7ee-87f3647ab227/.default": "Default function scope"
            }
          }
        }
      },
      "ApiKey": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  }
}