Class: Ingenico::Direct::SDK::Domain::PaymentErrorResponse

Inherits:
Ingenico::Direct::SDK::DataObject show all
Defined in:
lib/ingenico/direct/sdk/domain/payment_error_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Ingenico::Direct::SDK::DataObject

new_from_hash

Instance Attribute Details

#error_idString

Returns the current value of error_id.

Returns:

  • (String)

    the current value of error_id



15
16
17
# File 'lib/ingenico/direct/sdk/domain/payment_error_response.rb', line 15

def error_id
  @error_id
end

#errorsArray<Ingenico::Direct::SDK::Domain::APIError>

Returns the current value of errors.

Returns:



15
16
17
# File 'lib/ingenico/direct/sdk/domain/payment_error_response.rb', line 15

def errors
  @errors
end

#payment_resultIngenico::Direct::SDK::Domain::CreatePaymentResponse

Returns the current value of payment_result.

Returns:



15
16
17
# File 'lib/ingenico/direct/sdk/domain/payment_error_response.rb', line 15

def payment_result
  @payment_result
end

Instance Method Details

#from_hash(hash) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ingenico/direct/sdk/domain/payment_error_response.rb', line 29

def from_hash(hash)
  super
  @error_id = hash['errorId'] if hash.key? 'errorId'
  if hash.key? 'errors'
    raise TypeError, "value '%s' is not an Array" % [hash['errors']] unless hash['errors'].is_a? Array
    @errors = []
    hash['errors'].each do |e|
      @errors << Ingenico::Direct::SDK::Domain::APIError.new_from_hash(e)
    end
  end
  if hash.key? 'paymentResult'
    raise TypeError, "value '%s' is not a Hash" % [hash['paymentResult']] unless hash['paymentResult'].is_a? Hash
    @payment_result = Ingenico::Direct::SDK::Domain::CreatePaymentResponse.new_from_hash(hash['paymentResult'])
  end
end

#to_hHash

Returns:

  • (Hash)


21
22
23
24
25
26
27
# File 'lib/ingenico/direct/sdk/domain/payment_error_response.rb', line 21

def to_h
  hash = super
  hash['errorId'] = @error_id unless @error_id.nil?
  hash['errors'] = @errors.collect(&:to_h) if @errors
  hash['paymentResult'] = @payment_result.to_h if @payment_result
  hash
end