openapi: 3.0.3
info:
  title: Repzo API - Tax
  version: 1.0.0
  description: OpenAPI specification for Repzo Tax endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /tax:
    get:
      summary: Find taxes
      operationId: findTaxes
      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
              rate:
                oneOf:
                  - type: array
                    items:
                      type: number
                  - type: number
              type:
                type: string
                enum: [inclusive, additive, "N/A"]
              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]
          description: Query parameters for filtering taxes
      responses:
        "200":
          description: A list of taxes
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaxFindResult"
    post:
      summary: Create a tax
      operationId: createTax
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaxCreateBody"
      responses:
        "201":
          description: Tax created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaxCreateResult"
  /tax/{id}:
    get:
      summary: Get a tax by ID
      operationId: getTax
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Tax details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaxGetResult"
    put:
      summary: Update a tax
      operationId: updateTax
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TaxUpdateBody"
      responses:
        "200":
          description: Tax updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaxUpdateResult"
    delete:
      summary: Remove a tax
      operationId: removeTax
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Tax removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TaxRemoveResult"
components:
  schemas:
    TaxFindResult:
      type: object
      description: Result of finding taxes
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/TaxSchema"
        total_result:
          type: number
          description: Total number of taxes
        current_count:
          type: number
          description: Count of taxes 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 taxes 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
    TaxSchema:
      type: object
      description: Tax schema
      properties:
        _id:
          type: string
          description: Unique identifier for the tax
        name:
          type: string
          description: Name of the tax
        rate:
          type: number
          description: Tax rate
        type:
          type: string
          enum: [inclusive, additive, "N/A"]
          description: Type of tax (inclusive, additive, or N/A)
        disabled:
          type: boolean
          description: Whether the tax 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
    TaxCreateBody:
      type: object
      description: Body for creating a tax
      required:
        - name
        - rate
        - type
      properties:
        name:
          type: string
          description: Name of the tax
        rate:
          type: number
          description: Tax rate
        type:
          type: string
          enum: [inclusive, additive, "N/A"]
          description: Type of tax
        disabled:
          type: boolean
          description: Whether the tax is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
    TaxCreateResult:
      $ref: "#/components/schemas/TaxSchema"
      description: Result of creating a tax
    TaxGetResult:
      $ref: "#/components/schemas/TaxSchema"
      description: Result of getting a tax
    TaxUpdateBody:
      type: object
      description: Body for updating a tax
      properties:
        name:
          type: string
          description: Name of the tax
        rate:
          type: number
          description: Tax rate
        type:
          type: string
          enum: [inclusive, additive, "N/A"]
          description: Type of tax
        disabled:
          type: boolean
          description: Whether the tax is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        _id:
          type: string
          description: Unique identifier for the tax
        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
    TaxUpdateResult:
      $ref: "#/components/schemas/TaxSchema"
      description: Result of updating a tax
    TaxRemoveResult:
      $ref: "#/components/schemas/TaxSchema"
      description: Result of removing a tax
