openapi: 3.0.3
info:
  title: Repzo API - Media
  version: 1.0.0
  description: OpenAPI specification for Repzo Media endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /media:
    get:
      summary: Find media
      operationId: findMedia
      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
              description:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              parent_document_key:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              url:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              disabled:
                type: boolean
              document_type:
                type: string
                enum:
                  [
                    html,
                    csv,
                    json,
                    image,
                    pdf,
                    ppt,
                    pptx,
                    xls,
                    xlsx,
                    doc,
                    docx,
                    images,
                    zip,
                    pt,
                  ]
              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 media
      responses:
        "200":
          description: A list of media
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaFindResult"
    post:
      summary: Create media
      operationId: createMedia
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MediaCreateBody"
      responses:
        "201":
          description: Media created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaCreateResult"
  /media/{id}:
    get:
      summary: Get media by ID
      operationId: getMedia
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Media details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaGetResult"
    put:
      summary: Update media
      operationId: updateMedia
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MediaUpdateBody"
      responses:
        "200":
          description: Media updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaUpdateResult"
    delete:
      summary: Remove media
      operationId: removeMedia
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Media removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MediaRemoveResult"
components:
  schemas:
    MediaFindResult:
      type: object
      description: Result of finding media
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MediaSchema"
        total_result:
          type: number
          description: Total number of media
        current_count:
          type: number
          description: Count of media 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 media 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
    MediaSchema:
      type: object
      description: Media schema
      properties:
        _id:
          type: string
          description: Unique identifier for the media
        name:
          type: string
          description: Name of the media
        description:
          type: string
          description: Description of the media
        url:
          type: string
          description: URL of the media
        document_type:
          type: string
          enum:
            [
              html,
              csv,
              json,
              image,
              pdf,
              ppt,
              pptx,
              xls,
              xlsx,
              doc,
              docx,
              images,
              zip,
              pt,
            ]
          description: Type of media document
        parent_document_type:
          type: string
          enum:
            [
              clients,
              asset,
              assetUnit,
              workorder,
              clientLocation,
              clientContact,
              commentsThread,
              workorderRequest,
              workorderPortal,
              invoice,
              products,
              productvariations,
              representatives,
              productcategories,
              productSubCategory,
              speciality,
              line,
              banner,
              intgAvailableApps,
            ]
          description: Type of parent document
        parent_document_key:
          type: string
          description: Key of parent document
        disabled:
          type: boolean
          description: Whether the media 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
    MediaCreateBody:
      type: object
      description: Body for creating media
      required:
        - name
        - url
        - document_type
      properties:
        name:
          type: string
          description: Name of the media
        description:
          type: string
          description: Description of the media
        url:
          type: string
          description: URL of the media
        document_type:
          type: string
          enum:
            [
              html,
              csv,
              json,
              image,
              pdf,
              ppt,
              pptx,
              xls,
              xlsx,
              doc,
              docx,
              images,
              zip,
              pt,
            ]
          description: Type of media document
        parent_document_type:
          type: string
          enum:
            [
              clients,
              asset,
              assetUnit,
              workorder,
              clientLocation,
              clientContact,
              commentsThread,
              workorderRequest,
              workorderPortal,
              invoice,
              products,
              productvariations,
              representatives,
              productcategories,
              productSubCategory,
              speciality,
              line,
              banner,
              intgAvailableApps,
            ]
          description: Type of parent document
        parent_document_key:
          type: string
          description: Key of parent document
        disabled:
          type: boolean
          description: Whether the media is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
    MediaCreateResult:
      $ref: "#/components/schemas/MediaSchema"
      description: Result of creating media
    MediaGetResult:
      $ref: "#/components/schemas/MediaSchema"
      description: Result of getting media
    MediaUpdateBody:
      type: object
      description: Body for updating media
      properties:
        name:
          type: string
          description: Name of the media
        description:
          type: string
          description: Description of the media
        url:
          type: string
          description: URL of the media
        document_type:
          type: string
          enum:
            [
              html,
              csv,
              json,
              image,
              pdf,
              ppt,
              pptx,
              xls,
              xlsx,
              doc,
              docx,
              images,
              zip,
              pt,
            ]
          description: Type of media document
        parent_document_type:
          type: string
          enum:
            [
              clients,
              asset,
              assetUnit,
              workorder,
              clientLocation,
              clientContact,
              commentsThread,
              workorderRequest,
              workorderPortal,
              invoice,
              products,
              productvariations,
              representatives,
              productcategories,
              productSubCategory,
              speciality,
              line,
              banner,
              intgAvailableApps,
            ]
          description: Type of parent document
        parent_document_key:
          type: string
          description: Key of parent document
        disabled:
          type: boolean
          description: Whether the media 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 media
        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
    MediaUpdateResult:
      $ref: "#/components/schemas/MediaSchema"
      description: Result of updating media
    MediaRemoveResult:
      $ref: "#/components/schemas/MediaSchema"
      description: Result of removing media
