Class: NatureRemo::Client
- Inherits:
-
Object
- Object
- NatureRemo::Client
- Includes:
- Endpoints
- Defined in:
- lib/nature_remo/client.rb
Overview
Client to send requests to Nature Remo cloud API
Constant Summary collapse
- BASE_URL =
'https://api.nature.global/'
- API_VERSION =
'1'
Instance Method Summary collapse
-
#initialize(access_token) ⇒ Client
constructor
A new instance of Client.
Methods included from Endpoints::Users
Methods included from Endpoints::Signals
#create_signal, #delete_signal, #send_signal, #signals, #update_signal, #update_signal_orders
Methods included from Endpoints::Devices
#delete_device, #devices, #update_device, #update_device_humidity_offset, #update_device_temperature_offset
Methods included from Endpoints::Appliances
#appliances, #create_appliance, #delete_appliance, #update_aircon_settings, #update_appliance, #update_appliance_orders, #update_light_state, #update_tv_state
Constructor Details
#initialize(access_token) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nature_remo/client.rb', line 13 def initialize(access_token) raise ArgumentError, 'argument access_token must not be nil' if access_token.nil? @client = Faraday.new(url: "#{BASE_URL}#{API_VERSION}/") do |conn| conn.request :json conn.response :json, content_type: /\bjson$/, parser_options: { symbolize_names: true } conn.adapter Faraday.default_adapter conn.use RaiseError end @client.headers['Authorization'] = "Bearer #{access_token}" end |