#%RAML 0.8
title: Battery
version: v1.2.0-20170814
documentation:
  - title: (c) 2016, 2017 Open Connectivity Foundation, Inc. All rights reserved.
    content: |
        Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
        1.  Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
        2.  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

        THIS SOFTWARE IS PROVIDED BY THE Open Connectivity Foundation, INC. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE OR WARRANTIES OF NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE Open Connectivity Foundation, INC. OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
schemas:
  - Battery:   !include oic.r.energy.battery.json
  - BatteryUpdate: !include oic.r.energy.battery-Update.json

traits:
  - interface:
      queryParameters:
        if:
          enum: ["oic.if.rw","oic.if.baseline"]

/BatteryResURI:
  description: |
    This resource describes the attributes associated with a battery. The charge is an integer showing the current battery charge level as a percentage in the range 0 (fully discharged) to 100 (fully charged). The capacity represents the total capacity of battery in Amp Hours (Ah). The charging status and discharging status are represented by boolean values set to "True" indicating enabled and "False" indicating disabled. Low battery status is represented by a boolean value set to "True" indicating low charge level and "False" indicating otherwise, based upon the battery threshold represented as a percentage.
  displayName: Battery
  is: [ interface ] # valid for all methods

  get:
    description: |
      Retrieves the state of the battery.
    responses:
      200:
        body:
          application/json:
            schema: Battery
            example: |
              {
                "rt":     ["oic.r.energy.battery"],
                "id":     "unique_example_id",
                "charge": 50,
                "capacity": 3000,
                "charging": true,
                "discharging": false,
                "lowbattery": false,
                "batterythreshold": 20
              }
  post:
    description: |
      Sets current battery values
    body:
      application/json:
        schema: BatteryUpdate
        example: |
          {
            "id":         "unique_example_id",
            "batterythreshold": 20
          }
    responses:
      200:
        body:
          application/json:
            schema: BatteryUpdate
            example: |
              {
                "id":          "unique_example_id",
                "batterythreshold": 20
              }
