Class: OnlinePayments::SDK::Domain::ErrorResponse

Inherits:
OnlinePayments::SDK::DataObject show all
Defined in:
lib/onlinepayments/sdk/domain/error_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from OnlinePayments::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



12
13
14
# File 'lib/onlinepayments/sdk/domain/error_response.rb', line 12

def error_id
  @error_id
end

#errorsArray<OnlinePayments::SDK::Domain::APIError>

Returns the current value of errors.

Returns:



12
13
14
# File 'lib/onlinepayments/sdk/domain/error_response.rb', line 12

def errors
  @errors
end

Instance Method Details

#from_hash(hash) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/onlinepayments/sdk/domain/error_response.rb', line 24

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 << OnlinePayments::SDK::Domain::APIError.new_from_hash(e)
    end
  end
end

#to_hHash

Returns:

  • (Hash)


17
18
19
20
21
22
# File 'lib/onlinepayments/sdk/domain/error_response.rb', line 17

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