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
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#app_password ⇒ Object
Returns the value of attribute app_password.
-
#checksum_key ⇒ Object
Returns the value of attribute checksum_key.
-
#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, @api_version, @checksum_key = .values_at( :public_key, :app_id, :app_password, :api_version, :checksum_key) @connection = [:connection] || ApiConnection end |
Instance Attribute Details
#api_version ⇒ Object
Returns the value of attribute api_version.
6 7 8 |
# File 'lib/espago/client.rb', line 6 def api_version @api_version end |
#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 |
#checksum_key ⇒ Object
Returns the value of attribute checksum_key.
6 7 8 |
# File 'lib/espago/client.rb', line 6 def checksum_key @checksum_key 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
27 28 29 |
# File 'lib/espago/client.rb', line 27 def parse_response(request) Response.new(request) end |
#send_request(path, method, params = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/espago/client.rb', line 14 def send_request(path, method, params = {}) app_id = params[:app_id].present? ? params.delete(:app_id) : @app_id app_password = params[:app_password].present? ? params.delete(:app_password) : @app_password production_param = !params[:production].nil? ? params.delete(:production) : production raise NotAuthenticated unless valid?(app_id, app_password) connection = @connection.new(enviroment(production_param),api_version_header) connection.authenticate(app_id, app_password) connection.create(path, method, params) end |