Class: GpWebpay::Response

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

Direct Known Subclasses

Http::HttpResponse, Ws::WsResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_response:, result_text:, status:, pr_code:, sr_code:, params:, token: nil, merchant_number: nil) ⇒ Response

rubocop:disable Metrics/ParameterLists



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/gp_webpay/response.rb', line 13

def initialize(original_response:, result_text:, status:, pr_code:, sr_code:, params:, token: nil, merchant_number: nil)
  @original_response = original_response
  @result_text = result_text
  @token = token
  @status = status
  @pr_code = pr_code
  @sr_code = sr_code
  @params = params
  @merchant_number = merchant_number
  @config = GpWebpay.config[merchant_number] || GpWebpay.config.default
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



3
4
5
# File 'lib/gp_webpay/response.rb', line 3

def config
  @config
end

#original_responseObject

Returns the value of attribute original_response.



3
4
5
# File 'lib/gp_webpay/response.rb', line 3

def original_response
  @original_response
end

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'lib/gp_webpay/response.rb', line 3

def params
  @params
end

#pr_codeObject

Returns the value of attribute pr_code.



3
4
5
# File 'lib/gp_webpay/response.rb', line 3

def pr_code
  @pr_code
end

#result_textObject

Returns the value of attribute result_text.



3
4
5
# File 'lib/gp_webpay/response.rb', line 3

def result_text
  @result_text
end

#sr_codeObject

Returns the value of attribute sr_code.



3
4
5
# File 'lib/gp_webpay/response.rb', line 3

def sr_code
  @sr_code
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/gp_webpay/response.rb', line 3

def status
  @status
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/gp_webpay/response.rb', line 3

def token
  @token
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/gp_webpay/response.rb', line 30

def success?
  pr_code == '0' && sr_code == '0'
end

#valid?Boolean

rubocop:enable Metrics/ParameterLists

Returns:

  • (Boolean)


27
28
# File 'lib/gp_webpay/response.rb', line 27

def valid?
end