Class: Paypal::Exception::APIError::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/paypal/exception/api_error.rb

Defined Under Namespace

Classes: Detail

Constant Summary collapse

@@attribute_mapping =
{
  :ACK => :ack,
  :BUILD => :build,
  :CORRELATIONID => :correlation_id,
  :TIMESTAMP => :timestamp,
  :VERSION => :version,
  :ORDERTIME => :order_time,
  :PENDINGREASON => :pending_reason,
  :PAYMENTSTATUS => :payment_status,
  :PAYMENTTYPE => :payment_type,
  :REASONCODE => :reason_code,
  :TRANSACTIONTYPE => :transaction_type
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Response

Returns a new instance of Response.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/paypal/exception/api_error.rb', line 65

def initialize(attributes = {})
  attrs = attributes.dup
  @raw = attributes
  @@attribute_mapping.each do |key, value|
    self.send "#{value}=", attrs.delete(key)
  end
  details = []
  attrs.keys.each do |attribute|
    key, index = attribute.to_s.scan(/^L_(\S+)(\d+)$/).first
    next if [key, index].any?(&:blank?)
    details[index.to_i] ||= {}
    details[index.to_i][key.to_sym] = attrs.delete(attribute)
  end
  @details = details.collect do |_attrs_|
    Detail.new _attrs_
  end

  # warn ignored params
  attrs.each do |key, value|
    Paypal.log "Ignored Parameter (#{self.class}): #{key}=#{value}", :warn
  end
end

Instance Attribute Details

#detailsObject

Returns the value of attribute details.



38
39
40
# File 'lib/paypal/exception/api_error.rb', line 38

def details
  @details
end

#rawObject

Returns the value of attribute raw.



38
39
40
# File 'lib/paypal/exception/api_error.rb', line 38

def raw
  @raw
end

Instance Method Details

#short_messagesObject



88
89
90
# File 'lib/paypal/exception/api_error.rb', line 88

def short_messages
  details.map(&:short_message).compact
end