Class: ThePlaidApi::OauthErrorCode

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

Overview

OAuth error code

Constant Summary collapse

OAUTH_ERROR_CODE =
[
  # TODO: Write general description for INVALID_REQUEST
  INVALID_REQUEST = 'invalid_request'.freeze,

  # TODO: Write general description for INVALID_CLIENT
  INVALID_CLIENT = 'invalid_client'.freeze,

  # TODO: Write general description for INVALID_GRANT
  INVALID_GRANT = 'invalid_grant'.freeze,

  # TODO: Write general description for UNAUTHORIZED_CLIENT
  UNAUTHORIZED_CLIENT = 'unauthorized_client'.freeze,

  # TODO: Write general description for INVALID_SCOPE
  INVALID_SCOPE = 'invalid_scope'.freeze,

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

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = INVALID_REQUEST) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/the_plaid_api/models/oauth_error_code.rb', line 35

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

  str = value.to_s.strip

  case str.downcase
  when 'invalid_request' then INVALID_REQUEST
  when 'invalid_client' then INVALID_CLIENT
  when 'invalid_grant' then INVALID_GRANT
  when 'unauthorized_client' then UNAUTHORIZED_CLIENT
  when 'invalid_scope' then INVALID_SCOPE
  when 'unsupported_grant_type' then UNSUPPORTED_GRANT_TYPE
  else
    default_value
  end
end

.validate(value) ⇒ Object



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

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

  OAUTH_ERROR_CODE.include?(value)
end