Sha256: 748709790a69a8493f04789c3ba3e0dbb76b8a789a2a523104996e902dc8d6ef

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

module YouGotListed
  class Client

    include HTTParty
    format :xml
    base_uri "https://www.yougotlistings.com/api"

    attr_accessor :api_key, :http_timeout

    def initialize(api_key, http_timeout = nil)
      self.http_timeout = http_timeout
      self.class.default_params :key => api_key
    end
    
    def listings
      @listings ||= YouGotListed::Listings.new(self)
    end

    def leads
      @leads ||= YouGotListed::Lead.new(self)
    end
    
    def agents
      @agents ||= YouGotListed::Agent.new(self)
    end
    
    def accounts
      @agents ||= YouGotListed::Accounts.new(self)
    end

    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

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
you_got_listed-0.7.2 lib/you_got_listed/client.rb
you_got_listed-0.7.1 lib/you_got_listed/client.rb
you_got_listed-0.7.0 lib/you_got_listed/client.rb
you_got_listed-0.6.6 lib/you_got_listed/client.rb
you_got_listed-0.6.5 lib/you_got_listed/client.rb
you_got_listed-0.6.4 lib/you_got_listed/client.rb
you_got_listed-0.6.3 lib/you_got_listed/client.rb
you_got_listed-0.6.2 lib/you_got_listed/client.rb