Class: ThePlaidApi::Scopes

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

Overview

The scopes object

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(product_access: SKIP, accounts: SKIP, new_accounts: true, additional_properties: nil) ⇒ Scopes

Returns a new instance of Scopes.



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

def initialize(product_access: SKIP, accounts: SKIP, new_accounts: true,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @product_access = product_access unless product_access == SKIP
  @accounts = accounts unless accounts == SKIP
  @new_accounts = new_accounts unless new_accounts == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#accountsArray[AccountAccess]

The product access being requested. Used to or disallow product access across all accounts. If unset, defaults to all products allowed.

Returns:



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

def accounts
  @accounts
end

#new_accountsTrueClass | FalseClass

Allow access to newly opened accounts as they are opened. If unset, defaults to ‘true`.

Returns:

  • (TrueClass | FalseClass)


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

def new_accounts
  @new_accounts
end

#product_accessProductAccess

The product access being requested. Used to or disallow product access across all accounts. If unset, defaults to all products allowed.

Returns:



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

def product_access
  @product_access
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/the_plaid_api/models/scopes.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  product_access = ProductAccess.from_hash(hash['product_access']) if hash['product_access']
  # Parameter is an array, so we need to iterate through it
  accounts = nil
  unless hash['accounts'].nil?
    accounts = []
    hash['accounts'].each do |structure|
      accounts << (AccountAccess.from_hash(structure) if structure)
    end
  end

  accounts = SKIP unless hash.key?('accounts')
  new_accounts = hash['new_accounts'] ||= true

  # 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.
  Scopes.new(product_access: product_access,
             accounts: accounts,
             new_accounts: new_accounts,
             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/the_plaid_api/models/scopes.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['product_access'] = 'product_access'
  @_hash['accounts'] = 'accounts'
  @_hash['new_accounts'] = 'new_accounts'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
49
50
# File 'lib/the_plaid_api/models/scopes.rb', line 46

def self.nullables
  %w[
    new_accounts
  ]
end

.optionalsObject

An array for optional fields



37
38
39
40
41
42
43
# File 'lib/the_plaid_api/models/scopes.rb', line 37

def self.optionals
  %w[
    product_access
    accounts
    new_accounts
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



103
104
105
106
107
# File 'lib/the_plaid_api/models/scopes.rb', line 103

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} product_access: #{@product_access.inspect}, accounts: #{@accounts.inspect},"\
  " new_accounts: #{@new_accounts.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
# File 'lib/the_plaid_api/models/scopes.rb', line 96

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} product_access: #{@product_access}, accounts: #{@accounts}, new_accounts:"\
  " #{@new_accounts}, additional_properties: #{@additional_properties}>"
end