Class: Espago::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/espago/client.rb

Constant Summary collapse

NotAuthenticated =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
# File 'lib/espago/client.rb', line 9

def initialize(options = {})
  @public_key, @app_id, @app_password = options.values_at( :public_key, :app_id, :app_password)
  @connection = options[:connection] || ApiConnection
end

Instance Attribute Details

#app_idObject

Returns the value of attribute app_id.



6
7
8
# File 'lib/espago/client.rb', line 6

def app_id
  @app_id
end

#app_passwordObject

Returns the value of attribute app_password.



6
7
8
# File 'lib/espago/client.rb', line 6

def app_password
  @app_password
end

#productionObject

Returns the value of attribute production.



6
7
8
# File 'lib/espago/client.rb', line 6

def production
  @production
end

#public_keyObject

Returns the value of attribute public_key.



6
7
8
# File 'lib/espago/client.rb', line 6

def public_key
  @public_key
end

Instance Method Details

#parse_response(request) ⇒ Object



21
22
23
# File 'lib/espago/client.rb', line 21

def parse_response(request)
  Response.new(request)
end

#send_request(path, method, params = {}) ⇒ Object

Raises:



14
15
16
17
18
19
# File 'lib/espago/client.rb', line 14

def send_request(path, method, params = {})
  raise NotAuthenticated unless valid?
  connection = @connection.new(enviroment)
  connection.authenticate(@app_id, @app_password)
  connection.create(path, method, params)
end