Class: TqlOtrFactoringDataExchange::InvoiceException

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb

Overview

A processing exception or discrepancy found during invoice validation.

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(exception_id: SKIP, code: SKIP, severity: SKIP, message: SKIP, field: SKIP, created_at: SKIP, additional_properties: nil) ⇒ InvoiceException

Returns a new instance of InvoiceException.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 68

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

  @exception_id = exception_id unless exception_id == SKIP
  @code = code unless code == SKIP
  @severity = severity unless severity == SKIP
  @message = message unless message == SKIP
  @field = field unless field == SKIP
  @created_at = created_at unless created_at == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#codeString

Machine-readable exception code.

Returns:

  • (String)


19
20
21
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 19

def code
  @code
end

#created_atDateTime

When the exception was identified.

Returns:

  • (DateTime)


35
36
37
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 35

def created_at
  @created_at
end

#exception_idUUID | String

Unique identifier for this exception.

Returns:

  • (UUID | String)


15
16
17
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 15

def exception_id
  @exception_id
end

#fieldString

The field or area that triggered the exception, if applicable.

Returns:

  • (String)


31
32
33
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 31

def field
  @field
end

#messageString

Human-readable description of the exception.

Returns:

  • (String)


27
28
29
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 27

def message
  @message
end

#severityExceptionSeverity

Severity level of a processing exception.

Returns:



23
24
25
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 23

def severity
  @severity
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 84

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  exception_id = hash.key?('exceptionId') ? hash['exceptionId'] : SKIP
  code = hash.key?('code') ? hash['code'] : SKIP
  severity = hash.key?('severity') ? hash['severity'] : SKIP
  message = hash.key?('message') ? hash['message'] : SKIP
  field = hash.key?('field') ? hash['field'] : SKIP
  created_at = if hash.key?('createdAt')
                 (DateTimeHelper.from_rfc3339(hash['createdAt']) if hash['createdAt'])
               else
                 SKIP
               end

  # 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.
  InvoiceException.new(exception_id: exception_id,
                       code: code,
                       severity: severity,
                       message: message,
                       field: field,
                       created_at: created_at,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['exception_id'] = 'exceptionId'
  @_hash['code'] = 'code'
  @_hash['severity'] = 'severity'
  @_hash['message'] = 'message'
  @_hash['field'] = 'field'
  @_hash['created_at'] = 'createdAt'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
65
66
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 62

def self.nullables
  %w[
    field
  ]
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
58
59
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 50

def self.optionals
  %w[
    exception_id
    code
    severity
    message
    field
    created_at
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



129
130
131
132
133
134
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 129

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

#to_custom_created_atObject



116
117
118
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 116

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_sObject

Provides a human-readable string representation of the object.



121
122
123
124
125
126
# File 'lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb', line 121

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