Class: Greensky::Client
- Inherits:
-
Object
- Object
- Greensky::Client
- Defined in:
- lib/greensky/client.rb
Instance Method Summary collapse
- #get(path, data = {}, headers = {}) ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #post(path, data = {}, headers = {}) ⇒ Object
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 |