openapi: 3.1.0
info:
  title: API nextbike_v1 1.0.0
  version: 1.0.0
servers:
- url: https://data.movemore.hs-offenburg.de/api/nextbike/v1
paths:
  /health:
    get:
      description: Test if server is responsive.
      responses:
        "200":
          content:
            text/plain:
              schema:
                type: string
          description: Server healthy
        "404":
          description: Server not healty
  /tracker:
    get:
      description: Get Tracker by field value
      parameters:
      - explode: true
        in: query
        name: name
        required: false
        schema:
          type: string
        style: form
      - explode: true
        in: query
        name: eui
        required: false
        schema:
          type: integer
        style: form
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Tracker"
          description: Tracker retrieved
        "404":
          description: Tracker does not exist
    put:
      description: |
        Create or or update Tracker

        If the object id is zero, the object is inserted and the new id is filled into the returned object.

        If the object id is non-zero, the object is updated and returned.
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Tracker"
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Tracker"
          description: Tracker updated
        "201":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Tracker"
          description: Tracker created
        "422":
          description: Tracker is invalid
  /tracker/{id}:
    delete:
      description: Delete Tracker by database id
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          type: integer
        style: simple
      responses:
        "204":
          description: Tracker deleted
        "404":
          description: Tracker does not exist
    get:
      description: Get Tracker by database id
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          type: integer
        style: simple
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Tracker"
          description: Tracker retrieved
        "404":
          description: Tracker does not exist
  /tracker/{id}/values:
    get:
      description: Get list of Measurement from Tracker by database id
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          type: integer
        style: simple
      responses:
        "200":
          content:
            application/json:
              schema:
                items:
                  $ref: "#/components/schemas/Measurement"
                type: array
          description: List of Measurement retrieved
        "404":
          description: Tracker does not exist
    put:
      description: Add list of Measurement to Tracker by database id
      parameters:
      - explode: false
        in: path
        name: id
        required: true
        schema:
          type: integer
        style: simple
      requestBody:
        content:
          application/json:
            schema:
              items:
                $ref: "#/components/schemas/Measurement"
              type: array
      responses:
        "200":
          description: Tracker updated
        "404":
          description: Tracker does not exist
        "422":
          description: Tracker is invalid
  /tracker_list:
    get:
      description: Get list of all Tracker
      responses:
        "200":
          content:
            application/json:
              schema:
                items:
                  $ref: "#/components/schemas/Tracker"
                type: array
          description: List of Tracker retrieved
components:
  schemas:
    Measurement:
      example:
        light: 1.4658129
        latitude: 6.0274563
        utcTime: utcTime
        temperature: 5.637377
        battery: 0
        longitude: 5.962134
      properties:
        battery:
          description: Battery charge state (unit %)
          title: battery
          type: integer
        latitude:
          description: Current latitude of tracker (unit °)
          format: float
          title: latitude
          type: number
        light:
          description: Light (unit ?)
          format: float
          title: light
          type: number
        longitude:
          description: Current longitude of tracker (unit °)
          format: float
          title: longitude
          type: number
        temperature:
          description: Temperature (unit °C)
          format: float
          title: temperature
          type: number
        utcTime:
          description: UTC time of measurement
          title: utcTime
          type: string
      required:
      - utcTime
      title: Measurement
    Tracker:
      example:
        lastSeen: lastSeen
        ttnAppId: ttnAppId
        eui: 0
        lastBattery: 1
        name: name
        id: 6
        state: positioning_timeout
        lastJoin: lastJoin
      properties:
        eui:
          description: The EUI of the tracker
          format: int64
          title: eui
          type: integer
        id:
          default: 0
          title: id
          type: integer
        lastBattery:
          description: Last battery charge state (unit %)
          title: lastBattery
          type: integer
        lastJoin:
          description: The last join time
          title: lastJoin
          type: string
        lastSeen:
          description: The time of the last message
          title: lastSeen
          type: string
        name:
          description: The name/id of the tracker
          title: name
          type: string
        state:
          description: The last known state of the tracker
          enum:
          - positioning_timeout
          - tracking
          title: state
          type: string
        ttnAppId:
          description: The TTN application ID of the tracker
          title: ttnAppId
          type: string
      required:
      - eui
      - name
      - ttnAppId
      title: Tracker
