Class: TqlOtrFactoringDataExchange::ChargeInput
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- TqlOtrFactoringDataExchange::ChargeInput
- Defined in:
- lib/tql_otr_factoring_data_exchange/models/charge_input.rb
Overview
A single carrier charge line item. The ‘chargeCode` object identifies the charge type and its originating standard or system.
Instance Attribute Summary collapse
-
#amount ⇒ Float
Monetary amount of the charge.
-
#charge_code ⇒ ChargeCode
Structured charge code identifying the type of charge and the standard or system it originates from.
-
#currency ⇒ String
[ISO 4217](www.iso.org/iso-4217-currency-codes.html) currency code.
-
#external_id ⇒ String
The factoring company’s own identifier for this charge line item.
-
#item_id ⇒ String
Optional reference to an ‘InvoiceItemInput.itemId`, linking this charge to a specific freight item.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(charge_code:, amount:, item_id: SKIP, currency: 'USD', external_id: SKIP, additional_properties: nil) ⇒ ChargeInput
constructor
A new instance of ChargeInput.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(charge_code:, amount:, item_id: SKIP, currency: 'USD', external_id: SKIP, additional_properties: nil) ⇒ ChargeInput
Returns a new instance of ChargeInput.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 66 def initialize(charge_code:, amount:, item_id: SKIP, currency: 'USD', external_id: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @charge_code = charge_code @amount = amount @item_id = item_id unless item_id == SKIP @currency = currency unless currency == SKIP @external_id = external_id unless external_id == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Float
Monetary amount of the charge.
21 22 23 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 21 def amount @amount end |
#charge_code ⇒ ChargeCode
Structured charge code identifying the type of charge and the standard or system it originates from. Allows carriers, factors, and industry standards to coexist on the same invoice.
17 18 19 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 17 def charge_code @charge_code end |
#currency ⇒ String
[ISO 4217](www.iso.org/iso-4217-currency-codes.html) currency code. Defaults to USD.
31 32 33 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 31 def currency @currency end |
#external_id ⇒ String
The factoring company’s own identifier for this charge line item. Echoed back in responses for reconciliation.
36 37 38 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 36 def external_id @external_id end |
#item_id ⇒ String
Optional reference to an ‘InvoiceItemInput.itemId`, linking this charge to a specific freight item.
26 27 28 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 26 def item_id @item_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 80 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. charge_code = ChargeCode.from_hash(hash['chargeCode']) if hash['chargeCode'] amount = hash.key?('amount') ? hash['amount'] : nil item_id = hash.key?('itemId') ? hash['itemId'] : SKIP currency = hash['currency'] ||= 'USD' external_id = hash.key?('externalId') ? hash['externalId'] : SKIP # 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. ChargeInput.new(charge_code: charge_code, amount: amount, item_id: item_id, currency: currency, external_id: external_id, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
39 40 41 42 43 44 45 46 47 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 39 def self.names @_hash = {} if @_hash.nil? @_hash['charge_code'] = 'chargeCode' @_hash['amount'] = 'amount' @_hash['item_id'] = 'itemId' @_hash['currency'] = 'currency' @_hash['external_id'] = 'externalId' @_hash end |
.nullables ⇒ Object
An array for nullable fields
59 60 61 62 63 64 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 59 def self.nullables %w[ item_id external_id ] end |
.optionals ⇒ Object
An array for optional fields
50 51 52 53 54 55 56 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 50 def self.optionals %w[ item_id currency external_id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 108 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.charge_code, ->(val) { ChargeCode.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value.amount, ->(val) { val.instance_of? Float }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['chargeCode'], ->(val) { ChargeCode.validate(val) }, is_model_hash: true) and APIHelper.valid_type?(value['amount'], ->(val) { val.instance_of? Float }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
139 140 141 142 143 144 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 139 def inspect class_name = self.class.name.split('::').last "<#{class_name} charge_code: #{@charge_code.inspect}, amount: #{@amount.inspect}, item_id:"\ " #{@item_id.inspect}, currency: #{@currency.inspect}, external_id: #{@external_id.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
131 132 133 134 135 136 |
# File 'lib/tql_otr_factoring_data_exchange/models/charge_input.rb', line 131 def to_s class_name = self.class.name.split('::').last "<#{class_name} charge_code: #{@charge_code}, amount: #{@amount}, item_id: #{@item_id},"\ " currency: #{@currency}, external_id: #{@external_id}, additional_properties:"\ " #{@additional_properties}>" end |