Class: Colppy::Client
- Inherits:
-
Object
- Object
- Colppy::Client
- Extended by:
- Forwardable
- Includes:
- CompanyActions, Digest, UserActions
- Defined in:
- lib/colppy/client.rb
Constant Summary collapse
Constants included from Digest
Instance Method Summary collapse
- #call(service, operation, params) ⇒ Object
-
#initialize(auth_user, auth_pass, user, mode = "sandbox") ⇒ Client
constructor
A new instance of Client.
- #inspect ⇒ Object
Methods included from UserActions
#session_key, #session_params, #sign_in, #sign_out, #user=, #username
Methods included from CompanyActions
Methods included from Digest
Constructor Details
#initialize(auth_user, auth_pass, user, mode = "sandbox") ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/colppy/client.rb', line 7 def initialize(auth_user, auth_pass, user, mode = "sandbox") ensure_user_valid!(user) @auth_user = auth_user @auth_pass = md5(auth_pass) @gateway = Core::Gateway.new(mode) if user @user = user sign_in end end |
Instance Method Details
#call(service, operation, params) ⇒ Object
30 31 32 33 34 |
# File 'lib/colppy/client.rb', line 30 def call(service, operation, params) request_payload = request_base(service, operation).merge(parameters: params) @gateway.call(request_payload)[:response] if request_payload end |
#inspect ⇒ Object
20 21 22 23 24 25 |
# File 'lib/colppy/client.rb', line 20 def inspect formatted_attrs = attr_inspect.map do |attr| "#{attr}: #{send(attr).inspect}" end "#<#{self.class.name} #{formatted_attrs.join(", ")}>" end |