apimatic-tql-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +210 -0
  4. data/bin/console +15 -0
  5. data/lib/tql_otr_factoring_data_exchange/api_helper.rb +10 -0
  6. data/lib/tql_otr_factoring_data_exchange/apis/assignments_api.rb +45 -0
  7. data/lib/tql_otr_factoring_data_exchange/apis/base_api.rb +67 -0
  8. data/lib/tql_otr_factoring_data_exchange/apis/documents_api.rb +82 -0
  9. data/lib/tql_otr_factoring_data_exchange/apis/invoices_api.rb +114 -0
  10. data/lib/tql_otr_factoring_data_exchange/apis/loads_api.rb +68 -0
  11. data/lib/tql_otr_factoring_data_exchange/apis/oauth_authorization_api.rb +44 -0
  12. data/lib/tql_otr_factoring_data_exchange/client.rb +104 -0
  13. data/lib/tql_otr_factoring_data_exchange/configuration.rb +164 -0
  14. data/lib/tql_otr_factoring_data_exchange/exceptions/api_exception.rb +21 -0
  15. data/lib/tql_otr_factoring_data_exchange/exceptions/oauth_provider_exception.rb +64 -0
  16. data/lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb +58 -0
  17. data/lib/tql_otr_factoring_data_exchange/http/api_response.rb +19 -0
  18. data/lib/tql_otr_factoring_data_exchange/http/auth/oauth_2.rb +156 -0
  19. data/lib/tql_otr_factoring_data_exchange/http/http_call_back.rb +10 -0
  20. data/lib/tql_otr_factoring_data_exchange/http/http_method_enum.rb +10 -0
  21. data/lib/tql_otr_factoring_data_exchange/http/http_request.rb +10 -0
  22. data/lib/tql_otr_factoring_data_exchange/http/http_response.rb +10 -0
  23. data/lib/tql_otr_factoring_data_exchange/http/proxy_settings.rb +22 -0
  24. data/lib/tql_otr_factoring_data_exchange/logging/configuration/api_logging_configuration.rb +186 -0
  25. data/lib/tql_otr_factoring_data_exchange/logging/sdk_logger.rb +17 -0
  26. data/lib/tql_otr_factoring_data_exchange/models/assignment_request.rb +140 -0
  27. data/lib/tql_otr_factoring_data_exchange/models/assignment_response.rb +126 -0
  28. data/lib/tql_otr_factoring_data_exchange/models/assignment_status.rb +36 -0
  29. data/lib/tql_otr_factoring_data_exchange/models/base64_document.rb +118 -0
  30. data/lib/tql_otr_factoring_data_exchange/models/base64_document_upload_request.rb +107 -0
  31. data/lib/tql_otr_factoring_data_exchange/models/base_model.rb +110 -0
  32. data/lib/tql_otr_factoring_data_exchange/models/carrier.rb +98 -0
  33. data/lib/tql_otr_factoring_data_exchange/models/carrier1.rb +98 -0
  34. data/lib/tql_otr_factoring_data_exchange/models/carrier2.rb +98 -0
  35. data/lib/tql_otr_factoring_data_exchange/models/carrier_input.rb +123 -0
  36. data/lib/tql_otr_factoring_data_exchange/models/carrier_input1.rb +123 -0
  37. data/lib/tql_otr_factoring_data_exchange/models/charge_code.rb +126 -0
  38. data/lib/tql_otr_factoring_data_exchange/models/charge_code_origin.rb +49 -0
  39. data/lib/tql_otr_factoring_data_exchange/models/charge_input.rb +146 -0
  40. data/lib/tql_otr_factoring_data_exchange/models/document.rb +86 -0
  41. data/lib/tql_otr_factoring_data_exchange/models/document_type.rb +288 -0
  42. data/lib/tql_otr_factoring_data_exchange/models/document_upload_metadata.rb +111 -0
  43. data/lib/tql_otr_factoring_data_exchange/models/document_upload_response.rb +137 -0
  44. data/lib/tql_otr_factoring_data_exchange/models/exception_severity.rb +40 -0
  45. data/lib/tql_otr_factoring_data_exchange/models/factoring_company_input.rb +117 -0
  46. data/lib/tql_otr_factoring_data_exchange/models/invoice.rb +223 -0
  47. data/lib/tql_otr_factoring_data_exchange/models/invoice_exception.rb +136 -0
  48. data/lib/tql_otr_factoring_data_exchange/models/invoice_item_input.rb +165 -0
  49. data/lib/tql_otr_factoring_data_exchange/models/invoice_search_request.rb +242 -0
  50. data/lib/tql_otr_factoring_data_exchange/models/invoice_search_response.rb +124 -0
  51. data/lib/tql_otr_factoring_data_exchange/models/invoice_status.rb +74 -0
  52. data/lib/tql_otr_factoring_data_exchange/models/invoice_status_response.rb +193 -0
  53. data/lib/tql_otr_factoring_data_exchange/models/invoice_type.rb +50 -0
  54. data/lib/tql_otr_factoring_data_exchange/models/load.rb +110 -0
  55. data/lib/tql_otr_factoring_data_exchange/models/load_detail.rb +140 -0
  56. data/lib/tql_otr_factoring_data_exchange/models/load_search_request.rb +205 -0
  57. data/lib/tql_otr_factoring_data_exchange/models/load_search_response.rb +124 -0
  58. data/lib/tql_otr_factoring_data_exchange/models/load_status.rb +56 -0
  59. data/lib/tql_otr_factoring_data_exchange/models/location.rb +149 -0
  60. data/lib/tql_otr_factoring_data_exchange/models/oauth_provider_error.rb +62 -0
  61. data/lib/tql_otr_factoring_data_exchange/models/oauth_scope.rb +36 -0
  62. data/lib/tql_otr_factoring_data_exchange/models/oauth_token.rb +96 -0
  63. data/lib/tql_otr_factoring_data_exchange/models/payment.rb +108 -0
  64. data/lib/tql_otr_factoring_data_exchange/models/problem_details.rb +96 -0
  65. data/lib/tql_otr_factoring_data_exchange/models/reference_number_input.rb +109 -0
  66. data/lib/tql_otr_factoring_data_exchange/models/reference_type.rb +90 -0
  67. data/lib/tql_otr_factoring_data_exchange/models/status.rb +44 -0
  68. data/lib/tql_otr_factoring_data_exchange/models/stop_input.rb +121 -0
  69. data/lib/tql_otr_factoring_data_exchange/models/stop_type.rb +62 -0
  70. data/lib/tql_otr_factoring_data_exchange/models/submit_invoice_request.rb +326 -0
  71. data/lib/tql_otr_factoring_data_exchange/models/submit_invoice_response.rb +107 -0
  72. data/lib/tql_otr_factoring_data_exchange/models/weight_unit.rb +36 -0
  73. data/lib/tql_otr_factoring_data_exchange/utilities/date_time_helper.rb +11 -0
  74. data/lib/tql_otr_factoring_data_exchange/utilities/file_wrapper.rb +28 -0
  75. data/lib/tql_otr_factoring_data_exchange/utilities/union_type_lookup.rb +29 -0
  76. data/lib/tql_otr_factoring_data_exchange.rb +107 -0
  77. metadata +160 -0
