{
  "openapi": "3.0.0",
  "info": {
    "title": "Server API - 7GEN",
    "version": "1.0.0",
    "description": "API Documentation",
    "contact": {
      "name": "Pete Devine",
      "email": "peter@skyou.com"
    }
  },
  "servers": [
    {
      "url": "https://snugz.skyoudt.com",
      "description": "Production server"
    }
  ],
  "paths": {
    "/clients/newprojectdesign/{ext_id}/{sku}": {
      "get": {
        "summary": "Open Design Tool ready for new design, based on product SKU and project external ID",
        "description": "Opens the Design Tool with a specific product ready to be designed for a given project",
        "tags": [
          "Design Tool"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "ext_id",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "External project identifier"
          },
          {
            "in": "path",
            "name": "sku",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Product SKU to be designed"
          }
        ],
        "responses": {
          "200": {
            "description": "Design Tool view rendered successfully",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or product not associated with project",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Product not associated with project"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Project or product not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Project not found"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Database error"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/clients/editDesign/{design_id}": {
      "get": {
        "summary": "Open Design Tool to edit existing design",
        "description": "Opens the Design Tool to edit a specific design associated with a project",
        "tags": [
          "Design Tool"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "design_id",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID of the design to edit (from listdesigns endpoint)"
          }
        ],
        "responses": {
          "200": {
            "description": "Design Tool view rendered successfully",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Database error"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/products/listproducts": {
      "post": {
        "summary": "Get a list of all products",
        "description": "Retrieves all products from the database, ordered by priority",
        "tags": [
          "Products"
        ],
        "requestBody": {
          "description": "Empty request body (no parameters required)",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A list of products",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "products": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer",
                            "description": "The product ID"
                          },
                          "title": {
                            "type": "string",
                            "description": "The product title"
                          },
                          "sku": {
                            "type": "string",
                            "description": "The product SKU"
                          },
                          "description": {
                            "type": "string",
                            "description": "The product description"
                          },
                          "categories": {
                            "type": "string",
                            "description": "JSON string of product categories"
                          },
                          "priority": {
                            "type": "integer",
                            "description": "Display order priority"
                          },
                          "model": {
                            "type": "string",
                            "description": "JSON string of product models"
                          },
                          "graphic_designs": {
                            "type": "string",
                            "description": "JSON string of associated graphic designs"
                          },
                          "logos": {
                            "type": "string",
                            "description": "JSON string of associated logos"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error"
          }
        }
      }
    },
    "/projects/createProject": {
      "post": {
        "summary": "Create a new project",
        "description": "Creates a new project with required title and external ID. Optionally associates a product by SKU.",
        "tags": [
          "Projects"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ext_id",
                  "title"
                ],
                "properties": {
                  "ext_id": {
                    "type": "string",
                    "description": "External identifier for the project"
                  },
                  "title": {
                    "type": "string",
                    "description": "Title of the project"
                  },
                  "sku": {
                    "type": "string",
                    "description": "Optional product SKU to associate with the project"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Project created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "message": {
                      "type": "string",
                      "example": "Project created"
                    },
                    "id": {
                      "type": "string",
                      "description": "The external ID of the created project"
                    },
                    "project_id": {
                      "type": "integer",
                      "description": "The internal database ID of the created project"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Project already exists",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Project already exists. Please use a different external ID."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Error creating project"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/projects/listdesigns/{ext_id}": {
      "get": {
        "summary": "List all designs for a project",
        "description": "Retrieves all designs associated with a project's external ID",
        "tags": [
          "Projects"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "ext_id",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "External project identifier"
          }
        ],
        "responses": {
          "200": {
            "description": "List of designs retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "success"
                    },
                    "designs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "integer",
                            "description": "Design ID"
                          },
                          "product_id": {
                            "type": "string",
                            "description": "Product SKU"
                          },
                          "design": {
                            "type": "string",
                            "description": "Design data"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "error"
                    },
                    "message": {
                      "type": "string",
                      "example": "Database error"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
