---
openapi: 3.1.0
components:
  schemas:
    AgeCategory:
      type: string
      enum:
      - YOUTH
      - JUNIOR
      - SENIOR
    Competition:
      type: object
      required:
      - name
      - type
      - start
      - end
      - siteId
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
          type: string
          description: Internal id
        extId:
          type: string
          description: Your unique id
        name:
          type: string
        type:
          $ref: "#/components/schemas/Type"
        start:
          $ref: "#/components/schemas/Date"
        end:
          $ref: "#/components/schemas/Date"
        location:
          $ref: "#/components/schemas/Location"
          type: object
          readOnly: true
        siteId:
          type: string
        playerLevel:
          $ref: "#/components/schemas/PlayerLevel"
        image:
          $ref: "#/components/schemas/Image"
          type: object
          readOnly: true
        posterImage:
          $ref: "#/components/schemas/Image"
        venues:
          type: array
          items:
            $ref: "#/components/schemas/CompetitionVenue"
        uiConfigId:
          type: string
    CompetitionTable:
      type: object
      required:
      - siteId
      - tableRows
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
        extId:
          type: string
        competitionId:
          type: string
        competitionName:
          type: string
        competitionExtId:
          type: string
        siteId:
          type: string
        tableRows:
          type: array
          items:
            $ref: "#/components/schemas/CompetitionTableRow"
        created:
          $ref: "#/components/schemas/Date"
    CompetitionTableRow:
      type: object
      properties:
        position:
          type: integer
          format: int32
        played:
          type: integer
          format: int32
        won:
          type: integer
          format: int32
        draws:
          type: integer
          format: int32
        lost:
          type: integer
          format: int32
        points:
          type: integer
          format: int32
        goalsFor:
          type: integer
          format: int32
        goalsAgainst:
          type: integer
          format: int32
        group:
          $ref: "#/components/schemas/Group"
    CompetitionTeam:
      type: object
      required:
      - competitionId
      - siteId
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
        teamExtId:
          type: string
        teamName:
          type: string
        groupId:
          type: string
        groupExtId:
          type: string
        competitionId:
          type: string
        logo:
          $ref: "#/components/schemas/Image"
        shortName:
          type: string
        homeHex:
          type: string
        awayHex:
          type: string
        siteId:
          type: string
    CompetitionVenue:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        extId:
          type: string
    Date:
      type: string
      format: date
      examples:
      - 2022-03-10
    Gender:
      type: string
      enum:
      - MALE
      - FEMALE
      - MIXED
    Group:
      type: object
      properties:
        externalId:
          type: string
        id:
          type: string
        level1:
          type: string
        level2:
          type: string
        logo:
          $ref: "#/components/schemas/Image"
        name:
          type: string
        parentId:
          type: string
        primaryHex:
          type: string
        secondaryHex:
          type: string
        shortName:
          type: string
        teamExtId:
          type: string
        teamId:
          type: string
        teamName:
          type: string
    Image:
      type: object
      properties:
        blobId:
          type: string
        blobPath:
          type: string
        id:
          type: string
        mimeType:
          type: string
        url:
          type: string
    Location:
      type: object
      properties:
        level1:
          type: string
          readOnly: true
        level2:
          type: string
          readOnly: true
    ObjectId:
      type: string
      format: ObjectId
      description: MongoDB ObjectId represented as a string.
    PlayerLevel:
      type: object
      required:
      - name
      - gender
      - category
      properties:
        name:
          type: string
        extId:
          type: string
        maxAge:
          type: integer
          format: int32
        gender:
          $ref: "#/components/schemas/Gender"
        category:
          $ref: "#/components/schemas/AgeCategory"
    Season:
      type: object
      required:
      - name
      - start
      - end
      - siteId
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
        name:
          type: string
        extId:
          type: string
        start:
          $ref: "#/components/schemas/Date"
        end:
          $ref: "#/components/schemas/Date"
        siteId:
          type: string
    SortOrder:
      type: string
      enum:
      - Ascending
      - Descending
    Type:
      type: string
      enum:
      - SERIES
      - CUP
      - TOURNAMENT
      - OFF_SEASON
      - PRE_SEASON
      - PRACTICE_MATCH
  securitySchemes:
    SecurityScheme:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Authentication
