Class: Insnergy::Client::Widgets

Inherits:
Object
  • Object
show all
Defined in:
lib/insnergy-api-ruby-client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client: nil, category: nil) ⇒ Widgets

Returns a new instance of Widgets.



69
70
71
72
73
74
75
76
# File 'lib/insnergy-api-ruby-client.rb', line 69

def initialize(client: nil,category: nil)
  @access_token = client.access_token
  @user_id = client.user_id
  @domain = client.domain
  @category = category
  @response = nil
  response!
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



66
67
68
# File 'lib/insnergy-api-ruby-client.rb', line 66

def category
  @category
end

#clientObject

Returns the value of attribute client.



66
67
68
# File 'lib/insnergy-api-ruby-client.rb', line 66

def client
  @client
end

#responseObject (readonly)

Returns the value of attribute response.



67
68
69
# File 'lib/insnergy-api-ruby-client.rb', line 67

def response
  @response
end

Instance Method Details

#response!Object



78
79
80
81
82
83
# File 'lib/insnergy-api-ruby-client.rb', line 78

def response!
  parameter = {:params => {:apsystem => "IFA", :email => @user_id, :type_code => 1, :dev_category => "#{@category}"}, :Authorization => "Bearer #{@access_token}"}
  @response = JSON.parse(RestClient.get "#{@domain}/if/3/user/widgets", parameter)
  raise "#{response['err']['code']}" unless response['err']['code'] == '0'  
  @response
end