Class: Vibe::Client

Inherits:
Object
  • Object
show all
Includes:
Request
Defined in:
lib/vibe/client.rb

Constant Summary

Constants included from Request

Request::METHODS

Constants included from Configuration

Vibe::Configuration::DEFAULT_API_KEY, Vibe::Configuration::DEFAULT_CACHE, Vibe::Configuration::DEFAULT_CACHE_DRIVER, Vibe::Configuration::DEFAULT_ENDPOINT, Vibe::Configuration::DEFAULT_FORMAT, Vibe::Configuration::DEFAULT_METHOD, Vibe::Configuration::DEFAULT_USER_AGENT, Vibe::Configuration::VALID_CONFIG_KEYS, Vibe::Configuration::VALID_CONNECTION_KEYS, Vibe::Configuration::VALID_OPTIONS_KEYS

Instance Method Summary collapse

Methods included from Request

#get_request, #request

Methods included from Configuration

#configure, extended, #options, #reset

Constructor Details

#initialize(options = {}, &block) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vibe/client.rb', line 10

def initialize(options = {}, &block)
  # Merge the config values from the module and those passed
  # to the client.
  merged_options = Vibe.options.merge(options)

  # Copy the merged values and ignore those
  # not part of our configuration
  Configuration::VALID_CONFIG_KEYS.each do |key|
    puts "Setting Configuration: #{key}" if ENV['DEBUG']
    send("#{key}=", merged_options[key]) if Configuration::VALID_OPTIONS_KEYS.include? key
    send("#{key}=", Vibe.options[key]) if Configuration::VALID_CONNECTION_KEYS.include? key
  end

  self.instance_eval(&block) if block_given?
end

Instance Method Details

#get_data(email) ⇒ String

Get Data from an Email

Returns:

  • (String)


29
30
31
32
33
34
35
36
# File 'lib/vibe/client.rb', line 29

def get_data(email)
  if !email.is_a? String
    error = InvalidOptions.new(['Email(String)'], ['Email(String)'])
    raise error
  end

  get_request '/profile_lookup/', :person_email => email
end

#stats(api_key = nil) ⇒ String

Get Stats for API Key

Returns:

  • (String)


41
42
43
44
45
46
47
48
49
# File 'lib/vibe/client.rb', line 41

def stats(api_key = nil)
  if api_key && (!api_key.is_a? String)
    error = InvalidOptions.new(['API key(String)'], ['API key(String)'])
    raise error
  end

  # Disable cache for API key status calls
  get_request('/stats/', {:key => api_key}, true)
end