Sha256: 1cc90299bf670353a9e256f7507467f7e1ed84544f57d3009a4c8ceb2a153bca
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
module SimpleHubspot class ApiClient class << self 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 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 private def add_apikey "?hapikey=#{SimpleHubspot.configuration.hapikey}" end def response_fail(response = {}) return { success: false } if response.empty? json = JSON.parse(response, symbolize_names: true) json.merge(success: false) end def response_success(response = {}) return { success: true } if response.empty? json = JSON.parse(response, symbolize_names: true) json.merge(success: true) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_hubspot-0.1.3 | lib/simple_hubspot/api_client.rb |