class Enrich::Client
Attributes
enrich[RW]
rest_base_path[W]
rest_host[W]
verify[RW]
Public Class Methods
new()
click to toggle source
# File lib/enrich-api.rb, line 22 def initialize() @auth = {} @enrich = Enrich::EnrichResource.new(self) @verify = Enrich::VerifyResource.new(self) end
Public Instance Methods
_get(resource, query)
click to toggle source
# File lib/enrich-api.rb, line 48 def _get(resource, query) self._do_get(resource, query) end
authenticate(user_id, secret_key)
click to toggle source
# File lib/enrich-api.rb, line 31 def authenticate(user_id, secret_key) @auth["user_id"] = user_id @auth["secret_key"] = secret_key end
rest_base_path()
click to toggle source
# File lib/enrich-api.rb, line 40 def rest_base_path @rest_base_path || "/v1" end
rest_host()
click to toggle source
# File lib/enrich-api.rb, line 36 def rest_host @rest_host || "https://api.enrich.email" end
timeout()
click to toggle source
# File lib/enrich-api.rb, line 44 def timeout @timeout || 40 end
Protected Instance Methods
_do_get(resource, query)
click to toggle source
# File lib/enrich-api.rb, line 54 def _do_get(resource, query) response = RestClient::Request.execute( :url => self._prepare_rest_url(resource), :method => :get, :timeout => self.timeout, :user => @auth["user_id"], :password => @auth["secret_key"], :headers => { :user_agent => "enrich-api-ruby/2.0.0", :accept => :json, :content_type => :json, :params => query } ) return JSON.parse(response) end
_prepare_rest_url(resource)
click to toggle source
# File lib/enrich-api.rb, line 74 def _prepare_rest_url(resource) return self.rest_host + self.rest_base_path + resource end