Class: ThePlaidApi::ScopesContext

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

Overview

An indicator for when scopes are being updated. When scopes are updated via enrollment (i.e. OAuth), the partner must send ‘ENROLLMENT`. When scopes are updated in a post-enrollment view, the partner must send `PORTAL`.

Constant Summary collapse

SCOPES_CONTEXT =
[
  # TODO: Write general description for ENROLLMENT
  ENROLLMENT = 'ENROLLMENT'.freeze,

  # TODO: Write general description for PORTAL
  PORTAL = 'PORTAL'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = ENROLLMENT) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/the_plaid_api/models/scopes_context.rb', line 25

def self.from_value(value, default_value = ENROLLMENT)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'enrollment' then ENROLLMENT
  when 'portal' then PORTAL
  else
    default_value
  end
end

.validate(value) ⇒ Object



19
20
21
22
23
# File 'lib/the_plaid_api/models/scopes_context.rb', line 19

def self.validate(value)
  return false if value.nil?

  SCOPES_CONTEXT.include?(value)
end