openapi: 3.0.3
info:
  title: Repzo API - Item Status Type
  version: 1.0.0
  description: OpenAPI specification for Repzo Item Status Type endpoints.
servers:
  - url: https://sv.api.repzo.me
    description: Production server
  - url: https://staging.sv.api.repzo.me
    description: Staging server
security:
  - ApiKeyAuth: []
  - JwtAuth: []
tags:
  - name: Item Status Type
    description: Operations for managing item status type records.
paths:
  /item-status-type:
    get:
      tags:
        - Item Status Type
      summary: Find item status types
      operationId: findItemStatusTypes
      parameters:
        - in: query
          name: _id
          description: Filter by one or more item status type IDs.
          schema:
            oneOf:
              - type: string
              - type: array
                items:
                  type: string
        - in: query
          name: name
          description: Filter by item status type name.
          schema:
            oneOf:
              - type: string
              - type: array
                items:
                  type: string
        - in: query
          name: disabled
          description: Filter by soft-delete state.
          schema:
            type: boolean
        - in: query
          name: is_default
          description: Filter by namespace default state.
          schema:
            type: boolean
        - in: query
          name: per_page
          description: Number of records per page.
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - in: query
          name: page
          description: Page number.
          schema:
            type: integer
            minimum: 1
        - in: query
          name: sort
          description: Field to sort by.
          schema:
            type: string
        - in: query
          name: sortPageOrder
          description: Sort direction.
          schema:
            type: string
            enum:
              - asc
              - dsc
      responses:
        "200":
          description: A paginated list of item status types.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ItemStatusTypeFindResult"
        "401":
          description: Unauthorized.
        "500":
          description: Internal server error.
    post:
      tags:
        - Item Status Type
      summary: Create an item status type
      operationId: createItemStatusType
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ItemStatusTypeCreateBody"
      responses:
        "201":
          description: Item status type created.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ItemStatusType"
        "400":
          description: Bad request.
        "401":
          description: Unauthorized.
        "500":
          description: Internal server error.
  /item-status-type/{id}:
    get:
      tags:
        - Item Status Type
      summary: Get an item status type by ID
      operationId: getItemStatusType
      parameters:
        - in: path
          name: id
          required: true
          description: Item status type ID.
          schema:
            type: string
      responses:
        "200":
          description: Item status type details.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ItemStatusType"
        "401":
          description: Unauthorized.
        "404":
          description: Item status type not found.
        "500":
          description: Internal server error.
    put:
      tags:
        - Item Status Type
      summary: Update an item status type
      operationId: updateItemStatusType
      parameters:
        - in: path
          name: id
          required: true
          description: Item status type ID.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ItemStatusTypeUpdateBody"
      responses:
        "200":
          description: Item status type updated.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ItemStatusType"
        "400":
          description: Bad request.
        "401":
          description: Unauthorized.
        "404":
          description: Item status type not found.
        "500":
          description: Internal server error.
    delete:
      tags:
        - Item Status Type
      summary: Remove an item status type
      operationId: removeItemStatusType
      parameters:
        - in: path
          name: id
          required: true
          description: Item status type ID.
          schema:
            type: string
      responses:
        "200":
          description: Item status type removed.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ItemStatusType"
        "400":
          description: Bad request.
        "401":
          description: Unauthorized.
        "404":
          description: Item status type not found.
        "500":
          description: Internal server error.
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-key
    JwtAuth:
      type: apiKey
      in: header
      name: Authorization
  schemas:
    ItemStatusTypeFindResult:
      allOf:
        - $ref: "#/components/schemas/PaginationResult"
        - type: object
          properties:
            data:
              type: array
              items:
                $ref: "#/components/schemas/ItemStatusType"
    ItemStatusType:
      type: object
      properties:
        _id:
          type: string
        name:
          type: string
        local_name:
          type: string
        is_default:
          type: boolean
          description: Whether this is the default item status type for the namespace.
        disabled:
          type: boolean
          description: Soft-delete flag.
        company_namespace:
          type: array
          items:
            type: string
        creator:
          $ref: "#/components/schemas/UserRef"
        editor:
          $ref: "#/components/schemas/UserRef"
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
        __v:
          type: number
      required:
        - _id
        - name
        - is_default
        - disabled
        - company_namespace
        - creator
        - createdAt
        - updatedAt
    ItemStatusTypeCreateBody:
      type: object
      properties:
        name:
          type: string
        local_name:
          type: string
        is_default:
          type: boolean
          default: false
      required:
        - name
    ItemStatusTypeUpdateBody:
      type: object
      properties:
        name:
          type: string
        local_name:
          type: string
        is_default:
          type: boolean
        disabled:
          type: boolean
    UserRef:
      type: object
      properties:
        _id:
          type: string
        type:
          type: string
          enum:
            - admin
        name:
          type: string
        admin:
          type: string
      required:
        - _id
        - type
    PaginationResult:
      type: object
      properties:
        total_result:
          type: number
        current_count:
          type: number
        total_pages:
          type: number
        current_page:
          type: number
        per_page:
          type: number
        first_page_url:
          type: string
        last_page_url:
          type: string
        next_page_url:
          type: string
          nullable: true
        prev_page_url:
          type: string
          nullable: true
        path:
          type: string
