Class: Plaid::AssetReport

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/plaid/models/asset_report.rb

Overview

An object representing an Asset 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(asset_report_id:, client_report_id:, date_generated:, days_requested:, user:, items:, additional_properties: nil) ⇒ AssetReport

Returns a new instance of AssetReport.



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/plaid/models/asset_report.rb', line 66

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

  @asset_report_id = asset_report_id
  @client_report_id = client_report_id
  @date_generated = date_generated
  @days_requested = days_requested
  @user = user
  @items = items
  @additional_properties = additional_properties
end

Instance Attribute Details

#asset_report_idString

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

Returns:

  • (String)


16
17
18
# File 'lib/plaid/models/asset_report.rb', line 16

def asset_report_id
  @asset_report_id
end

#client_report_idString

An identifier you determine and submit for the Asset Report.

Returns:

  • (String)


20
21
22
# File 'lib/plaid/models/asset_report.rb', line 20

def client_report_id
  @client_report_id
end

#date_generatedDateTime

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

Returns:

  • (DateTime)


26
27
28
# File 'lib/plaid/models/asset_report.rb', line 26

def date_generated
  @date_generated
end

#days_requestedFloat

The duration of transaction history you requested

Returns:

  • (Float)


30
31
32
# File 'lib/plaid/models/asset_report.rb', line 30

def days_requested
  @days_requested
end

#itemsArray[AssetReportItem]

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

Returns:



42
43
44
# File 'lib/plaid/models/asset_report.rb', line 42

def items
  @items
end

#userAssetReportUser

The user object allows you to provide additional information about the user to be appended to the Asset Report. All fields are optional. The ‘first_name`, `last_name`, and `ssn` fields are required if you would like the Report to be eligible for Fannie Mae’s Day 1 Certainty™ program.

Returns:



37
38
39
# File 'lib/plaid/models/asset_report.rb', line 37

def user
  @user
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
114
115
116
117
118
119
120
121
# File 'lib/plaid/models/asset_report.rb', line 81

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  asset_report_id =
    hash.key?('asset_report_id') ? hash['asset_report_id'] : nil
  client_report_id =
    hash.key?('client_report_id') ? hash['client_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
  user = AssetReportUser.from_hash(hash['user']) if hash['user']
  # Parameter is an array, so we need to iterate through it
  items = nil
  unless hash['items'].nil?
    items = []
    hash['items'].each do |structure|
      items << (AssetReportItem.from_hash(structure) if structure)
    end
  end

  items = nil unless hash.key?('items')

  # 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.
  AssetReport.new(asset_report_id: asset_report_id,
                  client_report_id: client_report_id,
                  date_generated: date_generated,
                  days_requested: days_requested,
                  user: user,
                  items: items,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
# File 'lib/plaid/models/asset_report.rb', line 45

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

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/plaid/models/asset_report.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



57
58
59
# File 'lib/plaid/models/asset_report.rb', line 57

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



137
138
139
140
141
142
143
# File 'lib/plaid/models/asset_report.rb', line 137

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

#to_custom_date_generatedObject



123
124
125
# File 'lib/plaid/models/asset_report.rb', line 123

def to_custom_date_generated
  DateTimeHelper.to_rfc3339(date_generated)
end

#to_sObject

Provides a human-readable string representation of the object.



128
129
130
131
132
133
134
# File 'lib/plaid/models/asset_report.rb', line 128

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