Class: YouGotListed::Client
- Inherits:
-
Object
- Object
- YouGotListed::Client
- Includes:
- HTTParty
- Defined in:
- lib/you_got_listed/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#http_timeout ⇒ Object
Returns the value of attribute http_timeout.
Instance Method Summary collapse
- #accounts ⇒ Object
- #agents ⇒ Object
-
#initialize(api_key, http_timeout = nil) ⇒ Client
constructor
A new instance of Client.
- #leads ⇒ Object
- #listings ⇒ Object
- #perform_request(http_method, path, params = {}) ⇒ Object
Constructor Details
#initialize(api_key, http_timeout = nil) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/you_got_listed/client.rb', line 10 def initialize(api_key, http_timeout = nil) self.http_timeout = http_timeout self.class.default_params :key => api_key end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/you_got_listed/client.rb', line 8 def api_key @api_key end |
#http_timeout ⇒ Object
Returns the value of attribute http_timeout.
8 9 10 |
# File 'lib/you_got_listed/client.rb', line 8 def http_timeout @http_timeout end |
Instance Method Details
#accounts ⇒ Object
27 28 29 |
# File 'lib/you_got_listed/client.rb', line 27 def accounts @agents ||= YouGotListed::Accounts.new(self) end |
#agents ⇒ Object
23 24 25 |
# File 'lib/you_got_listed/client.rb', line 23 def agents @agents ||= YouGotListed::Agent.new(self) end |
#leads ⇒ Object
19 20 21 |
# File 'lib/you_got_listed/client.rb', line 19 def leads @leads ||= YouGotListed::Lead.new(self) end |
#listings ⇒ Object
15 16 17 |
# File 'lib/you_got_listed/client.rb', line 15 def listings @listings ||= YouGotListed::Listings.new(self) end |
#perform_request(http_method, path, params = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/you_got_listed/client.rb', line 31 def perform_request(http_method, path, params = {}) begin http_params = {} unless params.blank? http_params[:query] = params end unless self.http_timeout.nil? http_params[:timeout] = self.http_timeout end self.class.send(http_method, path, http_params) rescue Timeout::Error {"YGLResponse" => {"responseCode" => "996", "Error" => "Timeout"}} rescue Exception {"YGLResponse" => {"responseCode" => "999", "Error" => "Unknown Error"}} end end |