Class: Espago::Client
- Inherits:
-
Object
- Object
- Espago::Client
- Defined in:
- lib/espago/client.rb
Constant Summary collapse
- NotAuthenticated =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#app_password ⇒ Object
Returns the value of attribute app_password.
-
#production ⇒ Object
Returns the value of attribute production.
-
#public_key ⇒ Object
Returns the value of attribute public_key.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #parse_response(request) ⇒ Object
- #send_request(path, method, params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/espago/client.rb', line 9 def initialize( = {}) @public_key, @app_id, @app_password = .values_at( :public_key, :app_id, :app_password) @connection = [:connection] || ApiConnection end |
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
6 7 8 |
# File 'lib/espago/client.rb', line 6 def app_id @app_id end |
#app_password ⇒ Object
Returns the value of attribute app_password.
6 7 8 |
# File 'lib/espago/client.rb', line 6 def app_password @app_password end |
#production ⇒ Object
Returns the value of attribute production.
6 7 8 |
# File 'lib/espago/client.rb', line 6 def production @production end |
#public_key ⇒ Object
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
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 |