Class: GpWebpay::Ws::WsResponse
Instance Attribute Summary
Attributes inherited from Response
#config, #original_response, #params, #pr_code, #result_text, #sr_code, #status, #token
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Response
#initialize
Class Method Details
.from_fault_error(hash, exception, merchant_number) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/gp_webpay/ws/ws_response.rb', line 18
def self.from_fault_error(hash, exception, merchant_number)
validation_response = hash.dig(:fault, :detail, exception)
new(
original_response: hash,
params: validation_response,
status: :error,
pr_code: validation_response[:primary_return_code],
sr_code: validation_response[:secondary_return_code],
result_text: hash.dig(:fault, :faultstring),
merchant_number: merchant_number
)
end
|
.from_http_error(hash, merchant_number) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/gp_webpay/ws/ws_response.rb', line 31
def self.from_http_error(hash, merchant_number)
new(
original_response: hash,
params: {},
status: :error,
pr_code: nil,
sr_code: nil,
result_text: "Internal HTTP request error: '#{hash[:code]}'",
merchant_number: merchant_number
)
end
|
.from_success(hash, response_name, response_entity_name, merchant_number) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/gp_webpay/ws/ws_response.rb', line 4
def self.from_success(hash, response_name, response_entity_name, merchant_number)
validation_response = hash.dig(response_name, response_entity_name)
new(
original_response: hash,
params: validation_response,
status: validation_response[:status],
token: validation_response[:token_data],
pr_code: validation_response[:primary_return_code],
sr_code: validation_response[:secondary_return_code],
merchant_number: merchant_number,
result_text: 'OK'
)
end
|
Instance Method Details
#success? ⇒ Boolean
47
48
49
|
# File 'lib/gp_webpay/ws/ws_response.rb', line 47
def success?
@success ||= (status != :error)
end
|