Sha256: e278e729186ace3b2f7d23fca03ce616ea8af2646a15e8c26b0e775ea10c8abe

Contents?: true

Size: 878 Bytes

Versions: 3

Compression:

Stored size: 878 Bytes

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 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

3 entries across 3 versions & 1 rubygems

Version Path
you_got_listed-0.6.1 lib/you_got_listed/client.rb
you_got_listed-0.6.0 lib/you_got_listed/client.rb
you_got_listed-0.5.1 lib/you_got_listed/client.rb