Class: HomeWizard::Client

Inherits:
API
  • Object
show all
Defined in:
lib/homewizard/client.rb

Overview

Wrapper for the HomeWizard REST API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from API

#config

Constructor Details

#initialize(options = {}) ⇒ P1Client

get client to access P1 meter



12
13
14
15
16
17
18
19
# File 'lib/homewizard/client.rb', line 12

def initialize(options = {})
  # create client and copy access_token and set default headers
  super(options)
  @device_info = product_info
  puts "* probably incompatible api version" unless 'v1'.eql? product_info.api_version
rescue Faraday::ForbiddenError => e
  raise APInotEnabledError.new e.response[:body]['error']
end

Instance Attribute Details

#device_infoObject (readonly)

Returns the value of attribute device_info.



9
10
11
# File 'lib/homewizard/client.rb', line 9

def device_info
  @device_info
end

Class Method Details

.url(method) ⇒ Object

return api path



21
22
23
24
# File 'lib/homewizard/client.rb', line 21

def self.url(method)
  path = method ? "v1/#{method}" : ''
  "/api/#{path}"
end