---
openapi: 3.1.0
components:
  schemas:
    Access:
      type: object
      properties:
        permission:
          $ref: "#/components/schemas/Permission"
        targetAction:
          $ref: "#/components/schemas/TargetAction"
    Address:
      type: object
      properties:
        country:
          type: string
        address:
          type: string
        city:
          type: string
        postalCode:
          type: string
    ApiAccessToken:
      type: object
      properties:
        token:
          type: string
        domain:
          $ref: "#/components/schemas/TokenDomain"
        domainId:
          type: string
        target:
          $ref: "#/components/schemas/Target"
        targetId:
          type: string
        metaData:
          type: object
          additionalProperties:
            type: string
    ApiRoleAccessToken:
      type: object
      properties:
        token:
          type: string
        email:
          type: string
        siteId:
          type: string
        metaData:
          type: string
        targetType:
          $ref: "#/components/schemas/TargetType1"
        targetId:
          type: string
        role:
          $ref: "#/components/schemas/Role"
        accesses:
          type: array
          items:
            $ref: "#/components/schemas/Access"
        fullAccess:
          type: boolean
        type:
          $ref: "#/components/schemas/RoleAccessTokenType"
    CreateUserRequest:
      type: object
      required:
      - emailAddress
      - firstName
      - lastName
      properties:
        emailAddress:
          type: string
        password:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        affiliateId:
          type: string
        siteId:
          type: string
        kickbackGroup:
          $ref: "#/components/schemas/KickbackGroup"
        favorites:
          type: array
          items:
            $ref: "#/components/schemas/UserFavoriteDeprecated"
        domain:
          type: string
        sendResetPasswordMail:
          type: boolean
        dateOfBirth:
          $ref: "#/components/schemas/Date"
        gender:
          $ref: "#/components/schemas/Gender"
        address:
          $ref: "#/components/schemas/Address"
        location:
          $ref: "#/components/schemas/GeoJson"
    Date:
      type: string
      format: date
      examples:
      - 2022-03-10
    DeprecatedFavoriteType:
      type: string
      enum:
      - CLUB
      - COMPETITION
      - TEAM
      - EVENT
      - CONTENT
    FavoriteType:
      type: string
      enum:
      - CLUB
      - COMPETITION
      - TEAM
      - PERSON
      - SITE_ITEM
    Feature:
      type: object
      required:
      - name
      properties:
        limit:
          type: integer
          format: int32
        stock:
          type: integer
          format: int32
        targetId:
          type: string
        targetType:
          $ref: "#/components/schemas/TargetType"
        data:
          type: object
          additionalProperties:
            type: string
        name:
          type: string
    Gender:
      type: string
      enum:
      - MALE
      - FEMALE
      - OTHER
    GeoJson:
      type: object
      required:
      - type
      - coordinates
      properties:
        type:
          $ref: "#/components/schemas/GeoJsonType"
        coordinates:
          type: array
          maxItems: 2
          minItems: 2
          items:
            type: number
            format: double
    GeoJsonType:
      type: string
      enum:
      - Point
    Image:
      type: object
      properties:
        id:
          type: string
        blobId:
          type: string
        blobPath:
          type: string
        mimeType:
          type: string
        url:
          type: string
    KickbackGroup:
      type: object
      required:
      - id
      properties:
        name:
          type: string
        slug:
          type: string
        externalId:
          type: string
        id:
          type: string
    LoginRequest:
      type: object
      properties:
        userName:
          type: string
        password:
          type: string
        roleAccessToken:
          type: string
    LoginResponse:
      type: object
      properties:
        siteIds:
          type: array
          items:
            type: string
        message:
          type: string
        status:
          type: string
        jwt_token:
          type: string
    ObjectId:
      type: object
      properties:
        timestamp:
          type: integer
          format: int32
        nonce:
          type: integer
          format: int64
        date:
          $ref: "#/components/schemas/Date"
    Permission:
      type: string
      enum:
      - READ
      - WRITE
    Preference:
      type: object
      properties:
        key:
          type: string
        value:
          type: string
    Role:
      type: string
      enum:
      - Viewer
      - Admin
      - TeamAccount
      - System
      - SuperAdmin
      - DataProvider
      - Member
      - Marketeer
      - Payee
    RoleAccessToken:
      type: object
      required:
      - siteId
      - type
      - validTo
      - targetType
      - role
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
        name:
          type: string
        token:
          type: string
        siteId:
          type: string
        type:
          $ref: "#/components/schemas/RoleAccessTokenType"
        validTo:
          $ref: "#/components/schemas/Date"
        usesRemaining:
          type: integer
          format: int32
        redemptions:
          type: integer
          format: int32
        metaData:
          type: object
          additionalProperties:
            type: string
        createdByUserId:
          type: string
        created:
          $ref: "#/components/schemas/Date"
        targetType:
          $ref: "#/components/schemas/TargetType1"
        targetId:
          type: string
        role:
          $ref: "#/components/schemas/Role"
        accesses:
          type: array
          items:
            $ref: "#/components/schemas/Access"
        fullAccess:
          type: boolean
    RoleAccessTokenType:
      type: string
      enum:
      - ANONYMOUS
      - TEMPORARY
      - PERMANENT
    SortOrder:
      type: string
      enum:
      - Ascending
      - Descending
    Status:
      type: string
      enum:
      - CANCELED
      - PAYMENT_FAILED
      - ACTIVE
      - ENDED
      - PENDING
    Target:
      type: string
      enum:
      - COMP
      - BRO
      - SITE
    TargetAction:
      type: string
      enum:
      - PRO_COMMENTARY
      - PRO_FILM
      - PRO_GRAPHICS
      - PRO_BROADCAST
      - PS_CAMPAIGNS
      - PS_VIDEO_CAMPAIGNS
      - PS_ORGANISATIONS
      - PS_USERS
      - BO_BROADCASTS
      - BO_VENUES
      - BO_COMPETITIONS
      - BO_AUDIT_LOG
      - BO_GROUPS
      - BO_FEATURES
      - BO_CAMERAS
      - BO_USERS
      - BO_SITE
      - BO_PAYMENTS
    TargetType:
      type: string
      enum:
      - BROADCAST
      - COMPETITION
      - SITE
      - EXTERNAL
    TargetType1:
      type: string
      enum:
      - GROUP
      - COMPETITION
      - BROADCAST
      - SITE_ITEM
      - ORGANISATION
      - SITE_SPONSOR
      - SITE
      - AFFILIATE
      - PARTNER
      - VENUE
    TokenDomain:
      type: string
      enum:
      - DOWNLOAD
      - ACTIVATE
    User:
      type: object
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
        emailAddress:
          type: string
        firstName:
          type: string
        lastName:
          type: string
        externalId:
          type: string
        siteId:
          type: string
        affiliateId:
          type: string
        roles:
          type: array
          items:
            $ref: "#/components/schemas/Role"
        emailVerified:
          type: string
        termsAccepted:
          type: boolean
        locale:
          type: string
        preferences:
          type: array
          items:
            $ref: "#/components/schemas/Preference"
        favorites:
          type: array
          items:
            $ref: "#/components/schemas/UserFavoriteDeprecated"
        products:
          type: array
          items:
            type: string
        kickbackGroup:
          $ref: "#/components/schemas/KickbackGroup"
        image:
          $ref: "#/components/schemas/Image"
        created:
          $ref: "#/components/schemas/Date"
        updated:
          $ref: "#/components/schemas/Date"
        dateOfBirth:
          $ref: "#/components/schemas/Date"
        gender:
          $ref: "#/components/schemas/Gender"
        address:
          $ref: "#/components/schemas/Address"
        location:
          $ref: "#/components/schemas/GeoJson"
    UserAccess:
      type: object
      required:
      - userId
      - siteId
      - features
      - status
      - validTo
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
        userId:
          type: string
        siteId:
          type: string
        productId:
          type: string
        features:
          type: array
          minItems: 1
          items:
            $ref: "#/components/schemas/Feature"
        extId:
          type: string
        status:
          $ref: "#/components/schemas/Status"
        isCanceled:
          type: boolean
          deprecated: true
        validTo:
          $ref: "#/components/schemas/Date"
        created:
          $ref: "#/components/schemas/Date"
        updated:
          $ref: "#/components/schemas/Date"
        canceled:
          type: boolean
    UserFavorite:
      type: object
      required:
      - siteId
      properties:
        id:
          $ref: "#/components/schemas/ObjectId"
        image:
          $ref: "#/components/schemas/Image"
        siteId:
          type: string
        userId:
          type: string
        type:
          $ref: "#/components/schemas/FavoriteType"
    UserFavoriteDeprecated:
      type: object
      properties:
        name:
          type: string
        slug:
          type: string
        bgImageUrl:
          type: string
        category:
          type: string
        subCategory:
          type: string
        externalId:
          type: string
        targetId:
          type: string
        type:
          $ref: "#/components/schemas/DeprecatedFavoriteType"
        image:
          $ref: "#/components/schemas/Image"
    ViewerToken:
      type: object
      properties:
        token:
          type: string
        validTo:
          $ref: "#/components/schemas/Date"
    ViewerTokenRequest:
      type: object
      required:
      - siteId
      - userId
      properties:
        siteId:
          type: string
        userId:
          type: string
        groupId:
          type: string
  securitySchemes:
    SecurityScheme:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Authentication
