openapi: 3.0.3
info:
  title: Repzo API - Product
  version: 1.0.0
  description: OpenAPI specification for Repzo Product endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /product:
    get:
      summary: Find products
      operationId: findProducts
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering products
      responses:
        "200":
          description: A list of products
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductFindResult"
    post:
      summary: Create a product
      operationId: createProduct
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProductCreateBody"
      responses:
        "201":
          description: Product created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductCreateResult"
  /product/{id}:
    get:
      summary: Get a product by ID
      operationId: getProduct
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Product details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductGetResult"
    put:
      summary: Update a product
      operationId: updateProduct
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProductUpdateBody"
      responses:
        "200":
          description: Product updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductUpdateResult"
    delete:
      summary: Remove a product
      operationId: removeProduct
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Product removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductRemoveResult"
components:
  schemas:
    ProductFindResult:
      type: object
      description: Result of finding products
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ProductSchema"
        total_result:
          type: number
          description: Total number of products
        current_count:
          type: number
          description: Count of products in current page
        total_pages:
          type: number
          description: Total number of pages
        current_page:
          type: number
          description: Current page number
        per_page:
          type: number
          description: Number of products per page
        first_page_url:
          type: string
          description: URL for the first page
        last_page_url:
          type: string
          description: URL for the last page
        next_page_url:
          type: string
          nullable: true
          description: URL for the next page
        prev_page_url:
          type: string
          nullable: true
          description: URL for the previous page
        path:
          type: string
          description: Base URL path
    ProductSchema:
      type: object
      description: Product schema
      properties:
        _id:
          type: string
          description: Unique identifier for the product
        name:
          type: string
          description: Name of the product
        category:
          type: string
          description: ID of the product category
        active:
          type: boolean
          description: Whether the product is active
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        local_name:
          type: string
          description: Localized name of the product
        sku:
          type: string
          description: Stock keeping unit
        sub_category:
          type: array
          items:
            type: string
          description: IDs of the product sub-categories
        assigned_to:
          type: array
          items:
            type: string
          description: Representatives assigned to this product
        auditable:
          type: boolean
          description: Whether the product is auditable
        barcode:
          type: string
          description: Barcode of the product
        sv_tax:
          type: string
          description: ID of the tax
        sv_measureUnit:
          type: string
          description: ID of the measure unit
        description:
          type: string
          description: Description of the product
        local_description:
          type: string
          description: Localized description of the product
        product_img:
          type: string
          description: Product image URL
        base_price:
          type: string
          description: Base price of the product
        assigned_media:
          type: array
          items:
            type: string
          description: Media assigned to this product
        html_description:
          type: string
          description: HTML description of the product
        modifiers_group:
          type: array
          items:
            type: string
          description: Modifier groups for the product
        featured:
          type: boolean
          description: Whether the product is featured
        brand:
          type: string
          description: ID of the brand
        rsp:
          type: number
          description: Recommended selling price
        measureunit_family:
          type: string
          description: ID of the measure unit family
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        teams:
          type: array
          items:
            type: string
          description: Teams
        position:
          type: number
          description: Position of the product
        product_groups:
          type: array
          items:
            type: string
          description: Product groups
        frozen_pre_sales:
          type: boolean
          description: Whether pre-sales are frozen
        frozen_sales:
          type: boolean
          description: Whether sales are frozen
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
    ProductCreateBody:
      type: object
      description: Body for creating a product
      required:
        - name
        - category
      properties:
        name:
          type: string
          description: Name of the product
        category:
          type: string
          description: ID of the product category
        active:
          type: boolean
          description: Whether the product is active
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        local_name:
          type: string
          description: Localized name of the product
        sku:
          type: string
          description: Stock keeping unit
        sub_category:
          type: array
          items:
            type: string
          description: IDs of the product sub-categories
        assigned_to:
          type: array
          items:
            type: string
          description: Representatives assigned to this product
        auditable:
          type: boolean
          description: Whether the product is auditable
        barcode:
          type: string
          description: Barcode of the product
        sv_tax:
          type: string
          description: ID of the tax
        sv_measureUnit:
          type: string
          description: ID of the measure unit
        description:
          type: string
          description: Description of the product
        local_description:
          type: string
          description: Localized description of the product
        product_img:
          type: string
          description: Product image URL
        base_price:
          type: string
          description: Base price of the product
        assigned_media:
          type: array
          items:
            type: string
          description: Media assigned to this product
        html_description:
          type: string
          description: HTML description of the product
        modifiers_group:
          type: array
          items:
            type: string
          description: Modifier groups for the product
        featured:
          type: boolean
          description: Whether the product is featured
        brand:
          type: string
          description: ID of the brand
        rsp:
          type: number
          description: Recommended selling price
        measureunit_family:
          type: string
          description: ID of the measure unit family
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        teams:
          type: array
          items:
            type: string
          description: Teams
        position:
          type: number
          description: Position of the product
        product_groups:
          type: array
          items:
            type: string
          description: Product groups
        frozen_pre_sales:
          type: boolean
          description: Whether pre-sales are frozen
        frozen_sales:
          type: boolean
          description: Whether sales are frozen
        variants:
          type: array
          items:
            $ref: "#/components/schemas/VariantCreateBody"
          description: List of variants for this product
    ProductCreateResult:
      $ref: "#/components/schemas/ProductSchema"
      description: Result of creating a product
    ProductGetResult:
      $ref: "#/components/schemas/ProductSchema"
      description: Result of getting a product
    ProductUpdateBody:
      type: object
      description: Body for updating a product
      properties:
        name:
          type: string
          description: Name of the product
        category:
          type: string
          description: ID of the product category
        active:
          type: boolean
          description: Whether the product is active
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        local_name:
          type: string
          description: Localized name of the product
        sku:
          type: string
          description: Stock keeping unit
        sub_category:
          type: array
          items:
            type: string
          description: IDs of the product sub-categories
        assigned_to:
          type: array
          items:
            type: string
          description: Representatives assigned to this product
        auditable:
          type: boolean
          description: Whether the product is auditable
        barcode:
          type: string
          description: Barcode of the product
        sv_tax:
          type: string
          description: ID of the tax
        sv_measureUnit:
          type: string
          description: ID of the measure unit
        description:
          type: string
          description: Description of the product
        local_description:
          type: string
          description: Localized description of the product
        product_img:
          type: string
          description: Product image URL
        base_price:
          type: string
          description: Base price of the product
        assigned_media:
          type: array
          items:
            type: string
          description: Media assigned to this product
        html_description:
          type: string
          description: HTML description of the product
        modifiers_group:
          type: array
          items:
            type: string
          description: Modifier groups for the product
        featured:
          type: boolean
          description: Whether the product is featured
        brand:
          type: string
          description: ID of the brand
        rsp:
          type: number
          description: Recommended selling price
        measureunit_family:
          type: string
          description: ID of the measure unit family
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        teams:
          type: array
          items:
            type: string
          description: Teams
        position:
          type: number
          description: Position of the product
        product_groups:
          type: array
          items:
            type: string
          description: Product groups
        frozen_pre_sales:
          type: boolean
          description: Whether pre-sales are frozen
        frozen_sales:
          type: boolean
          description: Whether sales are frozen
        _id:
          type: string
          description: Unique identifier for the product
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
        variants:
          type: array
          items:
            allOf:
              - $ref: "#/components/schemas/VariantCreateBody"
              - type: object
                properties:
                  _id:
                    type: string
                    description: Unique identifier for the variant
          description: List of variants for this product
    ProductUpdateResult:
      $ref: "#/components/schemas/ProductSchema"
      description: Result of updating a product
    ProductRemoveResult:
      $ref: "#/components/schemas/ProductSchema"
      description: Result of removing a product
    VariantCreateBody:
      type: object
      description: Body for creating a variant
      properties:
        name:
          type: string
          description: Name of the variant
        product:
          type: string
          description: ID of the product this variant belongs to
        price:
          type: number
          description: Price of the variant
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the variant is disabled
        uuid:
          type: string
          description: UUID for the variant
        local_name:
          type: string
          description: Localized name of the variant
        sku:
          type: string
          description: Stock keeping unit
        barcode:
          type: string
          description: Barcode of the variant
        weight:
          type: number
          description: Weight of the variant
        length:
          type: number
          description: Length of the variant
        width:
          type: number
          description: Width of the variant
        height:
          type: number
          description: Height of the variant
        position:
          type: number
          description: Position of the variant
        default:
          type: boolean
          description: Whether this is the default variant
        variant_img:
          type: string
          description: Image URL for the variant
        modifiers_groups:
          type: array
          items:
            type: string
          description: Modifier groups for the variant
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
