Class: ThePlaidApi::TransactionsCategoryRule

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

Overview

A representation of a transactions category rule.

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(id: SKIP, user_id: SKIP, created_at: SKIP, updated_at: SKIP, pfc_primary_category: SKIP, pfc_detailed_category: SKIP, rule_details: SKIP, additional_properties: nil) ⇒ TransactionsCategoryRule

Returns a new instance of TransactionsCategoryRule.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 83

def initialize(id: SKIP, user_id: SKIP, created_at: SKIP, updated_at: SKIP,
               pfc_primary_category: SKIP, pfc_detailed_category: SKIP,
               rule_details: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id unless id == SKIP
  @user_id = user_id unless user_id == SKIP
  @created_at = created_at unless created_at == SKIP
  @updated_at = updated_at unless updated_at == SKIP
  @pfc_primary_category = pfc_primary_category unless pfc_primary_category == SKIP
  @pfc_detailed_category = pfc_detailed_category unless pfc_detailed_category == SKIP
  @rule_details = rule_details unless rule_details == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_atDateTime

Date and time when a rule was created in [ISO 8601](wikipedia.org/wiki/ISO_8601) format ( ‘YYYY-MM-DDTHH:mm:ssZ` ).

Returns:

  • (DateTime)


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

def created_at
  @created_at
end

#idString

A unique identifier of the rule created

Returns:

  • (String)


15
16
17
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 15

def id
  @id
end

#pfc_detailed_categoryString

A personal finance detailed category. See the [taxonomy csv file](plaid.com/documents/pfc-taxonomy-all.csv) for a full list of personal finance categories.

Returns:

  • (String)


46
47
48
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 46

def pfc_detailed_category
  @pfc_detailed_category
end

#pfc_primary_categoryString

A personal finance primary category. See the [taxonomy csv file](plaid.com/documents/pfc-taxonomy-all.csv) for a full list of personal finance categories.

Returns:

  • (String)


39
40
41
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 39

def pfc_primary_category
  @pfc_primary_category
end

#rule_detailsTransactionsRuleDetails

A representation of transactions rule details.



50
51
52
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 50

def rule_details
  @rule_details
end

#updated_atDateTime

Date and time when a rule was last updated in [ISO 8601](wikipedia.org/wiki/ISO_8601) format ( ‘YYYY-MM-DDTHH:mm:ssZ` ).

Returns:

  • (DateTime)


32
33
34
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 32

def updated_at
  @updated_at
end

#user_idString

The Plaid-generated unique identifier for the end user this rule belongs to.

Returns:

  • (String)


20
21
22
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 20

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 100

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  user_id = hash.key?('user_id') ? hash['user_id'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  updated_at = if hash.key?('updated_at')
                 (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at'])
               else
                 SKIP
               end
  pfc_primary_category =
    hash.key?('pfc_primary_category') ? hash['pfc_primary_category'] : SKIP
  pfc_detailed_category =
    hash.key?('pfc_detailed_category') ? hash['pfc_detailed_category'] : SKIP
  rule_details = TransactionsRuleDetails.from_hash(hash['rule_details']) if
    hash['rule_details']

  # 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.
  TransactionsCategoryRule.new(id: id,
                               user_id: user_id,
                               created_at: created_at,
                               updated_at: updated_at,
                               pfc_primary_category: pfc_primary_category,
                               pfc_detailed_category: pfc_detailed_category,
                               rule_details: rule_details,
                               additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['user_id'] = 'user_id'
  @_hash['created_at'] = 'created_at'
  @_hash['updated_at'] = 'updated_at'
  @_hash['pfc_primary_category'] = 'pfc_primary_category'
  @_hash['pfc_detailed_category'] = 'pfc_detailed_category'
  @_hash['rule_details'] = 'rule_details'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 66

def self.optionals
  %w[
    id
    user_id
    created_at
    updated_at
    pfc_primary_category
    pfc_detailed_category
    rule_details
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



159
160
161
162
163
164
165
166
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 159

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, user_id: #{@user_id.inspect}, created_at:"\
  " #{@created_at.inspect}, updated_at: #{@updated_at.inspect}, pfc_primary_category:"\
  " #{@pfc_primary_category.inspect}, pfc_detailed_category:"\
  " #{@pfc_detailed_category.inspect}, rule_details: #{@rule_details.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_created_atObject



141
142
143
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 141

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_updated_atObject



145
146
147
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 145

def to_custom_updated_at
  DateTimeHelper.to_rfc3339(updated_at)
end

#to_sObject

Provides a human-readable string representation of the object.



150
151
152
153
154
155
156
# File 'lib/the_plaid_api/models/transactions_category_rule.rb', line 150

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, user_id: #{@user_id}, created_at: #{@created_at}, updated_at:"\
  " #{@updated_at}, pfc_primary_category: #{@pfc_primary_category}, pfc_detailed_category:"\
  " #{@pfc_detailed_category}, rule_details: #{@rule_details}, additional_properties:"\
  " #{@additional_properties}>"
end