openapi: 3.0.3
info:
  title: Repzo API - Product Group
  version: 1.0.0
  description: OpenAPI specification for Repzo Product Group endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /product-group:
    get:
      summary: Find product groups
      operationId: findProductGroups
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              search:
                type: string
              name:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              local_name:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              disabled:
                type: boolean
              from_updatedAt:
                type: number
              from__id:
                type: string
              to__id:
                type: string
              sortBy:
                type: array
                items:
                  type: object
                  properties:
                    field:
                      type: string
                      enum: [_id]
                    type:
                      type: string
                      enum: [asc, desc]
              createdAt:
                type: number
              updatedAt:
                type: number
          description: Query parameters for filtering product groups
      responses:
        "200":
          description: A list of product groups
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductGroupFindResult"
    post:
      summary: Create a product group
      operationId: createProductGroup
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProductGroupCreateBody"
      responses:
        "201":
          description: Product group created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductGroupCreateResult"
  /product-group/{id}:
    get:
      summary: Get a product group by ID
      operationId: getProductGroup
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Product group details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductGroupGetResult"
    put:
      summary: Update a product group
      operationId: updateProductGroup
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ProductGroupUpdateBody"
      responses:
        "200":
          description: Product group updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductGroupUpdateResult"
    delete:
      summary: Remove a product group
      operationId: removeProductGroup
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Product group removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ProductGroupRemoveResult"
components:
  schemas:
    ProductGroupFindResult:
      type: object
      description: Result of finding product groups
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/ProductGroupSchema"
        total_result:
          type: number
          description: Total number of product groups
        current_count:
          type: number
          description: Count of product groups 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 product groups 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
    ProductGroupSchema:
      type: object
      description: Product group schema
      properties:
        _id:
          type: string
          description: Unique identifier for the product group
        name:
          type: string
          description: Name of the product group
        local_name:
          type: string
          description: Localized name of the product group
        disabled:
          type: boolean
          description: Whether the product group is disabled
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        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
    ProductGroupCreateBody:
      type: object
      description: Body for creating a product group
      required:
        - name
      properties:
        name:
          type: string
          description: Name of the product group
        local_name:
          type: string
          description: Localized name of the product group
        disabled:
          type: boolean
          description: Whether the product group is disabled
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
    ProductGroupCreateResult:
      $ref: "#/components/schemas/ProductGroupSchema"
      description: Result of creating a product group
    ProductGroupGetResult:
      $ref: "#/components/schemas/ProductGroupSchema"
      description: Result of getting a product group
    ProductGroupUpdateBody:
      type: object
      description: Body for updating a product group
      properties:
        name:
          type: string
          description: Name of the product group
        local_name:
          type: string
          description: Localized name of the product group
        disabled:
          type: boolean
          description: Whether the product group is disabled
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        _id:
          type: string
          description: Unique identifier for the product group
        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
    ProductGroupUpdateResult:
      $ref: "#/components/schemas/ProductGroupSchema"
      description: Result of updating a product group
    ProductGroupRemoveResult:
      $ref: "#/components/schemas/ProductGroupSchema"
      description: Result of removing a product group
