class EquinoxCrm::Client
Attributes
oauth_token[R]
Public Class Methods
new(oauth_token = nil)
click to toggle source
# File lib/equinox_crm/client.rb, line 11 def initialize(oauth_token = nil) @oauth_token = oauth_token end
Public Instance Methods
contacts(id)
click to toggle source
# File lib/equinox_crm/client.rb, line 15 def contacts(id) find(id) end
contacts_list(options = nil)
click to toggle source
# File lib/equinox_crm/client.rb, line 19 def contacts_list(options = nil) all(options) end
Private Instance Methods
client()
click to toggle source
# File lib/equinox_crm/client.rb, line 25 def client @_client ||= Faraday.new(API_URL) do |client| client.request :url_encoded client.adapter Faraday.default_adapter client.headers['Authorization'] = "token #{oauth_token}" if oauth_token.present? end end
request(http_method:, endpoint:, params: {})
click to toggle source
# File lib/equinox_crm/client.rb, line 33 def request(http_method:, endpoint:, params: {}) response = client.public_send(http_method, endpoint, params) JSON.parse(response.body) end