Class: PayTrace::API::Gateway
- Inherits:
-
Object
- Object
- PayTrace::API::Gateway
- Defined in:
- lib/paytrace/api/gateway.rb
Constant Summary collapse
- @@debug =
false- @@last_request =
nil- @@last_response =
nil- @@last_response_object =
nil- @@next_response =
nil- @@raise_exceptions =
true
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
Class Method Summary collapse
- .debug=(enable) ⇒ Object
- .last_request ⇒ Object
- .last_response ⇒ Object
- .last_response_object ⇒ Object
- .next_response=(next_response) ⇒ Object
- .raise_exceptions=(raise_exceptions) ⇒ Object
Instance Method Summary collapse
-
#initialize(connection = nil) ⇒ Gateway
constructor
A new instance of Gateway.
- #send_request(request, multi_value_response_fields = []) ⇒ Object
Constructor Details
#initialize(connection = nil) ⇒ Gateway
Returns a new instance of Gateway.
16 17 18 |
# File 'lib/paytrace/api/gateway.rb', line 16 def initialize(connection = nil) @connection = connection || PayTrace.configuration.connection end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
8 9 10 |
# File 'lib/paytrace/api/gateway.rb', line 8 def connection @connection end |
Class Method Details
.debug=(enable) ⇒ Object
20 21 22 |
# File 'lib/paytrace/api/gateway.rb', line 20 def self.debug=(enable) @@debug = enable end |
.last_request ⇒ Object
24 25 26 |
# File 'lib/paytrace/api/gateway.rb', line 24 def self.last_request @@last_request end |
.last_response ⇒ Object
28 29 30 |
# File 'lib/paytrace/api/gateway.rb', line 28 def self.last_response @@last_response end |
.last_response_object ⇒ Object
32 33 34 |
# File 'lib/paytrace/api/gateway.rb', line 32 def self.last_response_object @@last_response_object end |
.next_response=(next_response) ⇒ Object
36 37 38 |
# File 'lib/paytrace/api/gateway.rb', line 36 def self.next_response=(next_response) @@next_response = next_response end |
.raise_exceptions=(raise_exceptions) ⇒ Object
40 41 42 |
# File 'lib/paytrace/api/gateway.rb', line 40 def self.raise_exceptions=(raise_exceptions) @@raise_exceptions = raise_exceptions end |
Instance Method Details
#send_request(request, multi_value_response_fields = []) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/paytrace/api/gateway.rb', line 44 def send_request(request, multi_value_response_fields = []) @@last_request = request.to_parms_string if @@debug unless (@@debug && @@next_response) res = @connection.post PayTrace.configuration.url, parmlist: request.to_parms_string raw_response = res.body else raw_response = @@next_response end @@last_response = raw_response response = PayTrace::API::Response.new(raw_response, multi_value_response_fields) @@last_response_object = response @@next_response = nil # just to be sure if @@raise_exceptions && response.has_errors? raise PayTrace::Exceptions::ErrorResponse.new(response.get_response()) else response end end |