Class: UnivapayClientSdk::CustomsDeclarationWebhookError

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb

Overview

Error payload returned when customs declaration processing fails.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(code: SKIP, message: SKIP, details: SKIP, others: SKIP, additional_properties: nil) ⇒ CustomsDeclarationWebhookError

Returns a new instance of CustomsDeclarationWebhookError.



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 56

def initialize(code: SKIP, message: SKIP, details: SKIP, others: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @code = code unless code == SKIP
  @message = message unless message == SKIP
  @details = details unless details == SKIP
  @others = others unless others == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#codeInteger

Backend customs declaration error code.

Returns:

  • (Integer)


14
15
16
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 14

def code
  @code
end

#detailsString

Optional backend-provided detail string.

Returns:

  • (String)


22
23
24
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 22

def details
  @details
end

#messageString

Human-readable backend error name.

Returns:

  • (String)


18
19
20
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 18

def message
  @message
end

#othersArray[CustomsDeclarationWebhookOtherError]

Additional nested error records returned by the backend.



26
27
28
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 26

def others
  @others
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 69

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  code = hash.key?('code') ? hash['code'] : SKIP
  message = hash.key?('message') ? hash['message'] : SKIP
  details = hash.key?('details') ? hash['details'] : SKIP
  # Parameter is an array, so we need to iterate through it
  others = nil
  unless hash['others'].nil?
    others = []
    hash['others'].each do |structure|
      others << (CustomsDeclarationWebhookOtherError.from_hash(structure) if structure)
    end
  end

  others = SKIP unless hash.key?('others')

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  CustomsDeclarationWebhookError.new(code: code,
                                     message: message,
                                     details: details,
                                     others: others,
                                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['code'] = 'code'
  @_hash['message'] = 'message'
  @_hash['details'] = 'details'
  @_hash['others'] = 'others'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
52
53
54
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 49

def self.nullables
  %w[
    details
    others
  ]
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 39

def self.optionals
  %w[
    code
    message
    details
    others
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



104
105
106
107
108
109
110
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 104

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



120
121
122
123
124
125
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 120

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} code: #{@code.inspect}, message: #{@message.inspect}, details:"\
  " #{@details.inspect}, others: #{@others.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



113
114
115
116
117
# File 'lib/univapay_client_sdk/models/customs_declaration_webhook_error.rb', line 113

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} code: #{@code}, message: #{@message}, details: #{@details}, others:"\
  " #{@others}, additional_properties: #{@additional_properties}>"
end