openapi: 3.0.3
info:
  title: Repzo API - Measureunit Family
  version: 1.0.0
  description: OpenAPI specification for Repzo Measureunit Family endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /measureunitfamily:
    get:
      summary: Find measure unit families
      operationId: findMeasureUnitFamilies
      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
              measureunits:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              populatedKeys:
                type: array
                items:
                  type: string
                  enum: [measureunits]
              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 unit families
      responses:
        "200":
          description: A list of measure unit families
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitFamilyFindResult"
    post:
      summary: Create a measure unit family
      operationId: createMeasureUnitFamily
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MeasureUnitFamilyCreateBody"
      responses:
        "201":
          description: Measure unit family created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitFamilyCreateResult"
  /measureunitfamily/{id}:
    get:
      summary: Get a measure unit family by ID
      operationId: getMeasureUnitFamily
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Measure unit family details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitFamilyGetResult"
    put:
      summary: Update a measure unit family
      operationId: updateMeasureUnitFamily
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MeasureUnitFamilyUpdateBody"
      responses:
        "200":
          description: Measure unit family updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitFamilyUpdateResult"
    delete:
      summary: Remove a measure unit family
      operationId: removeMeasureUnitFamily
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Measure unit family removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MeasureUnitFamilyRemoveResult"
components:
  schemas:
    MeasureUnitFamilyFindResult:
      type: object
      description: Result of finding measure unit families
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MeasureUnitFamilySchemaWithPopulatedKeys"
        total_result:
          type: number
          description: Total number of measure unit families
        current_count:
          type: number
          description: Count of measure unit families 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 unit families 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
    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: IDs of measure units 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
    MeasureUnitFamilySchemaWithPopulatedKeys:
      allOf:
        - $ref: "#/components/schemas/MeasureUnitFamilySchema"
        - type: object
          properties:
            measureunits_populated:
              oneOf:
                - type: array
                  items:
                    type: string
                - type: array
                  items:
                    type: object
                    properties:
                      _id:
                        type: string
                      name:
                        type: string
                      factor:
                        type: number
                      local_name:
                        type: string
                      parent:
                        type: string
                      disabled:
                        type: boolean
                      integration_meta:
                        type: object
                        additionalProperties: true
                      company_namespace:
                        type: array
                        items:
                          type: string
                      createdAt:
                        type: string
                        format: date-time
                      updatedAt:
                        type: string
                        format: date-time
                      __v:
                        type: number
              description: Populated measure units
    MeasureUnitFamilyCreateBody:
      type: object
      description: Body for creating a measure unit family
      required:
        - name
      properties:
        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: IDs of measure units in this family
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the measure unit family is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    MeasureUnitFamilyCreateResult:
      $ref: "#/components/schemas/MeasureUnitFamilySchema"
      description: Result of creating a measure unit family
    MeasureUnitFamilyGetResult:
      $ref: "#/components/schemas/MeasureUnitFamilySchema"
      description: Result of getting a measure unit family
    MeasureUnitFamilyUpdateBody:
      type: object
      description: Body for updating a measure unit family
      properties:
        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: IDs of measure units in this family
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the measure unit family is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        _id:
          type: string
          description: Unique identifier for the measure unit family
        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
    MeasureUnitFamilyUpdateResult:
      $ref: "#/components/schemas/MeasureUnitFamilySchema"
      description: Result of updating a measure unit family
    MeasureUnitFamilyRemoveResult:
      $ref: "#/components/schemas/MeasureUnitFamilySchema"
      description: Result of removing a measure unit family
