Sha256: 8411f0ac57538facb12d02600dd150fd4bb58d19e5ee62a727d20a768c30defc
Contents?: true
Size: 1.41 KB
Versions: 5
Compression:
Stored size: 1.41 KB
Contents
module PayPal module Recurring module Response class Base extend PayPal::Recurring::Utils attr_accessor :response mapping( :token => :TOKEN, :ack => :ACK, :version => :VERSION, :build => :BUILD, :correlaction_id => :CORRELATIONID, :requested_at => :TIMESTAMP ) def initialize(response = nil) @response = response end def params @params ||= CGI.parse(response.body).inject({}) do |buffer, (name, value)| buffer.merge(name.to_sym => value.first) end end def errors @errors ||= begin index = 0 [].tap do |errors| while params[:"L_ERRORCODE#{index}"] errors << { :code => params[:"L_ERRORCODE#{index}"], :messages => [ params[:"L_SHORTMESSAGE#{index}"], params[:"L_LONGMESSAGE#{index}"] ] } index += 1 end end end end def success? ack == "Success" end def valid? errors.empty? && success? end private def build_requested_at(stamp) # :nodoc: Time.parse(stamp) end end end end end
Version data entries
5 entries across 5 versions & 2 rubygems