Class: SplititWebApiV4::InstallmentItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/splitit_web_api_v4/models/installment_item.rb

Overview

InstallmentItem 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(installment_number:, status:, amount: SKIP, process_date_time: SKIP, additional_properties: nil) ⇒ InstallmentItem

Returns a new instance of InstallmentItem.



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 52

def initialize(installment_number:, status:, amount: SKIP,
               process_date_time: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @installment_number = installment_number
  @amount = amount unless amount == SKIP
  @status = status
  @process_date_time = process_date_time unless process_date_time == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#amountAmountData

TODO: Write general description for this method

Returns:



19
20
21
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 19

def amount
  @amount
end

#installment_numberInteger

TODO: Write general description for this method

Returns:

  • (Integer)


15
16
17
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 15

def installment_number
  @installment_number
end

#process_date_timeDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


27
28
29
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 27

def process_date_time
  @process_date_time
end

#statusInstallmentStatus

TODO: Write general description for this method

Returns:



23
24
25
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 23

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 65

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  installment_number =
    hash.key?('InstallmentNumber') ? hash['InstallmentNumber'] : nil
  status = hash.key?('Status') ? hash['Status'] : nil
  amount = AmountData.from_hash(hash['Amount']) if hash['Amount']
  process_date_time = if hash.key?('ProcessDateTime')
                        (DateTimeHelper.from_rfc3339(hash['ProcessDateTime']) if hash['ProcessDateTime'])
                      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.
  InstallmentItem.new(installment_number: installment_number,
                      status: status,
                      amount: amount,
                      process_date_time: process_date_time,
                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



30
31
32
33
34
35
36
37
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['installment_number'] = 'InstallmentNumber'
  @_hash['amount'] = 'Amount'
  @_hash['status'] = 'Status'
  @_hash['process_date_time'] = 'ProcessDateTime'
  @_hash
end

.nullablesObject

An array for nullable fields



48
49
50
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 48

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 40

def self.optionals
  %w[
    amount
    process_date_time
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



107
108
109
110
111
112
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 107

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} installment_number: #{@installment_number.inspect}, amount:"\
  " #{@amount.inspect}, status: #{@status.inspect}, process_date_time:"\
  " #{@process_date_time.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_process_date_timeObject



94
95
96
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 94

def to_custom_process_date_time
  DateTimeHelper.to_rfc3339(process_date_time)
end

#to_sObject

Provides a human-readable string representation of the object.



99
100
101
102
103
104
# File 'lib/splitit_web_api_v4/models/installment_item.rb', line 99

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} installment_number: #{@installment_number}, amount: #{@amount}, status:"\
  " #{@status}, process_date_time: #{@process_date_time}, additional_properties:"\
  " #{@additional_properties}>"
end