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.



85
86
87
88
89
90
91
92
# File 'lib/insnergy-api-ruby-client.rb', line 85

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.



82
83
84
# File 'lib/insnergy-api-ruby-client.rb', line 82

def category
  @category
end

#clientObject

Returns the value of attribute client.



82
83
84
# File 'lib/insnergy-api-ruby-client.rb', line 82

def client
  @client
end

#responseObject (readonly)

Returns the value of attribute response.



83
84
85
# File 'lib/insnergy-api-ruby-client.rb', line 83

def response
  @response
end

Instance Method Details

#response!Object



94
95
96
97
98
99
# File 'lib/insnergy-api-ruby-client.rb', line 94

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