Class: SebElink::Response
- Inherits:
-
Object
- Object
- SebElink::Response
- Includes:
- Communications
- Defined in:
- lib/seb_elink/response.rb
Constant Summary collapse
- SUPPORTED_VERSIONS =
["001"].freeze
- SUPPORTED_MESSAGES =
["0003", "0004"].freeze
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#gateway_instance ⇒ Object
readonly
Returns the value of attribute gateway_instance.
Instance Method Summary collapse
-
#initialize(gateway_instance, body) ⇒ Response
constructor
A new instance of Response.
- #to_h(mode = :secure) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(gateway_instance, body) ⇒ Response
Returns a new instance of Response.
9 10 11 12 |
# File 'lib/seb_elink/response.rb', line 9 def initialize(gateway_instance, body) @gateway_instance = gateway_instance @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/seb_elink/response.rb', line 7 def body @body end |
#gateway_instance ⇒ Object (readonly)
Returns the value of attribute gateway_instance.
7 8 9 |
# File 'lib/seb_elink/response.rb', line 7 def gateway_instance @gateway_instance end |
Instance Method Details
#to_h(mode = :secure) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/seb_elink/response.rb', line 34 def to_h(mode=:secure) raise SebElink::InvalidResponseError.new( "The response with body '#{body}' is invalid" ) if mode != :insecure && !valid? @to_h ||= body_hash end |
#valid? ⇒ Boolean
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/seb_elink/response.rb', line 14 def valid? return @valid if defined?(@valid) validate_version footprint = gateway_instance.produce_footprint({ message_code: , version: version, skip_validation: true, data: body_hash }) @valid = gateway_instance.verify({ version: version, message: footprint, base64_signature: body_hash[:IB_CRC] }) end |