Class: ThePlaidApi::BaseReport

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

Overview

An object representing a Base Report

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(report_id:, date_generated:, days_requested:, items:, client_report_id: SKIP, attributes: SKIP, additional_properties: nil) ⇒ BaseReport

Returns a new instance of BaseReport.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/the_plaid_api/models/base_report.rb', line 70

def initialize(report_id:, date_generated:, days_requested:, items:,
               client_report_id: SKIP, attributes: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @report_id = report_id
  @date_generated = date_generated
  @days_requested = days_requested
  @client_report_id = client_report_id unless client_report_id == SKIP
  @items = items
  @attributes = attributes unless attributes == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#attributesBaseReportUserAttributes

Calculated attributes derived from transaction-level data, aggregated across accounts.



41
42
43
# File 'lib/the_plaid_api/models/base_report.rb', line 41

def attributes
  @attributes
end

#client_report_idString

Client-generated identifier, which can be used by lenders to track loan applications.

Returns:

  • (String)


31
32
33
# File 'lib/the_plaid_api/models/base_report.rb', line 31

def client_report_id
  @client_report_id
end

#date_generatedDateTime

The date and time when the Base Report was created, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format (e.g. ā€œ2018-04-12T03:32:11Zā€).

Returns:

  • (DateTime)


22
23
24
# File 'lib/the_plaid_api/models/base_report.rb', line 22

def date_generated
  @date_generated
end

#days_requestedFloat

The number of days of transaction history requested.

Returns:

  • (Float)


26
27
28
# File 'lib/the_plaid_api/models/base_report.rb', line 26

def days_requested
  @days_requested
end

#itemsArray[BaseReportItem]

Data returned by Plaid about each of the Items included in the Base Report.

Returns:



36
37
38
# File 'lib/the_plaid_api/models/base_report.rb', line 36

def items
  @items
end

#report_idString

A unique ID identifying an Base Report. Like all Plaid identifiers, this ID is case sensitive.

Returns:

  • (String)


16
17
18
# File 'lib/the_plaid_api/models/base_report.rb', line 16

def report_id
  @report_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/the_plaid_api/models/base_report.rb', line 86

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  report_id = hash.key?('report_id') ? hash['report_id'] : nil
  date_generated = if hash.key?('date_generated')
                     (DateTimeHelper.from_rfc3339(hash['date_generated']) if hash['date_generated'])
                   end
  days_requested =
    hash.key?('days_requested') ? hash['days_requested'] : nil
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (BaseReportItem.from_hash(structure) if structure)
    end
  end

  items = nil unless hash.key?('items')
  client_report_id =
    hash.key?('client_report_id') ? hash['client_report_id'] : SKIP
  attributes = BaseReportUserAttributes.from_hash(hash['attributes']) if hash['attributes']

  # 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.
  BaseReport.new(report_id: report_id,
                 date_generated: date_generated,
                 days_requested: days_requested,
                 items: items,
                 client_report_id: client_report_id,
                 attributes: attributes,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



44
45
46
47
48
49
50
51
52
53
# File 'lib/the_plaid_api/models/base_report.rb', line 44

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['report_id'] = 'report_id'
  @_hash['date_generated'] = 'date_generated'
  @_hash['days_requested'] = 'days_requested'
  @_hash['client_report_id'] = 'client_report_id'
  @_hash['items'] = 'items'
  @_hash['attributes'] = 'attributes'
  @_hash
end

.nullablesObject

An array for nullable fields



64
65
66
67
68
# File 'lib/the_plaid_api/models/base_report.rb', line 64

def self.nullables
  %w[
    client_report_id
  ]
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
# File 'lib/the_plaid_api/models/base_report.rb', line 56

def self.optionals
  %w[
    client_report_id
    attributes
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



140
141
142
143
144
145
146
# File 'lib/the_plaid_api/models/base_report.rb', line 140

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} report_id: #{@report_id.inspect}, date_generated:"\
  " #{@date_generated.inspect}, days_requested: #{@days_requested.inspect}, client_report_id:"\
  " #{@client_report_id.inspect}, items: #{@items.inspect}, attributes:"\
  " #{@attributes.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_date_generatedObject



127
128
129
# File 'lib/the_plaid_api/models/base_report.rb', line 127

def to_custom_date_generated
  DateTimeHelper.to_rfc3339(date_generated)
end

#to_sObject

Provides a human-readable string representation of the object.



132
133
134
135
136
137
# File 'lib/the_plaid_api/models/base_report.rb', line 132

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} report_id: #{@report_id}, date_generated: #{@date_generated},"\
  " days_requested: #{@days_requested}, client_report_id: #{@client_report_id}, items:"\
  " #{@items}, attributes: #{@attributes}, additional_properties: #{@additional_properties}>"
end