openapi: 3.0.3
info:
  title: Repzo API - Measure Unit
  version: 1.0.0
  description: OpenAPI specification for Repzo Measure Unit endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /measure-unit:
    get:
      summary: Find measure units
      operationId: findMeasureUnits
      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
              factor:
                oneOf:
                  - type: array
                    items:
                      type: number
                  - type: number
              parent:
                type: string
                enum: [nil]
              disabled:
                type: boolean
              from_updatedAt:
                type: number
              family_name:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              withFamily:
                type: boolean
              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]
          description: Query parameters for filtering measure units
      responses:
        "200":
          description: A list of measure units
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitFindResult"
    post:
      summary: Create a measure unit
      operationId: createMeasureUnit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MeasureUnitCreateBody"
      responses:
        "201":
          description: Measure unit created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitCreateResult"
  /measure-unit/{id}:
    get:
      summary: Get a measure unit by ID
      operationId: getMeasureUnit
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Measure unit details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitGetResult"
    put:
      summary: Update a measure unit
      operationId: updateMeasureUnit
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MeasureUnitUpdateBody"
      responses:
        "200":
          description: Measure unit updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitUpdateResult"
    delete:
      summary: Remove a measure unit
      operationId: removeMeasureUnit
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Measure unit removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitRemoveResult"
components:
  schemas:
    MeasureUnitFindResult:
      type: object
      description: Result of finding measure units
      properties:
        data:
          type: array
          items:
            oneOf:
              - $ref: "#/components/schemas/MeasureUnitSchema"
              - allOf:
                  - $ref: "#/components/schemas/MeasureUnitSchema"
                  - type: object
                    properties:
                      family:
                        type: array
                        items:
                          $ref: "#/components/schemas/MeasureUnitFamilySchema"
        total_result:
          type: number
          description: Total number of measure units
        current_count:
          type: number
          description: Count of measure units 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 measure units 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
    MeasureUnitSchema:
      type: object
      description: Measure unit schema
      properties:
        _id:
          type: string
          description: Unique identifier for the measure unit
        name:
          type: string
          description: Name of the measure unit
        factor:
          type: number
          description: Factor of the measure unit
        local_name:
          type: string
          description: Localized name of the measure unit
        parent:
          type: string
          description: Parent measure unit ID
        disabled:
          type: boolean
          description: Whether the measure unit is disabled
        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
    MeasureUnitFamilySchema:
      type: object
      description: Measure unit family schema
      properties:
        _id:
          type: string
          description: Unique identifier for the measure unit family
        name:
          type: string
          description: Name of the measure unit family
        local_name:
          type: string
          description: Localized name of the measure unit family
        measureunits:
          type: array
          items:
            type: string
          description: Measure unit IDs in this family
        disabled:
          type: boolean
          description: Whether the measure unit family is disabled
        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
    MeasureUnitCreateBody:
      type: object
      description: Body for creating a measure unit
      required:
        - name
        - factor
      properties:
        name:
          type: string
          description: Name of the measure unit
        factor:
          type: number
          description: Factor of the measure unit
        local_name:
          type: string
          description: Localized name of the measure unit
        parent:
          type: string
          description: Parent measure unit ID
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the measure unit is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    MeasureUnitCreateResult:
      $ref: "#/components/schemas/MeasureUnitSchema"
      description: Result of creating a measure unit
    MeasureUnitGetResult:
      $ref: "#/components/schemas/MeasureUnitSchema"
      description: Result of getting a measure unit
    MeasureUnitUpdateBody:
      type: object
      description: Body for updating a measure unit
      properties:
        name:
          type: string
          description: Name of the measure unit
        factor:
          type: number
          description: Factor of the measure unit
        local_name:
          type: string
          description: Localized name of the measure unit
        parent:
          type: string
          description: Parent measure unit ID
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the measure unit is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        _id:
          type: string
          description: Unique identifier for the measure unit
        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
    MeasureUnitUpdateResult:
      $ref: "#/components/schemas/MeasureUnitSchema"
      description: Result of updating a measure unit
    MeasureUnitRemoveResult:
      $ref: "#/components/schemas/MeasureUnitSchema"
      description: Result of removing a measure unit
