Class: FreightFinancialsWebhookIngestionApi::Charge
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- FreightFinancialsWebhookIngestionApi::Charge
- Defined in:
- lib/freight_financials_webhook_ingestion_api/models/charge.rb
Overview
Charge Model.
Instance Attribute Summary collapse
-
#amount ⇒ Float
TODO: Write general description for this method.
-
#charge_code ⇒ ChargeCode
TODO: Write general description for this method.
-
#currency ⇒ String
TODO: Write general description for this method.
-
#external_id ⇒ String
TODO: Write general description for this method.
-
#item_id ⇒ String
TODO: Write general description for this method.
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.
Instance Method Summary collapse
-
#initialize(amount: SKIP, charge_code: SKIP, currency: SKIP, external_id: SKIP, item_id: SKIP) ⇒ Charge
constructor
A new instance of Charge.
-
#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(amount: SKIP, charge_code: SKIP, currency: SKIP, external_id: SKIP, item_id: SKIP) ⇒ Charge
Returns a new instance of Charge.
62 63 64 65 66 67 68 69 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 62 def initialize(amount: SKIP, charge_code: SKIP, currency: SKIP, external_id: SKIP, item_id: SKIP) @amount = amount unless amount == SKIP @charge_code = charge_code unless charge_code == SKIP @currency = currency unless currency == SKIP @external_id = external_id unless external_id == SKIP @item_id = item_id unless item_id == SKIP end |
Instance Attribute Details
#amount ⇒ Float
TODO: Write general description for this method
14 15 16 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 14 def amount @amount end |
#charge_code ⇒ ChargeCode
TODO: Write general description for this method
18 19 20 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 18 def charge_code @charge_code end |
#currency ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 22 def currency @currency end |
#external_id ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 26 def external_id @external_id end |
#item_id ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 30 def item_id @item_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 72 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : SKIP charge_code = ChargeCode.from_hash(hash['chargeCode']) if hash['chargeCode'] currency = hash.key?('currency') ? hash['currency'] : SKIP external_id = hash.key?('externalId') ? hash['externalId'] : SKIP item_id = hash.key?('itemId') ? hash['itemId'] : SKIP # Create object from extracted values. Charge.new(amount: amount, charge_code: charge_code, currency: currency, external_id: external_id, item_id: item_id) end |
.names ⇒ Object
A mapping from model property names to API property names.
33 34 35 36 37 38 39 40 41 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 33 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['charge_code'] = 'chargeCode' @_hash['currency'] = 'currency' @_hash['external_id'] = 'externalId' @_hash['item_id'] = 'itemId' @_hash end |
.nullables ⇒ Object
An array for nullable fields
55 56 57 58 59 60 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 55 def self.nullables %w[ external_id item_id ] end |
.optionals ⇒ Object
An array for optional fields
44 45 46 47 48 49 50 51 52 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 44 def self.optionals %w[ amount charge_code currency external_id item_id ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
98 99 100 101 102 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 98 def inspect class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount.inspect}, charge_code: #{@charge_code.inspect}, currency:"\ " #{@currency.inspect}, external_id: #{@external_id.inspect}, item_id: #{@item_id.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
91 92 93 94 95 |
# File 'lib/freight_financials_webhook_ingestion_api/models/charge.rb', line 91 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, charge_code: #{@charge_code}, currency: #{@currency},"\ " external_id: #{@external_id}, item_id: #{@item_id}>" end |