Class: Greensky::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Client

Returns a new instance of Client.



3
4
5
6
7
8
9
# File 'lib/greensky/client.rb', line 3

def initialize(config)
  @config = config
  @resource = RestClient::Resource.new(config.endpoint, {
    headers: {content_type: :json, accept: :json},
    user: config.username, password: config.password
  })
end

Instance Method Details

#get(path, data = {}, headers = {}) ⇒ Object



11
12
13
# File 'lib/greensky/client.rb', line 11

def get(path, data={}, headers={})
  process_response services[path].get(headers.merge(params: data))
end

#post(path, data = {}, headers = {}) ⇒ Object



15
16
17
18
# File 'lib/greensky/client.rb', line 15

def post(path, data={}, headers={})
  params = data.to_json
  process_response services[path].post(params, headers)
end