paths:
  /user:
    post:
      parameters:
      - name: User-Agent
        in: header
        schema:
          type: string
      - name: site-id
        in: header
        schema:
          type: string
        required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateUserRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/User"
        "400":
          description: Bad Request
      summary: Create User
      tags:
      - User Resource
  /user/access:
    get:
      parameters:
      - name: ext-id
        in: query
        schema:
          type: string
      - name: feature-type
        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: product-id
        in: query
        schema:
          type: array
          items:
            type: string
      - 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: status
        in: query
        schema:
          type: array
          items:
            $ref: "#/components/schemas/Status"
      - name: target-id
        in: query
        schema:
          type: string
      - name: target-type
        in: query
        schema:
          $ref: "#/components/schemas/TargetType"
      - name: to
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      - name: user-id
        in: query
        schema:
          type: string
      - name: valid-from
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      - name: valid-to
        in: query
        schema:
          $ref: "#/components/schemas/Date"
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/UserAccess"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Get User Access
      tags:
      - User Access Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
  /user/access-token/meta-data:
    get:
      parameters:
      - name: token
        in: query
        schema:
          type: string
      - name: site-id
        in: header
        schema:
          type: string
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiAccessToken"
      summary: Get Activate User Meta Data
      tags:
      - Access Token Resource
  /user/access/valid:
    get:
      parameters:
      - name: user-id
        in: query
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/UserAccess"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Get User Access
      tags:
      - User Access Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
  /user/activate:
    post:
      parameters:
      - name: token
        in: query
        schema:
          type: array
          items:
            type: string
      - name: User-Agent
        in: header
        schema:
          type: string
      - name: site-id
        in: header
        schema:
          type: string
        required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateUserRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LoginResponse"
        "400":
          description: Bad Request
      summary: Activate User
      tags:
      - Activate User Resource
  /user/favorite:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              type: string
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserFavorite"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Patch User Favorite
      tags:
      - User Favorite Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
    get:
      parameters:
      - name: group-id
        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"
      - name: type
        in: query
        schema:
          type: array
          items:
            $ref: "#/components/schemas/FavoriteType"
      - name: user-id
        in: query
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: "#/components/schemas/UserFavorite"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Get User Favorites
      tags:
      - User Favorite Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UserFavorite"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserFavorite"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Create User Favorite
      tags:
      - User Favorite Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
  /user/favorite/{userFavoriteId}:
    get:
      parameters:
      - name: userFavoriteId
        in: path
        required: true
        schema:
          type: string
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/UserFavorite"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
      summary: Get User Favorite
      tags:
      - User Favorite Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
    delete:
      parameters:
      - name: userFavoriteId
        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 User Favorite
      tags:
      - User Favorite Resource
      security:
      - SecurityScheme:
        - System
        - SuperAdmin
        - Admin
        - Member
        - Viewer
  /user/login:
    post:
      parameters:
      - name: site-id
        in: header
        schema:
          type: string
        required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LoginRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LoginResponse"
        "400":
          description: Bad Request
      summary: Login
      tags:
      - User Resource
  /user/role-access/token:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RoleAccessToken"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/RoleAccessToken"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Create Role Access Token
      tags:
      - Role Access Token Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - Admin
        - Member
  /user/role-access/token/meta-data:
    get:
      parameters:
      - name: token
        in: query
        schema:
          type: string
      - name: site-id
        in: header
        schema:
          type: string
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ApiRoleAccessToken"
      summary: Get Token Meta Data
      tags:
      - Role Access Token Resource
  /user/role-access/token/redeem:
    post:
      parameters:
      - name: site-id
        in: header
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ApiRoleAccessToken"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/LoginResponse"
        "400":
          description: Bad Request
      summary: Redeem Role Access Token
      tags:
      - Role Access Token Resource
  /user/viewer-token:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ViewerTokenRequest"
        required: true
      responses:
        "200":
          description: OK
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ViewerToken"
        "401":
          description: Not Authorized
        "403":
          description: Not Allowed
        "400":
          description: Bad Request
      summary: Create Viewer Token
      tags:
      - User Resource
      security:
      - SecurityScheme:
        - SuperAdmin
        - Admin
info:
  title: User Service API
  version: 1.0-SNAPSHOT
