Class: FreightFinancialsWebhookIngestionApi::Payment

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/freight_financials_webhook_ingestion_api/models/payment.rb

Overview

Payment Model.

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(currency: SKIP, due_date: SKIP, invoice_amount: SKIP, paid_amount: SKIP) ⇒ Payment

Returns a new instance of Payment.



55
56
57
58
59
60
61
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 55

def initialize(currency: SKIP, due_date: SKIP, invoice_amount: SKIP,
               paid_amount: SKIP)
  @currency = currency unless currency == SKIP
  @due_date = due_date unless due_date == SKIP
  @invoice_amount = invoice_amount unless invoice_amount == SKIP
  @paid_amount = paid_amount unless paid_amount == SKIP
end

Instance Attribute Details

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 14

def currency
  @currency
end

#due_dateDate

TODO: Write general description for this method

Returns:

  • (Date)


18
19
20
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 18

def due_date
  @due_date
end

#invoice_amountFloat

TODO: Write general description for this method

Returns:

  • (Float)


22
23
24
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 22

def invoice_amount
  @invoice_amount
end

TODO: Write general description for this method

Returns:

  • (Float)


26
27
28
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 26

def paid_amount
  @paid_amount
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  due_date = hash.key?('dueDate') ? hash['dueDate'] : SKIP
  invoice_amount = hash.key?('invoiceAmount') ? hash['invoiceAmount'] : SKIP
  paid_amount = hash.key?('paidAmount') ? hash['paidAmount'] : SKIP

  # Create object from extracted values.
  Payment.new(currency: currency,
              due_date: due_date,
              invoice_amount: invoice_amount,
              paid_amount: paid_amount)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['currency'] = 'currency'
  @_hash['due_date'] = 'dueDate'
  @_hash['invoice_amount'] = 'invoiceAmount'
  @_hash['paid_amount'] = 'paidAmount'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
52
53
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 49

def self.nullables
  %w[
    due_date
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    currency
    due_date
    invoice_amount
    paid_amount
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



88
89
90
91
92
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 88

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} currency: #{@currency.inspect}, due_date: #{@due_date.inspect},"\
  " invoice_amount: #{@invoice_amount.inspect}, paid_amount: #{@paid_amount.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



81
82
83
84
85
# File 'lib/freight_financials_webhook_ingestion_api/models/payment.rb', line 81

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} currency: #{@currency}, due_date: #{@due_date}, invoice_amount:"\
  " #{@invoice_amount}, paid_amount: #{@paid_amount}>"
end