Class: WirecardCheckoutPage::Toolkit::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/wirecard_checkout_page/toolkit/response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, original_response: nil) ⇒ Response

Returns a new instance of Response.



10
11
12
13
# File 'lib/wirecard_checkout_page/toolkit/response.rb', line 10

def initialize(body, original_response: nil)
  @body = body
  @original_response = original_response
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



17
18
19
# File 'lib/wirecard_checkout_page/toolkit/response.rb', line 17

def body
  @body
end

#original_responseObject (readonly)

Returns the value of attribute original_response.



15
16
17
# File 'lib/wirecard_checkout_page/toolkit/response.rb', line 15

def original_response
  @original_response
end

Class Method Details

.from_typhoeus_response(response) ⇒ Object



6
7
8
# File 'lib/wirecard_checkout_page/toolkit/response.rb', line 6

def self.from_typhoeus_response(response)
  new(response.body, original_response: response)
end

Instance Method Details

#error_codeObject



23
24
25
# File 'lib/wirecard_checkout_page/toolkit/response.rb', line 23

def error_code
  param('errorCode').to_s
end

#order_numberObject



27
28
29
# File 'lib/wirecard_checkout_page/toolkit/response.rb', line 27

def order_number
  param('orderNumber').to_i
end

#paramsObject



31
32
33
# File 'lib/wirecard_checkout_page/toolkit/response.rb', line 31

def params
  { payment_url: original_response.headers['Location'] }
end

#success?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/wirecard_checkout_page/toolkit/response.rb', line 19

def success?
  status == '0'
end