Class: Paypal::Masspay::ResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/paypal/masspay/response_parser.rb

Constant Summary collapse

SUCCESS_ACK =
'Success'
SUCCESS_WITH_WARN_ACK =
'SuccessWithWarning'
SUCCESSFUL_ACKS =
[ SUCCESS_ACK, SUCCESS_WITH_WARN_ACK ]

Instance Method Summary collapse

Constructor Details

#initialize(response_body) ⇒ ResponseParser

Returns a new instance of ResponseParser.



10
11
12
13
# File 'lib/paypal/masspay/response_parser.rb', line 10

def initialize(response_body)
  @response_body = response_body
  @errors = []
end

Instance Method Details

#errorsObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/paypal/masspay/response_parser.rb', line 19

def errors
  @errors.tap do |errors|
    parsed_response.select { |k, v| k.match(/^L_ERRORCODE\d+$/) }.keys.count.times do |i|
      errors << Paypal::Masspay::Error.new(
        :code          => error_code_for(i),
        :short_message => short_message_for(i),
        :long_message  => long_message_for(i),
        :severity      => severity_for(i))
    end
  end
end

#successful?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/paypal/masspay/response_parser.rb', line 15

def successful?
  SUCCESSFUL_ACKS.include?(ack)
end