openapi: 3.0.3
info:
  title: Repzo API - Team
  version: 1.0.0
  description: OpenAPI specification for Repzo Team endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /team:
    get:
      summary: Find teams
      operationId: findTeams
      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
              disabled:
                type: boolean
              from_updatedAt:
                type: number
              to_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 teams
      responses:
        "200":
          description: A list of teams
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TeamFindResult"
    post:
      summary: Create a team
      operationId: createTeam
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TeamCreateBody"
      responses:
        "201":
          description: Team created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TeamCreateResult"
  /team/{id}:
    get:
      summary: Get a team by ID
      operationId: getTeam
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Team details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TeamGetResult"
    put:
      summary: Update a team
      operationId: updateTeam
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TeamUpdateBody"
      responses:
        "200":
          description: Team updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TeamUpdateResult"
    delete:
      summary: Remove a team
      operationId: removeTeam
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Team removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/TeamRemoveResult"
components:
  schemas:
    TeamFindResult:
      type: object
      description: Result of finding teams
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/TeamSchema"
        total_result:
          type: number
          description: Total number of teams
        current_count:
          type: number
          description: Count of teams 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 teams 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
    TeamSchema:
      type: object
      description: Team schema
      properties:
        _id:
          type: string
          description: Unique identifier for the team
        name:
          type: string
          description: Name of the team
        disabled:
          type: boolean
          description: Whether the team is disabled
        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
    TeamCreateBody:
      type: object
      description: Body for creating a team
      required:
        - name
      properties:
        name:
          type: string
          description: Name of the team
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the team is disabled
    TeamCreateResult:
      $ref: "#/components/schemas/TeamSchema"
      description: Result of creating a team
    TeamGetResult:
      allOf:
        - $ref: "#/components/schemas/TeamSchema"
        - type: object
          properties:
            admins:
              description: Administrators associated with the team
            reps:
              description: Representatives associated with the team
      description: Result of getting a team
    TeamUpdateBody:
      type: object
      description: Body for updating a team
      properties:
        name:
          type: string
          description: Name of the team
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        disabled:
          type: boolean
          description: Whether the team is disabled
        _id:
          type: string
          description: Unique identifier for the team
        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
    TeamUpdateResult:
      $ref: "#/components/schemas/TeamSchema"
      description: Result of updating a team
    TeamRemoveResult:
      $ref: "#/components/schemas/TeamSchema"
      description: Result of removing a team
