openapi: 3.0.0
info:
  description: The API for Mobile Notification Services in the ThingPark X Platform
  version: 1.4.0
  title: Thingpark X Notification Module API
externalDocs:
  description: For more information, please check the online examples in this documentation.
  url: '/location-notification/latest/doc/index.html'
tags:
  - name: Mobile Device
    description: Operations for Mobile Device
paths:
  /register/userDeviceApp:
    post:
      tags:
        - Mobile Device
      summary: Register Mobile Device App
      description: Register Mobile Device App in the platform
      operationId: registerUserDeviceApp
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MobileDeviceInfo'
      responses:
        '201':
          description: successfully registered device app
        '401':
          description: unauthorized - invalid token
        '403':
          description: forbidden - device already registered
      security:
        - bearerAuth: []
          Dx-Admin: []
          keycloak: []
    put:
      tags:
        - Mobile Device
      summary: Update Mobile Device App
      description: Update Registration Token for a given mobile device
      operationId: updateDeviceToken
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MobileDeviceInfo'
      responses:
        '200':
          description: successfully updated device app
        '401':
          description: unauthorized - invalid token
        '404':
          description: not found - the requested device app does not exsit
        '409':
          description: conflict- modification in conflict with current device information
      security:
        - bearerAuth: []
          Dx-Admin: []
          keycloak: []
  /userDeviceApp:
    get:
      tags:
        - Mobile Device
      summary: Get Mobile Device App Info
      description: Get a given mobile device Info
      operationId: getDeviceToken
      parameters:
        - name: appId
          in: query
          description: app id of the current app
          required: false
          schema:
            type: string
      responses:
        '200':
          description: list of mobile devices
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MobileDevices'
        '400':
          description: Invalid device id supplied
        '401':
          description: Unauthorized - invalid api key
      security:
        - bearerAuth: []
          Dx-Admin: []
          keycloak: []
  /userDeviceApp/{appId}/mobileDevice/{mobileDeviceID}:
    delete:
      tags:
        - Mobile Device
      summary: Delete Mobile Device App
      description: Delete a given mobile device
      operationId: deleteDeviceToken
      parameters:
        - name: mobileDeviceID
          in: path
          description: Device id to delete
          required: true
          schema:
            type: string
        - name: appId
          in: path
          description: app id of the current app
          required: true
          schema:
            type: string
        - name: userEmail
          in: query
          description: user email in case the user is not authenticated
          required: false
          schema:
            type: string
        - name: realmId
          in: query
          description: realm Id of the user in case the user is not authenticated
          required: false
          schema:
            type: string
        - name: registration_token
          in: query
          description: registration_token in case the user is not authenticated
          required: false
          schema:
            type: string
      responses:
        '204':
          description: Mobile device deleted
        '400':
          description: Invalid device id supplied
        '401':
          description: Unauthorized - invalid api key
        '403':
          description: Validation Error - device association check failure
        '404':
          description: Device not found
      security:
        - bearerAuth: []
          Dx-Admin: []
          keycloak: []
servers:
  - url: '/location-notification/latest/api'
components:
  requestBodies:
    MobileDeviceInfo:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MobileDeviceInfo'
      required: true
  securitySchemes:
    bearerAuth:
      description: 'Enter your access token here without prefix "bearer " '
      type: http
      scheme: bearer
      bearerFormat: JWT
    keycloak:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: '/auth/realms//protocol/openid-connect/auth'
          scopes: {}
    Dx-Admin:
      type: oauth2
      description: |
        **This authorization is deprecated. Service account authentication should be used.**

        Enter your ThingPark credentials with dx-profile-id as prefix. 

        Example: dev1-api/test@abeeway.com
      flows:
        clientCredentials:
          tokenUrl: '/admin/latest/api/oauth/token'
          scopes: {}
  schemas:
    MobileDevices:
      type: array
      items:
        $ref: '#/components/schemas/MobileDeviceInfo'
    MobileDeviceInfo:
      type: object
      required:
        - appOS
        - registration_token
        - appID
        - mobileDeviceID
      properties:
        appOS:
          type: string
          enum:
            - IOS
            - ANDROID
        registration_token:
          type: string
          example: 0729a580-2240-11e6-9eb5-0002a5d5c51b
        appID:
          type: string
          description: the app's bundle id of IOS or a unique id for android
          example: com.foocompany.appname
        mobileDeviceID:
          type: string
          description: the mobile device unique id, ex. serial number
          example: abcdef