Class: ThePlaidApi::CraMonitoringInsightsItem

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

Overview

An object representing a Monitoring Insights Item

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(date_generated:, item_id:, institution_id:, institution_name:, status:, insights:, accounts: SKIP, additional_properties: nil) ⇒ CraMonitoringInsightsItem

Returns a new instance of CraMonitoringInsightsItem.



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

def initialize(date_generated:, item_id:, institution_id:,
               institution_name:, status:, insights:, accounts: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @date_generated = date_generated
  @item_id = item_id
  @institution_id = institution_id
  @institution_name = institution_name
  @status = status
  @insights = insights
  @accounts = accounts unless accounts == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#accountsArray[BaseReportAccount]

Data about each of the accounts open on the Item.

Returns:



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

def accounts
  @accounts
end

#date_generatedDateTime

The date and time when the specific insights were generated (per-item), in [ISO 8601](wikipedia.org/wiki/ISO_8601) format (e.g. “2018-04-12T03:32:11Z”).

Returns:

  • (DateTime)


17
18
19
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 17

def date_generated
  @date_generated
end

#insightsMonitoringInsights

An object representing the Monitoring Insights for the given Item

Returns:



37
38
39
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 37

def insights
  @insights
end

#institution_idString

The id of the financial institution associated with the Item.

Returns:

  • (String)


25
26
27
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 25

def institution_id
  @institution_id
end

#institution_nameString

The full financial institution name associated with the Item.

Returns:

  • (String)


29
30
31
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 29

def institution_name
  @institution_name
end

#item_idString

The ‘item_id` of the Item associated with the insights

Returns:

  • (String)


21
22
23
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 21

def item_id
  @item_id
end

#statusMonitoringInsightsItemStatus

An object with details of the Monitoring Insights Item’s status.



33
34
35
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 33

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
126
127
128
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 87

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  date_generated = if hash.key?('date_generated')
                     (DateTimeHelper.from_rfc3339(hash['date_generated']) if hash['date_generated'])
                   end
  item_id = hash.key?('item_id') ? hash['item_id'] : nil
  institution_id =
    hash.key?('institution_id') ? hash['institution_id'] : nil
  institution_name =
    hash.key?('institution_name') ? hash['institution_name'] : nil
  status = MonitoringInsightsItemStatus.from_hash(hash['status']) if hash['status']
  insights = MonitoringInsights.from_hash(hash['insights']) if hash['insights']
  # Parameter is an array, so we need to iterate through it
  accounts = nil
  unless hash['accounts'].nil?
    accounts = []
    hash['accounts'].each do |structure|
      accounts << (BaseReportAccount.from_hash(structure) if structure)
    end
  end

  accounts = SKIP unless hash.key?('accounts')

  # 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.
  CraMonitoringInsightsItem.new(date_generated: date_generated,
                                item_id: item_id,
                                institution_id: institution_id,
                                institution_name: institution_name,
                                status: status,
                                insights: insights,
                                accounts: accounts,
                                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
54
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 44

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['date_generated'] = 'date_generated'
  @_hash['item_id'] = 'item_id'
  @_hash['institution_id'] = 'institution_id'
  @_hash['institution_name'] = 'institution_name'
  @_hash['status'] = 'status'
  @_hash['insights'] = 'insights'
  @_hash['accounts'] = 'accounts'
  @_hash
end

.nullablesObject

An array for nullable fields



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

def self.nullables
  %w[
    insights
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    accounts
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



143
144
145
146
147
148
149
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 143

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} date_generated: #{@date_generated.inspect}, item_id: #{@item_id.inspect},"\
  " institution_id: #{@institution_id.inspect}, institution_name:"\
  " #{@institution_name.inspect}, status: #{@status.inspect}, insights: #{@insights.inspect},"\
  " accounts: #{@accounts.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_date_generatedObject



130
131
132
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 130

def to_custom_date_generated
  DateTimeHelper.to_rfc3339(date_generated)
end

#to_sObject

Provides a human-readable string representation of the object.



135
136
137
138
139
140
# File 'lib/the_plaid_api/models/cra_monitoring_insights_item.rb', line 135

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} date_generated: #{@date_generated}, item_id: #{@item_id}, institution_id:"\
  " #{@institution_id}, institution_name: #{@institution_name}, status: #{@status}, insights:"\
  " #{@insights}, accounts: #{@accounts}, additional_properties: #{@additional_properties}>"
end