paths:
  /competition:
    put:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Competition"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Competition"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Update Competition
      tags:
      - Competition Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
        - Member
    patch:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Competition"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Competition"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Patch Competition
      tags:
      - Competition Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
        - Member
    get:
      parameters:
      - name: age
        in: query
        schema:
          type: array
          items:
            type: integer
            format: int32
      - name: age-category
        in: query
        schema:
          type: array
          items:
            $ref: "#/components/schemas/AgeCategory"
      - name: competition-id
        in: query
        schema:
          type: array
          items:
            type: string
      - name: end-from
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      - name: end-to
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      - name: external-id
        in: query
        schema:
          type: array
          items:
            type: string
      - name: from
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      - name: gender
        in: query
        schema:
          type: array
          items:
            $ref: "#/components/schemas/Gender"
      - name: level1
        in: query
        schema:
          type: string
      - name: level2
        in: query
        schema:
          type: string
      - name: name
        in: query
        schema:
          type: string
      - name: origin
        in: query
        schema:
          type: string
      - name: page-index
        in: query
        schema:
          type: integer
          format: int32
          minimum: 0
      - name: page-size
        in: query
        schema:
          type: integer
          format: int32
          minimum: 0
      - name: player-level-name
        in: query
        schema:
          type: array
          items:
            type: string
      - name: site-id
        in: query
        schema:
          type: array
          items:
            type: string
      - name: sort-column
        in: query
        schema:
          type: string
      - name: sort-order
        in: query
        schema:
          $ref: "#/components/schemas/SortOrder"
      - name: to
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      - name: type
        in: query
        schema:
          type: array
          items:
            $ref: "#/components/schemas/Type"
      - name: site-id
        in: header
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Competition"
      summary: Get Competitions
      tags:
      - Competition Resource
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Competition"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Competition"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Create Competition
      tags:
      - Competition Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
  /competition/season:
    put:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Season"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Season"
        "400":
          description: Bad Request
      summary: Update Season
      tags:
      - Season Resource
    patch:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Season"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Season"
      summary: Patch Season
      tags:
      - Season Resource
    get:
      parameters:
      - name: ext-id
        in: query
        schema:
          type: string
      - name: name
        in: query
        schema:
          type: string
      - name: page-index
        in: query
        schema:
          type: integer
          format: int32
      - name: page-size
        in: query
        schema:
          type: integer
          format: int32
      - name: site-id
        in: query
        schema:
          type: string
      - name: sort-column
        in: query
        schema:
          type: string
      - name: sort-order
        in: query
        schema:
          $ref: "#/components/schemas/SortOrder"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Season"
      summary: Get Seasons
      tags:
      - Season Resource
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Season"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Season"
        "400":
          description: Bad Request
      summary: Create Season
      tags:
      - Season Resource
  /competition/season/{seasonId}:
    get:
      parameters:
      - name: seasonId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Season"
      summary: Get Season
      tags:
      - Season Resource
    delete:
      parameters:
      - name: seasonId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: boolean
      summary: Delete Season
      tags:
      - Season Resource
  /competition/table:
    put:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompetitionTable"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompetitionTable"
        "400":
          description: Bad Request
      summary: Update Competition Table
      tags:
      - Competition Table Resource
    get:
      parameters:
      - name: competition-ext-id
        in: query
        schema:
          type: string
      - name: competition-id
        in: query
        schema:
          type: string
      - name: from
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      - name: page-index
        in: query
        schema:
          type: integer
          format: int32
      - name: page-size
        in: query
        schema:
          type: integer
          format: int32
      - name: site-id
        in: query
        schema:
          type: string
      - name: sort-column
        in: query
        schema:
          type: string
      - name: sort-order
        in: query
        schema:
          $ref: "#/components/schemas/SortOrder"
      - name: to
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      - name: site-id
        in: header
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/CompetitionTable"
      summary: Get Competition Table
      tags:
      - Competition Table Resource
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompetitionTable"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompetitionTable"
        "400":
          description: Bad Request
      summary: Create Competition Table
      tags:
      - Competition Table Resource
  /competition/table/{id}:
    get:
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompetitionTable"
      summary: Get Competition Table By Id
      tags:
      - Competition Table Resource
    delete:
      parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: boolean
      summary: Delete Competition Table
      tags:
      - Competition Table Resource
  /competition/team:
    put:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompetitionTeam"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompetitionTeam"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Update Competition Team
      tags:
      - Competition Team Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
    patch:
      requestBody:
        content:
          application/json:
            schema:
              type: string
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompetitionTeam"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Patch Competition Team
      tags:
      - Competition Team Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
    get:
      parameters:
      - name: competition-group-id
        in: query
        schema:
          type: string
      - name: competition-id
        in: query
        schema:
          type: string
      - name: group-ext-id
        in: query
        schema:
          type: string
      - name: group-id
        in: query
        schema:
          type: string
      - name: site-id
        in: query
        schema:
          type: string
      - name: team-ext-id
        in: query
        schema:
          type: string
      - name: team-name
        in: query
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/CompetitionTeam"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Get Competition Teams
      tags:
      - Competition Team Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CompetitionTeam"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompetitionTeam"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Create Competition Team
      tags:
      - Competition Team Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
  /competition/team/{competitionGroupId}:
    get:
      parameters:
      - name: competitionGroupId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompetitionTeam"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Get Competition Team
      tags:
      - Competition Team Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
    delete:
      parameters:
      - name: competitionGroupId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: boolean
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Delete Competition Team
      tags:
      - Competition Team Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
  /competition/{competitionId}:
    get:
      parameters:
      - name: competitionId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Competition"
      summary: Get Competition
      tags:
      - Competition Resource
    delete:
      parameters:
      - name: competitionId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: boolean
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Delete Competition
      tags:
      - Competition Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
  /competition/{competitionId}/table:
    get:
      parameters:
      - name: competitionId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/CompetitionTable"
      summary: Get Competition Table By Competition Id
      tags:
      - Competition Table Resource
info:
  title: Competition Service API
  version: 1.0.0-SNAPSHOT
