openapi: 3.0.3
info:
  title: Repzo API - Price List Item
  version: 1.0.0
  description: OpenAPI specification for Repzo Price List Item endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /pricelistitem:
    get:
      summary: Find price list items
      operationId: findPriceListItems
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              search:
                type: string
              product_id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              variant_id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              pricelist_id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              disabled:
                type: boolean
              from_updatedAt:
                type: number
              populatedKeys:
                type: array
                items:
                  type: string
                  enum: [product, variant, pricelist]
          description: Query parameters for filtering price list items
      responses:
        "200":
          description: A list of price list items
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListItemFindResult"
    post:
      summary: Create a price list item
      operationId: createPriceListItem
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PriceListItemCreateBody"
      responses:
        "201":
          description: Price list item created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListItemCreateResult"
  /pricelistitem/{id}:
    get:
      summary: Get a price list item by ID
      operationId: getPriceListItem
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Price list item details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListItemGetResult"
    put:
      summary: Update a price list item
      operationId: updatePriceListItem
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PriceListItemUpdateBody"
      responses:
        "200":
          description: Price list item updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListItemUpdateResult"
    delete:
      summary: Remove a price list item
      operationId: removePriceListItem
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Price list item removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PriceListItemRemoveResult"
components:
  schemas:
    PriceListItemFindResult:
      type: object
      description: Result of finding price list items
      properties:
        data:
          type: array
          items:
            allOf:
              - $ref: "#/components/schemas/PriceListItemSchema"
              - type: object
                properties:
                  product_id:
                    oneOf:
                      - type: string
                      - $ref: "#/components/schemas/ProductReference"
                  variant_id:
                    oneOf:
                      - type: string
                      - $ref: "#/components/schemas/VariantReference"
                  pricelist_id:
                    oneOf:
                      - type: string
                      - $ref: "#/components/schemas/PriceListReference"
        total_result:
          type: number
          description: Total number of price list items
        current_count:
          type: number
          description: Count of price list items 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 price list items 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
    PriceListItemSchema:
      type: object
      description: Price list item schema
      properties:
        _id:
          type: string
          description: Unique identifier for the price list item
        product_id:
          type: string
          description: ID of the product
        variant_id:
          type: string
          description: ID of the variant
        pricelist_id:
          type: string
          description: ID of the price list
        price:
          type: number
          description: Price value
        disabled:
          type: boolean
          description: Whether the price list item 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
    ProductReference:
      type: object
      description: Reference to a product
      properties:
        _id:
          type: string
          description: Product ID
        name:
          type: string
          description: Product name
        category:
          type: string
          description: Product category
        active:
          type: boolean
          description: Whether the product is active
        sku:
          type: string
          description: Product SKU
        barcode:
          type: string
          description: Product barcode
    VariantReference:
      type: object
      description: Reference to a variant
      properties:
        _id:
          type: string
          description: Variant ID
        name:
          type: string
          description: Variant name
        product:
          type: string
          description: Product ID
        sku:
          type: string
          description: Variant SKU
        barcode:
          type: string
          description: Variant barcode
    PriceListReference:
      type: object
      description: Reference to a price list
      properties:
        _id:
          type: string
          description: Price list ID
        name:
          type: string
          description: Price list name
    PriceListItemCreateBody:
      type: object
      description: Body for creating a price list item
      required:
        - product_id
        - variant_id
        - pricelist_id
        - price
      properties:
        product_id:
          type: string
          description: ID of the product
        variant_id:
          type: string
          description: ID of the variant
        pricelist_id:
          type: string
          description: ID of the price list
        price:
          type: number
          description: Price value
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        disabled:
          type: boolean
          description: Whether the price list item is disabled
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
    PriceListItemCreateResult:
      $ref: "#/components/schemas/PriceListItemSchema"
      description: Result of creating a price list item
    PriceListItemGetResult:
      $ref: "#/components/schemas/PriceListItemSchema"
      description: Result of getting a price list item
    PriceListItemUpdateBody:
      type: object
      description: Body for updating a price list item
      properties:
        product_id:
          type: string
          description: ID of the product
        variant_id:
          type: string
          description: ID of the variant
        pricelist_id:
          type: string
          description: ID of the price list
        price:
          type: number
          description: Price value
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        disabled:
          type: boolean
          description: Whether the price list item is disabled
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        _id:
          type: string
          description: Unique identifier for the price list item
        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
    PriceListItemUpdateResult:
      $ref: "#/components/schemas/PriceListItemSchema"
      description: Result of updating a price list item
    PriceListItemRemoveResult:
      $ref: "#/components/schemas/PriceListItemSchema"
      description: Result of removing a price list item
