Class: NatureRemoApi::Client
- Inherits:
-
Object
- Object
- NatureRemoApi::Client
- Includes:
- Endpoints
- Defined in:
- lib/nature_remo_api/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
TODO: NatureRemoApi::Config::ATTRIBUTESを下記に設定できるようにする.
-
#client ⇒ Object
TODO: NatureRemoApi::Config::ATTRIBUTESを下記に設定できるようにする.
-
#default_max_retries ⇒ Object
TODO: NatureRemoApi::Config::ATTRIBUTESを下記に設定できるようにする.
-
#endpoint ⇒ Object
TODO: NatureRemoApi::Config::ATTRIBUTESを下記に設定できるようにする.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Methods included from Endpoints::Signal
Methods included from Endpoints::Appliance
Methods included from Endpoints::Device
Methods included from Endpoints::User
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nature_remo_api/client.rb', line 13 def initialize( = {}) NatureRemoApi::Config::ATTRIBUTES.each do |key| send("#{key}=", .fetch(key, NatureRemoApi.config.send(key))) end @access_token ||= NatureRemoApi.config.access_token @client = Faraday.new(url: endpoint) do |conn| conn.request :json conn.response :mashify conn.response :json, :content_type => /\bjson$/ conn.adapter Faraday.default_adapter end @client.headers['Authorization'] = "Bearer #{access_token}" end |
Instance Attribute Details
#access_token ⇒ Object
TODO: NatureRemoApi::Config::ATTRIBUTESを下記に設定できるようにする
11 12 13 |
# File 'lib/nature_remo_api/client.rb', line 11 def access_token @access_token end |
#client ⇒ Object
TODO: NatureRemoApi::Config::ATTRIBUTESを下記に設定できるようにする
11 12 13 |
# File 'lib/nature_remo_api/client.rb', line 11 def client @client end |
#default_max_retries ⇒ Object
TODO: NatureRemoApi::Config::ATTRIBUTESを下記に設定できるようにする
11 12 13 |
# File 'lib/nature_remo_api/client.rb', line 11 def default_max_retries @default_max_retries end |
#endpoint ⇒ Object
TODO: NatureRemoApi::Config::ATTRIBUTESを下記に設定できるようにする
11 12 13 |
# File 'lib/nature_remo_api/client.rb', line 11 def endpoint @endpoint end |