Class: ThePlaidApi::StatementsStatement

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/statements_statement.rb

Overview

A statement’s metadata associated with an account

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(statement_id:, month:, year:, date_posted: SKIP, additional_properties: nil) ⇒ StatementsStatement

Returns a new instance of StatementsStatement.



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/the_plaid_api/models/statements_statement.rb', line 53

def initialize(statement_id:, month:, year:, date_posted: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @statement_id = statement_id
  @date_posted = date_posted unless date_posted == SKIP
  @month = month
  @year = year
  @additional_properties = additional_properties
end

Instance Attribute Details

#date_postedDate

Date when the statement was posted by the FI, if known

Returns:

  • (Date)


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

def date_posted
  @date_posted
end

#monthInteger

Month of the year. Possible values: 1 through 12 (January through December).

Returns:

  • (Integer)


23
24
25
# File 'lib/the_plaid_api/models/statements_statement.rb', line 23

def month
  @month
end

#statement_idString

Plaid’s unique identifier for the statement.

Returns:

  • (String)


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

def statement_id
  @statement_id
end

#yearInteger

The year of statement.

Returns:

  • (Integer)


27
28
29
# File 'lib/the_plaid_api/models/statements_statement.rb', line 27

def year
  @year
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/the_plaid_api/models/statements_statement.rb', line 66

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  statement_id = hash.key?('statement_id') ? hash['statement_id'] : nil
  month = hash.key?('month') ? hash['month'] : nil
  year = hash.key?('year') ? hash['year'] : nil
  date_posted = hash.key?('date_posted') ? hash['date_posted'] : SKIP

  # 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.
  StatementsStatement.new(statement_id: statement_id,
                          month: month,
                          year: year,
                          date_posted: date_posted,
                          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/the_plaid_api/models/statements_statement.rb', line 30

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['statement_id'] = 'statement_id'
  @_hash['date_posted'] = 'date_posted'
  @_hash['month'] = 'month'
  @_hash['year'] = 'year'
  @_hash
end

.nullablesObject

An array for nullable fields



47
48
49
50
51
# File 'lib/the_plaid_api/models/statements_statement.rb', line 47

def self.nullables
  %w[
    date_posted
  ]
end

.optionalsObject

An array for optional fields



40
41
42
43
44
# File 'lib/the_plaid_api/models/statements_statement.rb', line 40

def self.optionals
  %w[
    date_posted
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



98
99
100
101
102
103
# File 'lib/the_plaid_api/models/statements_statement.rb', line 98

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} statement_id: #{@statement_id.inspect}, date_posted:"\
  " #{@date_posted.inspect}, month: #{@month.inspect}, year: #{@year.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



91
92
93
94
95
# File 'lib/the_plaid_api/models/statements_statement.rb', line 91

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} statement_id: #{@statement_id}, date_posted: #{@date_posted}, month:"\
  " #{@month}, year: #{@year}, additional_properties: #{@additional_properties}>"
end