---
openapi: 3.1.0
components:
  schemas:
    Date:
      type: string
      format: date
      examples:
      - 2022-03-10
    ExtGroup:
      type: object
      required:
      - externalId
      - siteId
      properties:
        externalId:
          type: string
        siteId:
          type: string
        name:
          type: string
        shortName:
          type: string
        longName:
          type: string
        type:
          $ref: "#/components/schemas/GroupType"
        homeHex:
          type: string
        awayHex:
          type: string
        logo:
          $ref: "#/components/schemas/ExtImage"
        secondaryLogo:
          $ref: "#/components/schemas/ExtImage"
    ExtImage:
      type: object
      properties:
        url:
          type: string
    Group:
      type: object
      required:
      - name
      - shortName
      - siteId
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
          type: object
          description: Internal id
        name:
          type: string
        shortName:
          type: string
          minLength: 3
          maxLength: 5
          description: FBOK
        longName:
          type: string
        parentId:
          $ref: "#/components/schemas/ObjectId"
          type: object
          description: The parent item in the site structure
        level1:
          $ref: "#/components/schemas/ObjectId"
        level2:
          $ref: "#/components/schemas/ObjectId"
        type:
          $ref: "#/components/schemas/GroupType"
        externalId:
          type: string
          description: Your unique id
        siteId:
          type: string
        homeHex:
          type: string
          description: Hex code for when playing as home team shown in broadcasts
        awayHex:
          type: string
          description: Hex code for when playing as away team shown in broadcasts
        posterImage:
          $ref: "#/components/schemas/Image"
    GroupType:
      type: string
      enum:
      - TEAM
      - CLUB
      - NATIONAL
      - DISTRICT
    Image:
      type: object
      properties:
        id:
          type: string
        blobId:
          type: string
        mimeType:
          type: string
        url:
          type: string
    ObjectId:
      type: string
      format: ObjectId
      description: MongoDB ObjectId represented as a string.
    SortOrder:
      type: string
      enum:
      - Ascending
      - Descending
  securitySchemes:
    SecurityScheme:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Authentication
paths:
  /group:
    put:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Group"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Group"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Update Group
      tags:
      - Group Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
    patch:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Group"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Group"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Patch Group
      tags:
      - Group Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
    get:
      parameters:
      - name: external-id
        in: query
        schema:
          type: array
          items:
            type: string
      - name: group-id
        in: query
        schema:
          type: array
          items:
            type: string
      - name: include-orphans
        in: query
        schema:
          type: boolean
      - name: level1
        in: query
        schema:
          type: string
      - name: level2
        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: parent-id
        in: query
        schema:
          type: string
      - name: parentId
        in: query
        schema:
          type: string
      - name: pref-kickback
        in: query
        schema:
          type: boolean
      - name: search-string
        in: query
        schema:
          type: string
      - name: searchString
        in: query
        schema:
          type: string
      - name: short-name
        in: query
        schema:
          type: string
      - name: shortName
        in: query
        schema:
          type: string
      - name: site-id
        in: query
        schema:
          type: array
          items:
            type: string
      - name: slug
        in: query
        schema:
          type: string
      - name: sort-column
        in: query
        schema:
          type: string
      - name: sort-order
        in: query
        schema:
          $ref: "#/components/schemas/SortOrder"
      - name: type
        in: query
        schema:
          $ref: "#/components/schemas/GroupType"
      - name: site-id
        in: header
        schema:
          type: string
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/Group"
      summary: Get Groups
      tags:
      - Group Resource
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Group"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Group"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Create Group
      tags:
      - Group Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
  /group/ext:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ExtGroup"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Group"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Patch Group Ext
      tags:
      - Group Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ExtGroup"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Group"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Create Group Ext
      tags:
      - Group Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - System
        - Admin
  /group/{groupId}:
    get:
      parameters:
      - name: groupId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Group"
      summary: Get Group
      tags:
      - Group Resource
    delete:
      parameters:
      - name: groupId
        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 Group
      tags:
      - Group Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - Admin
info:
  title: Group Service API
  version: 1.2-SNAPSHOT
