Class: ThePlaidApi::Deductions
- Defined in:
- lib/the_plaid_api/models/deductions.rb
Overview
An object with the deduction information found on a paystub.
Instance Attribute Summary collapse
-
#breakdown ⇒ Array[DeductionsBreakdown]
TODO: Write general description for this method.
-
#subtotals ⇒ Array[Total]
TODO: Write general description for this method.
-
#total ⇒ DeductionsTotal
An object representing the total deductions for the pay period.
-
#totals ⇒ Array[Total]
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(breakdown:, total:, subtotals: SKIP, totals: SKIP, additional_properties: nil) ⇒ Deductions
constructor
A new instance of Deductions.
-
#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(breakdown:, total:, subtotals: SKIP, totals: SKIP, additional_properties: nil) ⇒ Deductions
Returns a new instance of Deductions.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/the_plaid_api/models/deductions.rb', line 51 def initialize(breakdown:, total:, subtotals: SKIP, totals: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @subtotals = subtotals unless subtotals == SKIP @breakdown = breakdown @totals = totals unless totals == SKIP @total = total @additional_properties = additional_properties end |
Instance Attribute Details
#breakdown ⇒ Array[DeductionsBreakdown]
TODO: Write general description for this method
18 19 20 |
# File 'lib/the_plaid_api/models/deductions.rb', line 18 def breakdown @breakdown end |
#subtotals ⇒ Array[Total]
TODO: Write general description for this method
14 15 16 |
# File 'lib/the_plaid_api/models/deductions.rb', line 14 def subtotals @subtotals end |
#total ⇒ DeductionsTotal
An object representing the total deductions for the pay period
26 27 28 |
# File 'lib/the_plaid_api/models/deductions.rb', line 26 def total @total end |
#totals ⇒ Array[Total]
TODO: Write general description for this method
22 23 24 |
# File 'lib/the_plaid_api/models/deductions.rb', line 22 def totals @totals 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 79 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 105 106 107 108 109 110 111 112 113 |
# File 'lib/the_plaid_api/models/deductions.rb', line 64 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it breakdown = nil unless hash['breakdown'].nil? breakdown = [] hash['breakdown'].each do |structure| breakdown << (DeductionsBreakdown.from_hash(structure) if structure) end end breakdown = nil unless hash.key?('breakdown') total = DeductionsTotal.from_hash(hash['total']) if hash['total'] # Parameter is an array, so we need to iterate through it subtotals = nil unless hash['subtotals'].nil? subtotals = [] hash['subtotals'].each do |structure| subtotals << (Total.from_hash(structure) if structure) end end subtotals = SKIP unless hash.key?('subtotals') # Parameter is an array, so we need to iterate through it totals = nil unless hash['totals'].nil? totals = [] hash['totals'].each do |structure| totals << (Total.from_hash(structure) if structure) end end totals = SKIP unless hash.key?('totals') # 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. Deductions.new(breakdown: breakdown, total: total, subtotals: subtotals, totals: totals, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 36 |
# File 'lib/the_plaid_api/models/deductions.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['subtotals'] = 'subtotals' @_hash['breakdown'] = 'breakdown' @_hash['totals'] = 'totals' @_hash['total'] = 'total' @_hash end |
.nullables ⇒ Object
An array for nullable fields
47 48 49 |
# File 'lib/the_plaid_api/models/deductions.rb', line 47 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
39 40 41 42 43 44 |
# File 'lib/the_plaid_api/models/deductions.rb', line 39 def self.optionals %w[ subtotals totals ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
123 124 125 126 127 128 |
# File 'lib/the_plaid_api/models/deductions.rb', line 123 def inspect class_name = self.class.name.split('::').last "<#{class_name} subtotals: #{@subtotals.inspect}, breakdown: #{@breakdown.inspect}, totals:"\ " #{@totals.inspect}, total: #{@total.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
116 117 118 119 120 |
# File 'lib/the_plaid_api/models/deductions.rb', line 116 def to_s class_name = self.class.name.split('::').last "<#{class_name} subtotals: #{@subtotals}, breakdown: #{@breakdown}, totals: #{@totals},"\ " total: #{@total}, additional_properties: #{@additional_properties}>" end |