Class: BuckarooClient::Gateway::NVP::Response
- Inherits:
-
Object
- Object
- BuckarooClient::Gateway::NVP::Response
- Includes:
- Signature
- Defined in:
- lib/buckaroo_client/gateway/nvp/response.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status_code ⇒ Object
readonly
Returns the value of attribute status_code.
-
#success ⇒ Object
(also: #success?)
readonly
Returns the value of attribute success.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #verified? ⇒ Boolean
- #verify! ⇒ Object
Methods included from Signature
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
27 28 29 30 31 32 |
# File 'lib/buckaroo_client/gateway/nvp/response.rb', line 27 def initialize(response) @body = response.body @response = Hash[Addressable::URI.form_unencode(body)] @status_code = @response['BRQ_STATUSCODE'].to_i @success = !error_occurred? end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
14 15 16 |
# File 'lib/buckaroo_client/gateway/nvp/response.rb', line 14 def body @body end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
14 15 16 |
# File 'lib/buckaroo_client/gateway/nvp/response.rb', line 14 def response @response end |
#status_code ⇒ Object (readonly)
Returns the value of attribute status_code.
14 15 16 |
# File 'lib/buckaroo_client/gateway/nvp/response.rb', line 14 def status_code @status_code end |
#success ⇒ Object (readonly) Also known as: success?
Returns the value of attribute success.
14 15 16 |
# File 'lib/buckaroo_client/gateway/nvp/response.rb', line 14 def success @success end |
Class Method Details
.for_action(action, response) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/buckaroo_client/gateway/nvp/response.rb', line 16 def self.for_action(action, response) klass = case action when 'invoiceinfo' require 'buckaroo_client/gateway/nvp/invoice_info_response' InvoiceInfoResponse else Response end klass.new(response) end |
Instance Method Details
#verified? ⇒ Boolean
40 41 42 43 44 45 |
# File 'lib/buckaroo_client/gateway/nvp/response.rb', line 40 def verified? input = response.dup given_hash = input['BRQ_SIGNATURE'] input.delete('BRQ_SIGNATURE') signature(input) == given_hash end |
#verify! ⇒ Object
36 37 38 |
# File 'lib/buckaroo_client/gateway/nvp/response.rb', line 36 def verify! verified? or raise "Response signature does not match expected value" end |