Class: SimpleHubspot::ApiClient
- Inherits:
-
Object
- Object
- SimpleHubspot::ApiClient
- Defined in:
- lib/simple_hubspot/api_client.rb
Class Method Summary collapse
- .do_get(path = nil, params = {}, headers = {}) ⇒ Object
- .do_post(path = nil, params = {}, headers = {}) ⇒ Object
Class Method Details
.do_get(path = nil, params = {}, headers = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/simple_hubspot/api_client.rb', line 12 def do_get(path = nil, params = {}, headers = {}) response = RestClient.get "#{SimpleHubspot.configuration.api_base}#{path}#{add_apikey}" json = JSON.parse(response.body, symbolize_names: true) json.merge(success: true) rescue RestClient::BadRequest => e response_fail e.response.body end |
.do_post(path = nil, params = {}, headers = {}) ⇒ Object
5 6 7 8 9 10 |
# File 'lib/simple_hubspot/api_client.rb', line 5 def do_post(path = nil, params = {}, headers = {}) response = RestClient.post "#{SimpleHubspot.configuration.api_base}#{path}#{add_apikey}", params.to_json, { content_type: :json } response_success response.body rescue RestClient::BadRequest => e response_fail e.response.body end |