Class: ActiveMerchant::Billing::PaypalPermissions::Parsers::CommonNVParser
- Inherits:
-
Object
- Object
- ActiveMerchant::Billing::PaypalPermissions::Parsers::CommonNVParser
show all
- Defined in:
- lib/paypal_permissions/parsers/common.rb
Class Method Summary
collapse
Class Method Details
.parse(nvp_response) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/paypal_permissions/parsers/common.rb', line 7
def parse nvp_response
@response = {
:raw_response => nvp_response,
:errors => [
],
}
end
|
.process_envelope_pair(n, v) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/paypal_permissions/parsers/common.rb', line 15
def process_envelope_pair n, v
case n
when "responseEnvelope.timestamp"
@response[:timestamp] = v
when "responseEnvelope.ack"
@response[:ack] = v
when "responseEnvelope.correlationId"
@response[:correlation_id] = v
when "responseEnvelope.build"
end
end
|
.process_error_idx(error_idx) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/paypal_permissions/parsers/common.rb', line 28
def process_error_idx error_idx
if @response[:errors].length <= error_idx
@response[:errors] << { :parameters => [] }
raise if @response[:errors].length <= error_idx
end
end
|
.process_error_pair(n, v) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/paypal_permissions/parsers/common.rb', line 35
def process_error_pair n, v
n =~ /^error\((\d+)\)/
error_idx = $1.to_i
process_error_idx error_idx
case n
when /^error\(\d+\)\.errorId$/
@response[:errors][error_idx][:error_id] = v
when /^error\(\d+\)\.domain$/
@response[:errors][error_idx][:domain] = v
when /^error\(\d+\)\.subdomain$/
@response[:errors][error_idx][:subdomain] = v
when /^error\(\d+\)\.severity$/
@response[:errors][error_idx][:severity] = v
when /^error\(\d+\)\.category$/
@response[:errors][error_idx][:category] = v
when /^error\(\d+\)\.message$/
@response[:errors][error_idx][:message] = v
when /^error\(\d+\)\.parameter\((\d+)\)$/
parameter_idx = $1.to_i if @response[:errors][error_idx][:parameters].length <= parameter_idx
@response[:errors][error_idx][:parameters] << {}
raise if @response[:errors][error_idx][:parameters].length <= parameter_idx
end
@response[:errors][error_idx][:parameters][parameter_idx] = v
end
end
|