Class: ThePlaidApi::Taxform

Inherits:
BaseModel
  • Object
show all
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

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(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_idString

An identifier of the document referenced by the document metadata.

Returns:

  • (String)


14
15
16
# File 'lib/the_plaid_api/models/taxform.rb', line 14

def doc_id
  @doc_id
end

#document_typeString

The type of tax document. Currently, the only supported value is ‘w2`.

Returns:

  • (String)


18
19
20
# File 'lib/the_plaid_api/models/taxform.rb', line 18

def document_type
  @document_type
end

#w2W2

W2 is an object that represents income data taken from a W2 tax document.

Returns:



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

.namesObject

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

.nullablesObject

An array for nullable fields



42
43
44
# File 'lib/the_plaid_api/models/taxform.rb', line 42

def self.nullables
  []
end

.optionalsObject

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

#inspectObject

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_sObject

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