openapi: 3.0.3
info:
  title: Repzo API - Category
  version: 1.0.0
  description: OpenAPI specification for Repzo Category endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /product-category:
    get:
      summary: Find categories
      operationId: findCategories
      parameters:
        - in: query
          name: params
          schema:
            type: object
          description: Query parameters for filtering categories
      responses:
        "200":
          description: A list of categories
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CategoryFindResult"
    post:
      summary: Create a category
      operationId: createCategory
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CategoryCreateBody"
      responses:
        "201":
          description: Category created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CategoryCreateResult"
  /product-category/{id}:
    get:
      summary: Get a category by ID
      operationId: getCategory
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Category details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CategoryGetResult"
    put:
      summary: Update a category
      operationId: updateCategory
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CategoryUpdateBody"
      responses:
        "200":
          description: Category updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CategoryUpdateResult"
    delete:
      summary: Remove a category
      operationId: removeCategory
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Category removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CategoryRemoveResult"
components:
  schemas:
    CategoryFindResult:
      type: object
      description: Result of finding categories
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/CategorySchema"
        total_result:
          type: number
          description: Total number of categories
        current_count:
          type: number
          description: Count of categories 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 categories 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
    CategorySchema:
      type: object
      description: Category schema
      properties:
        _id:
          type: string
          description: Unique identifier for the category
        type:
          type: string
          enum: [main]
          description: Category type
        name:
          type: string
          description: Name of the category
        photo:
          type: string
          description: Photo URL of the category
        local_name:
          type: string
          description: Localized name of the category
        icon:
          type: string
          description: Icon for the category
        disabled:
          type: boolean
          description: Whether the category is disabled
        position:
          type: number
          description: Position of the category
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        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
    CategoryCreateBody:
      type: object
      description: Body for creating a category
      required:
        - name
      properties:
        name:
          type: string
          description: Name of the category
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        type:
          type: string
          enum: [main]
          description: Category type
        disabled:
          type: boolean
          description: Whether the category is disabled
        photo:
          type: string
          description: Photo URL of the category
        local_name:
          type: string
          description: Localized name of the category
        icon:
          type: string
          description: Icon for the category
        position:
          type: number
          description: Position of the category
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    CategoryCreateResult:
      $ref: "#/components/schemas/CategorySchema"
      description: Result of creating a category
    CategoryGetResult:
      $ref: "#/components/schemas/CategorySchema"
      description: Result of getting a category
    CategoryUpdateBody:
      type: object
      description: Body for updating a category
      properties:
        name:
          type: string
          description: Name of the category
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        type:
          type: string
          enum: [main]
          description: Category type
        disabled:
          type: boolean
          description: Whether the category is disabled
        photo:
          type: string
          description: Photo URL of the category
        local_name:
          type: string
          description: Localized name of the category
        icon:
          type: string
          description: Icon for the category
        position:
          type: number
          description: Position of the category
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        _id:
          type: string
          description: Unique identifier for the category
        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
    CategoryUpdateResult:
      $ref: "#/components/schemas/CategorySchema"
      description: Result of updating a category
    CategoryRemoveResult:
      $ref: "#/components/schemas/CategorySchema"
      description: Result of removing a category
