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
- .reset_trace ⇒ 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
31 32 33 |
# File 'lib/paytrace/api/gateway.rb', line 31 def self.last_request @@last_request end |
.last_response ⇒ Object
35 36 37 |
# File 'lib/paytrace/api/gateway.rb', line 35 def self.last_response @@last_response end |
.last_response_object ⇒ Object
39 40 41 |
# File 'lib/paytrace/api/gateway.rb', line 39 def self.last_response_object @@last_response_object end |
.next_response=(next_response) ⇒ Object
43 44 45 |
# File 'lib/paytrace/api/gateway.rb', line 43 def self.next_response=(next_response) @@next_response = next_response end |
.raise_exceptions=(raise_exceptions) ⇒ Object
47 48 49 |
# File 'lib/paytrace/api/gateway.rb', line 47 def self.raise_exceptions=(raise_exceptions) @@raise_exceptions = raise_exceptions end |
.reset_trace ⇒ Object
24 25 26 27 28 29 |
# File 'lib/paytrace/api/gateway.rb', line 24 def self.reset_trace @@last_request = nil @@last_response = nil @@last_response_object = nil @@next_response = nil end |
Instance Method Details
#send_request(request, multi_value_response_fields = []) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/paytrace/api/gateway.rb', line 51 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 |