Class: ThePlaidApi::Taxform
- Defined in:
- lib/the_plaid_api/models/taxform.rb
Overview
Data about an official document used to report the user’s income to the IRS.
Instance Attribute Summary collapse
-
#doc_id ⇒ String
An identifier of the document referenced by the document metadata.
-
#document_type ⇒ String
The type of tax document.
-
#w2 ⇒ W2
W2 is an object that represents income data taken from a W2 tax document.
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(document_type:, doc_id: SKIP, w2: SKIP, additional_properties: nil) ⇒ Taxform
constructor
A new instance of Taxform.
-
#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(document_type:, doc_id: SKIP, w2: SKIP, additional_properties: nil) ⇒ Taxform
Returns a new instance of Taxform.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/the_plaid_api/models/taxform.rb', line 46 def initialize(document_type:, doc_id: SKIP, w2: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @doc_id = doc_id unless doc_id == SKIP @document_type = document_type @w2 = w2 unless w2 == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#doc_id ⇒ String
An identifier of the document referenced by the document metadata.
14 15 16 |
# File 'lib/the_plaid_api/models/taxform.rb', line 14 def doc_id @doc_id end |
#document_type ⇒ String
The type of tax document. Currently, the only supported value is ‘w2`.
18 19 20 |
# File 'lib/the_plaid_api/models/taxform.rb', line 18 def document_type @document_type end |
#w2 ⇒ W2
W2 is an object that represents income data taken from a W2 tax document.
22 23 24 |
# File 'lib/the_plaid_api/models/taxform.rb', line 22 def w2 @w2 end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/the_plaid_api/models/taxform.rb', line 58 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. document_type = hash.key?('document_type') ? hash['document_type'] : nil doc_id = hash.key?('doc_id') ? hash['doc_id'] : SKIP w2 = W2.from_hash(hash['w2']) if hash['w2'] # 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. Taxform.new(document_type: document_type, doc_id: doc_id, w2: w2, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
25 26 27 28 29 30 31 |
# File 'lib/the_plaid_api/models/taxform.rb', line 25 def self.names @_hash = {} if @_hash.nil? @_hash['doc_id'] = 'doc_id' @_hash['document_type'] = 'document_type' @_hash['w2'] = 'w2' @_hash end |
.nullables ⇒ Object
An array for nullable fields
42 43 44 |
# File 'lib/the_plaid_api/models/taxform.rb', line 42 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
34 35 36 37 38 39 |
# File 'lib/the_plaid_api/models/taxform.rb', line 34 def self.optionals %w[ doc_id w2 ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
88 89 90 91 92 |
# File 'lib/the_plaid_api/models/taxform.rb', line 88 def inspect class_name = self.class.name.split('::').last "<#{class_name} doc_id: #{@doc_id.inspect}, document_type: #{@document_type.inspect}, w2:"\ " #{@w2.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
81 82 83 84 85 |
# File 'lib/the_plaid_api/models/taxform.rb', line 81 def to_s class_name = self.class.name.split('::').last "<#{class_name} doc_id: #{@doc_id}, document_type: #{@document_type}, w2: #{@w2},"\ " additional_properties: #{@additional_properties}>" end |