@@ -0,0 +1,90 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # Reference number qualifier. Values follow [EDI
8
+ # 210](https://www.stedi.com/edi/x12/transaction-set/210) / [ANSI
9
+ # X12](https://www.x12.org/) Reference Identification Qualifier codes.
10
+ class ReferenceType
11
+ REFERENCE_TYPE = [
12
+ # TODO: Write general description for BM
13
+ BM = 'BM'.freeze,
14
+
15
+ # TODO: Write general description for PO
16
+ PO = 'PO'.freeze,
17
+
18
+ # TODO: Write general description for PRO
19
+ PRO = 'PRO'.freeze,
20
+
21
+ # TODO: Write general description for SI
22
+ SI = 'SI'.freeze,
23
+
24
+ # TODO: Write general description for CN
25
+ CN = 'CN'.freeze,
26
+
27
+ # TODO: Write general description for CR
28
+ CR = 'CR'.freeze,
29
+
30
+ # TODO: Write general description for AO
31
+ AO = 'AO'.freeze,
32
+
33
+ # TODO: Write general description for MB
34
+ MB = 'MB'.freeze,
35
+
36
+ # TODO: Write general description for TN
37
+ TN = 'TN'.freeze,
38
+
39
+ # TODO: Write general description for IV
40
+ IV = 'IV'.freeze,
41
+
42
+ # TODO: Write general description for SN
43
+ SN = 'SN'.freeze,
44
+
45
+ # TODO: Write general description for LO
46
+ LO = 'LO'.freeze,
47
+
48
+ # TODO: Write general description for DO
49
+ DO = 'DO'.freeze,
50
+
51
+ # TODO: Write general description for CO
52
+ CO = 'CO'.freeze,
53
+
54
+ # TODO: Write general description for TL
55
+ TL = 'TL'.freeze
56
+ ].freeze
57
+
58
+ def self.validate(value)
59
+ return false if value.nil?
60
+
61
+ REFERENCE_TYPE.include?(value)
62
+ end
63
+
64
+ def self.from_value(value, default_value = BM)
65
+ return default_value if value.nil?
66
+
67
+ str = value.to_s.strip
68
+
69
+ case str.downcase
70
+ when 'bm' then BM
71
+ when 'po' then PO
72
+ when 'pro' then PRO
73
+ when 'si' then SI
74
+ when 'cn' then CN
75
+ when 'cr' then CR
76
+ when 'ao' then AO
77
+ when 'mb' then MB
78
+ when 'tn' then TN
79
+ when 'iv' then IV
80
+ when 'sn' then SN
81
+ when 'lo' then LO
82
+ when 'do' then DO
83
+ when 'co' then CO
84
+ when 'tl' then TL
85
+ else
86
+ default_value
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,44 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # Processing status of this document.
8
+ class Status
9
+ STATUS = [
10
+ # TODO: Write general description for RECEIVED
11
+ RECEIVED = 'Received'.freeze,
12
+
13
+ # TODO: Write general description for EXTRACTING
14
+ EXTRACTING = 'Extracting'.freeze,
15
+
16
+ # TODO: Write general description for COMPLETE
17
+ COMPLETE = 'Complete'.freeze,
18
+
19
+ # TODO: Write general description for FAILED
20
+ FAILED = 'Failed'.freeze
21
+ ].freeze
22
+
23
+ def self.validate(value)
24
+ return false if value.nil?
25
+
26
+ STATUS.include?(value)
27
+ end
28
+
29
+ def self.from_value(value, default_value = RECEIVED)
30
+ return default_value if value.nil?
31
+
32
+ str = value.to_s.strip
33
+
34
+ case str.downcase
35
+ when 'received' then RECEIVED
36
+ when 'extracting' then EXTRACTING
37
+ when 'complete' then COMPLETE
38
+ when 'failed' then FAILED
39
+ else
40
+ default_value
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,121 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # A pickup or delivery stop on the shipment route, using [EDI
8
+ # 210](https://www.stedi.com/edi/x12/transaction-set/210) stop type codes.
9
+ class StopInput < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # Type of stop. Values align with [EDI
14
+ # 210](https://www.stedi.com/edi/x12/transaction-set/210) stop-off detail
15
+ # codes.
16
+ # @return [StopType]
17
+ attr_accessor :stop_type
18
+
19
+ # 1-based ordering of the stop in the route.
20
+ # @return [Integer]
21
+ attr_accessor :sequence
22
+
23
+ # Physical address of the stop.
24
+ # @return [Location]
25
+ attr_accessor :location
26
+
27
+ # A mapping from model property names to API property names.
28
+ def self.names
29
+ @_hash = {} if @_hash.nil?
30
+ @_hash['stop_type'] = 'stopType'
31
+ @_hash['sequence'] = 'sequence'
32
+ @_hash['location'] = 'location'
33
+ @_hash
34
+ end
35
+
36
+ # An array for optional fields
37
+ def self.optionals
38
+ []
39
+ end
40
+
41
+ # An array for nullable fields
42
+ def self.nullables
43
+ []
44
+ end
45
+
46
+ def initialize(stop_type:, sequence:, location:, additional_properties: nil)
47
+ # Add additional model properties to the instance
48
+ additional_properties = {} if additional_properties.nil?
49
+
50
+ @stop_type = stop_type
51
+ @sequence = sequence
52
+ @location = location
53
+ @additional_properties = additional_properties
54
+ end
55
+
56
+ # Creates an instance of the object from a hash.
57
+ def self.from_hash(hash)
58
+ return nil unless hash
59
+
60
+ # Extract variables from the hash.
61
+ stop_type = hash.key?('stopType') ? hash['stopType'] : nil
62
+ sequence = hash.key?('sequence') ? hash['sequence'] : nil
63
+ location = Location.from_hash(hash['location']) if hash['location']
64
+
65
+ # Create a new hash for additional properties, removing known properties.
66
+ new_hash = hash.reject { |k, _| names.value?(k) }
67
+
68
+ additional_properties = APIHelper.get_additional_properties(
69
+ new_hash, proc { |value| value }
70
+ )
71
+
72
+ # Create object from extracted values.
73
+ StopInput.new(stop_type: stop_type,
74
+ sequence: sequence,
75
+ location: location,
76
+ additional_properties: additional_properties)
77
+ end
78
+
79
+ # Validates an instance of the object from a given value.
80
+ # @param [StopInput | Hash] The value against the validation is performed.
81
+ def self.validate(value)
82
+ if value.instance_of? self
83
+ return (
84
+ APIHelper.valid_type?(value.stop_type,
85
+ ->(val) { StopType.validate(val) }) and
86
+ APIHelper.valid_type?(value.sequence,
87
+ ->(val) { val.instance_of? Integer }) and
88
+ APIHelper.valid_type?(value.location,
89
+ ->(val) { Location.validate(val) },
90
+ is_model_hash: true)
91
+ )
92
+ end
93
+
94
+ return false unless value.instance_of? Hash
95
+
96
+ (
97
+ APIHelper.valid_type?(value['stopType'],
98
+ ->(val) { StopType.validate(val) }) and
99
+ APIHelper.valid_type?(value['sequence'],
100
+ ->(val) { val.instance_of? Integer }) and
101
+ APIHelper.valid_type?(value['location'],
102
+ ->(val) { Location.validate(val) },
103
+ is_model_hash: true)
104
+ )
105
+ end
106
+
107
+ # Provides a human-readable string representation of the object.
108
+ def to_s
109
+ class_name = self.class.name.split('::').last
110
+ "<#{class_name} stop_type: #{@stop_type}, sequence: #{@sequence}, location: #{@location},"\
111
+ " additional_properties: #{@additional_properties}>"
112
+ end
113
+
114
+ # Provides a debugging-friendly string with detailed object information.
115
+ def inspect
116
+ class_name = self.class.name.split('::').last
117
+ "<#{class_name} stop_type: #{@stop_type.inspect}, sequence: #{@sequence.inspect}, location:"\
118
+ " #{@location.inspect}, additional_properties: #{@additional_properties}>"
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,62 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # Type of stop. Values align with [EDI
8
+ # 210](https://www.stedi.com/edi/x12/transaction-set/210) stop-off detail
9
+ # codes.
10
+ class StopType
11
+ STOP_TYPE = [
12
+ # TODO: Write general description for PU
13
+ PU = 'PU'.freeze,
14
+
15
+ # TODO: Write general description for DL
16
+ DL = 'DL'.freeze,
17
+
18
+ # TODO: Write general description for CL
19
+ CL = 'CL'.freeze,
20
+
21
+ # TODO: Write general description for PL
22
+ PL = 'PL'.freeze,
23
+
24
+ # TODO: Write general description for UL
25
+ UL = 'UL'.freeze,
26
+
27
+ # TODO: Write general description for CS
28
+ CS = 'CS'.freeze,
29
+
30
+ # TODO: Write general description for DS
31
+ DS = 'DS'.freeze,
32
+
33
+ # TODO: Write general description for XX
34
+ XX = 'XX'.freeze
35
+ ].freeze
36
+
37
+ def self.validate(value)
38
+ return false if value.nil?
39
+
40
+ STOP_TYPE.include?(value)
41
+ end
42
+
43
+ def self.from_value(value, default_value = PU)
44
+ return default_value if value.nil?
45
+
46
+ str = value.to_s.strip
47
+
48
+ case str.downcase
49
+ when 'pu' then PU
50
+ when 'dl' then DL
51
+ when 'cl' then CL
52
+ when 'pl' then PL
53
+ when 'ul' then UL
54
+ when 'cs' then CS
55
+ when 'ds' then DS
56
+ when 'xx' then XX
57
+ else
58
+ default_value
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,326 @@
1
+ # tql_otr_factoring_data_exchange
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module TqlOtrFactoringDataExchange
7
+ # Factoring company invoice submitted against a TQL load. Documents should be
8
+ # uploaded separately via `POST /api/documents`.
9
+ class SubmitInvoiceRequest < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # Indicates the purpose of the invoice being submitted.
14
+ # - **Invoice** — A standard carrier invoice for freight services
15
+ # rendered on a load. This is the initial, primary billing
16
+ # submitted by the factoring company on behalf of the carrier.
17
+ # - **BalanceDue** — A follow-up invoice for the remaining balance
18
+ # after a partial payment or short-pay on a previously submitted
19
+ # invoice. Use this type when the original invoice was paid at
20
+ # less than the full amount and the carrier is billing for the
21
+ # difference.
22
+ # - **Supplemental** — An additional invoice for charges that were
23
+ # not included on the original invoice. Common examples include
24
+ # detention charges, lumper fees, or other accessorials
25
+ # discovered or finalized after the initial invoice was
26
+ # submitted.
27
+ # @return [InvoiceType]
28
+ attr_accessor :type
29
+
30
+ # The TQL load number this invoice is billed against. This is the load
31
+ # identifier assigned by TQL and must match an existing load in the TQL
32
+ # system.
33
+ # @return [String]
34
+ attr_accessor :load_number
35
+
36
+ # The factoring company's invoice number for this shipment. This is the
37
+ # primary identifier the factoring company uses to track this invoice.
38
+ # @return [String]
39
+ attr_accessor :invoice_number
40
+
41
+ # The carrier's own invoice number, if different from the factoring
42
+ # company's invoice number. Optional.
43
+ # @return [String]
44
+ attr_accessor :carrier_invoice_number
45
+
46
+ # Carrier information for the invoiced shipment. At least one of `mcNumber`
47
+ # or `dotNumber` must be provided.
48
+ # @return [Object]
49
+ attr_accessor :carrier
50
+
51
+ # Identifies the factoring company that purchased (bought out) the carrier's
52
+ # loads.
53
+ # @return [FactoringCompanyInput]
54
+ attr_accessor :factoring_company
55
+
56
+ # Ordered list of stops for the invoiced shipment. Must include at least an
57
+ # origin and a destination.
58
+ # @return [Array[StopInput]]
59
+ attr_accessor :stops
60
+
61
+ # One or more carrier charge line items on this invoice.
62
+ # @return [Array[ChargeInput]]
63
+ attr_accessor :charges
64
+
65
+ # Physical line items describing the freight being shipped. Each item
66
+ # represents a distinct commodity or handling unit on the load — for
67
+ # example, 4 pallets of paper towels at 2,310 lbs, freight class 100. Items
68
+ # describe **what was moved**; charges describe **what you are billing**.
69
+ # These are independent concepts — charges are not linked to specific items.
70
+ # @return [Array[InvoiceItemInput]]
71
+ attr_accessor :items
72
+
73
+ # One or more reference numbers (PRO, PO, BOL, etc.) to cross-reference this
74
+ # invoice with the TQL load.
75
+ # @return [Array[ReferenceNumberInput]]
76
+ attr_accessor :reference_numbers
77
+
78
+ # Date the invoice was generated or sent by the factoring company. [ISO
79
+ # 8601](https://www.iso.org/iso-8601-date-and-time-format.html) date format
80
+ # (YYYY-MM-DD).
81
+ # @return [Date]
82
+ attr_accessor :invoice_date
83
+
84
+ # Date by which the invoice should be paid, if known. [ISO
85
+ # 8601](https://www.iso.org/iso-8601-date-and-time-format.html) date format
86
+ # (YYYY-MM-DD).
87
+ # @return [Date]
88
+ attr_accessor :invoice_due_date
89
+
90
+ # Invoice payment terms. Use `NetN` where N is the number of days until
91
+ # payment is due (0–365), or `Prepaid` for invoices paid in advance.
92
+ # @return [String]
93
+ attr_accessor :payment_terms
94
+
95
+ # A mapping from model property names to API property names.
96
+ def self.names
97
+ @_hash = {} if @_hash.nil?
98
+ @_hash['type'] = 'type'
99
+ @_hash['load_number'] = 'loadNumber'
100
+ @_hash['invoice_number'] = 'invoiceNumber'
101
+ @_hash['carrier_invoice_number'] = 'carrierInvoiceNumber'
102
+ @_hash['carrier'] = 'carrier'
103
+ @_hash['factoring_company'] = 'factoringCompany'
104
+ @_hash['stops'] = 'stops'
105
+ @_hash['charges'] = 'charges'
106
+ @_hash['items'] = 'items'
107
+ @_hash['reference_numbers'] = 'referenceNumbers'
108
+ @_hash['invoice_date'] = 'invoiceDate'
109
+ @_hash['invoice_due_date'] = 'invoiceDueDate'
110
+ @_hash['payment_terms'] = 'paymentTerms'
111
+ @_hash
112
+ end
113
+
114
+ # An array for optional fields
115
+ def self.optionals
116
+ %w[
117
+ type
118
+ carrier_invoice_number
119
+ items
120
+ invoice_due_date
121
+ payment_terms
122
+ ]
123
+ end
124
+
125
+ # An array for nullable fields
126
+ def self.nullables
127
+ %w[
128
+ carrier_invoice_number
129
+ items
130
+ invoice_due_date
131
+ payment_terms
132
+ ]
133
+ end
134
+
135
+ def initialize(load_number:, invoice_number:, carrier:, factoring_company:,
136
+ stops:, charges:, reference_numbers:, invoice_date:,
137
+ type: InvoiceType::INVOICE, carrier_invoice_number: SKIP,
138
+ items: SKIP, invoice_due_date: SKIP, payment_terms: SKIP,
139
+ additional_properties: nil)
140
+ # Add additional model properties to the instance
141
+ additional_properties = {} if additional_properties.nil?
142
+
143
+ @type = type unless type == SKIP
144
+ @load_number = load_number
145
+ @invoice_number = invoice_number
146
+ @carrier_invoice_number = carrier_invoice_number unless carrier_invoice_number == SKIP
147
+ @carrier = carrier
148
+ @factoring_company = factoring_company
149
+ @stops = stops
150
+ @charges = charges
151
+ @items = items unless items == SKIP
152
+ @reference_numbers = reference_numbers
153
+ @invoice_date = invoice_date
154
+ @invoice_due_date = invoice_due_date unless invoice_due_date == SKIP
155
+ @payment_terms = payment_terms unless payment_terms == SKIP
156
+ @additional_properties = additional_properties
157
+ end
158
+
159
+ # Creates an instance of the object from a hash.
160
+ def self.from_hash(hash)
161
+ return nil unless hash
162
+
163
+ # Extract variables from the hash.
164
+ load_number = hash.key?('loadNumber') ? hash['loadNumber'] : nil
165
+ invoice_number = hash.key?('invoiceNumber') ? hash['invoiceNumber'] : nil
166
+ carrier = hash.key?('carrier') ? APIHelper.deserialize_union_type(
167
+ UnionTypeLookUp.get(:CarrierInput2), hash['carrier']
168
+ ) : nil
169
+ factoring_company = FactoringCompanyInput.from_hash(hash['factoringCompany']) if
170
+ hash['factoringCompany']
171
+ # Parameter is an array, so we need to iterate through it
172
+ stops = nil
173
+ unless hash['stops'].nil?
174
+ stops = []
175
+ hash['stops'].each do |structure|
176
+ stops << (StopInput.from_hash(structure) if structure)
177
+ end
178
+ end
179
+
180
+ stops = nil unless hash.key?('stops')
181
+ # Parameter is an array, so we need to iterate through it
182
+ charges = nil
183
+ unless hash['charges'].nil?
184
+ charges = []
185
+ hash['charges'].each do |structure|
186
+ charges << (ChargeInput.from_hash(structure) if structure)
187
+ end
188
+ end
189
+
190
+ charges = nil unless hash.key?('charges')
191
+ # Parameter is an array, so we need to iterate through it
192
+ reference_numbers = nil
193
+ unless hash['referenceNumbers'].nil?
194
+ reference_numbers = []
195
+ hash['referenceNumbers'].each do |structure|
196
+ reference_numbers << (ReferenceNumberInput.from_hash(structure) if structure)
197
+ end
198
+ end
199
+
200
+ reference_numbers = nil unless hash.key?('referenceNumbers')
201
+ invoice_date = hash.key?('invoiceDate') ? hash['invoiceDate'] : nil
202
+ type = hash['type'] ||= InvoiceType::INVOICE
203
+ carrier_invoice_number =
204
+ hash.key?('carrierInvoiceNumber') ? hash['carrierInvoiceNumber'] : SKIP
205
+ # Parameter is an array, so we need to iterate through it
206
+ items = nil
207
+ unless hash['items'].nil?
208
+ items = []
209
+ hash['items'].each do |structure|
210
+ items << (InvoiceItemInput.from_hash(structure) if structure)
211
+ end
212
+ end
213
+
214
+ items = SKIP unless hash.key?('items')
215
+ invoice_due_date =
216
+ hash.key?('invoiceDueDate') ? hash['invoiceDueDate'] : SKIP
217
+ payment_terms = hash.key?('paymentTerms') ? hash['paymentTerms'] : SKIP
218
+
219
+ # Create a new hash for additional properties, removing known properties.
220
+ new_hash = hash.reject { |k, _| names.value?(k) }
221
+
222
+ additional_properties = APIHelper.get_additional_properties(
223
+ new_hash, proc { |value| value }
224
+ )
225
+
226
+ # Create object from extracted values.
227
+ SubmitInvoiceRequest.new(load_number: load_number,
228
+ invoice_number: invoice_number,
229
+ carrier: carrier,
230
+ factoring_company: factoring_company,
231
+ stops: stops,
232
+ charges: charges,
233
+ reference_numbers: reference_numbers,
234
+ invoice_date: invoice_date,
235
+ type: type,
236
+ carrier_invoice_number: carrier_invoice_number,
237
+ items: items,
238
+ invoice_due_date: invoice_due_date,
239
+ payment_terms: payment_terms,
240
+ additional_properties: additional_properties)
241
+ end
242
+
243
+ # Validates an instance of the object from a given value.
244
+ # @param [SubmitInvoiceRequest | Hash] The value against the validation is performed.
245
+ def self.validate(value)
246
+ if value.instance_of? self
247
+ return (
248
+ APIHelper.valid_type?(value.load_number,
249
+ ->(val) { val.instance_of? String }) and
250
+ APIHelper.valid_type?(value.invoice_number,
251
+ ->(val) { val.instance_of? String }) and
252
+ UnionTypeLookUp.get(:CarrierInput2)
253
+ .validate(value.carrier) and
254
+ APIHelper.valid_type?(value.factoring_company,
255
+ ->(val) { FactoringCompanyInput.validate(val) },
256
+ is_model_hash: true) and
257
+ APIHelper.valid_type?(value.stops,
258
+ ->(val) { StopInput.validate(val) },
259
+ is_model_hash: true,
260
+ is_inner_model_hash: true) and
261
+ APIHelper.valid_type?(value.charges,
262
+ ->(val) { ChargeInput.validate(val) },
263
+ is_model_hash: true,
264
+ is_inner_model_hash: true) and
265
+ APIHelper.valid_type?(value.reference_numbers,
266
+ ->(val) { ReferenceNumberInput.validate(val) },
267
+ is_model_hash: true,
268
+ is_inner_model_hash: true) and
269
+ APIHelper.valid_type?(value.invoice_date,
270
+ ->(val) { val.instance_of? String })
271
+ )
272
+ end
273
+
274
+ return false unless value.instance_of? Hash
275
+
276
+ (
277
+ APIHelper.valid_type?(value['loadNumber'],
278
+ ->(val) { val.instance_of? String }) and
279
+ APIHelper.valid_type?(value['invoiceNumber'],
280
+ ->(val) { val.instance_of? String }) and
281
+ UnionTypeLookUp.get(:CarrierInput2)
282
+ .validate(value['carrier']) and
283
+ APIHelper.valid_type?(value['factoringCompany'],
284
+ ->(val) { FactoringCompanyInput.validate(val) },
285
+ is_model_hash: true) and
286
+ APIHelper.valid_type?(value['stops'],
287
+ ->(val) { StopInput.validate(val) },
288
+ is_model_hash: true,
289
+ is_inner_model_hash: true) and
290
+ APIHelper.valid_type?(value['charges'],
291
+ ->(val) { ChargeInput.validate(val) },
292
+ is_model_hash: true,
293
+ is_inner_model_hash: true) and
294
+ APIHelper.valid_type?(value['referenceNumbers'],
295
+ ->(val) { ReferenceNumberInput.validate(val) },
296
+ is_model_hash: true,
297
+ is_inner_model_hash: true) and
298
+ APIHelper.valid_type?(value['invoiceDate'],
299
+ ->(val) { val.instance_of? String })
300
+ )
301
+ end
302
+
303
+ # Provides a human-readable string representation of the object.
304
+ def to_s
305
+ class_name = self.class.name.split('::').last
306
+ "<#{class_name} type: #{@type}, load_number: #{@load_number}, invoice_number:"\
307
+ " #{@invoice_number}, carrier_invoice_number: #{@carrier_invoice_number}, carrier:"\
308
+ " #{@carrier}, factoring_company: #{@factoring_company}, stops: #{@stops}, charges:"\
309
+ " #{@charges}, items: #{@items}, reference_numbers: #{@reference_numbers}, invoice_date:"\
310
+ " #{@invoice_date}, invoice_due_date: #{@invoice_due_date}, payment_terms:"\
311
+ " #{@payment_terms}, additional_properties: #{@additional_properties}>"
312
+ end
313
+
314
+ # Provides a debugging-friendly string with detailed object information.
315
+ def inspect
316
+ class_name = self.class.name.split('::').last
317
+ "<#{class_name} type: #{@type.inspect}, load_number: #{@load_number.inspect},"\
318
+ " invoice_number: #{@invoice_number.inspect}, carrier_invoice_number:"\
319
+ " #{@carrier_invoice_number.inspect}, carrier: #{@carrier.inspect}, factoring_company:"\
320
+ " #{@factoring_company.inspect}, stops: #{@stops.inspect}, charges: #{@charges.inspect},"\
321
+ " items: #{@items.inspect}, reference_numbers: #{@reference_numbers.inspect}, invoice_date:"\
322
+ " #{@invoice_date.inspect}, invoice_due_date: #{@invoice_due_date.inspect}, payment_terms:"\
323
+ " #{@payment_terms.inspect}, additional_properties: #{@additional_properties}>"
324
+ end
325
+ end
326
+ end