Class: CleverReach::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/clever_reach/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



7
8
9
# File 'lib/clever_reach/base.rb', line 7

def initialize
  @api_key = CleverReach.config.api_key
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/clever_reach/base.rb', line 15

def method_missing(name, *args)
  options  = args.last.is_a?(Hash) ? args.pop : {}
  response = request(name, options)

  ResponseDecorator.new(response).tap do |r|
    raise Errors.lookup(r.status_code) unless r.valid?
  end
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



5
6
7
# File 'lib/clever_reach/base.rb', line 5

def api_key
  @api_key
end

Instance Method Details

#clientObject



11
12
13
# File 'lib/clever_reach/base.rb', line 11

def client
  @client ||= Savon.client(CleverReach.config.wsdl_url)
end