Class: FdxV660Api::OauthScopeOauthFapi1Baseline

Inherits:
Object
  • Object
show all
Defined in:
lib/fdx_v660_api/models/oauth_scope_oauth_fapi1_baseline.rb

Overview

OAuth 2 scopes supported by the API

Constant Summary collapse

OAUTH_SCOPE_OAUTH_FAPI1_BASELINE =
[
  # Scope authorizing publishing of a new notification
  FDXNOTIFICATIONSPUBLISH = 'fdx:notifications:publish'.freeze,

  # Scope authorizing creation of a new notification subscription
  FDXNOTIFICATIONSSUBSCRIBE = 'fdx:notifications:subscribe'.freeze,

  # Scope authorizing the client to refresh `access_tokens` without user
  # present
  OFFLINE_ACCESS = 'offline_access'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = FDXNOTIFICATIONSPUBLISH) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fdx_v660_api/models/oauth_scope_oauth_fapi1_baseline.rb', line 27

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

  str = value.to_s.strip

  case str.downcase
  when 'fdxnotificationspublish' then FDXNOTIFICATIONSPUBLISH
  when 'fdxnotificationssubscribe' then FDXNOTIFICATIONSSUBSCRIBE
  when 'offline_access' then OFFLINE_ACCESS
  else
    default_value
  end
end

.validate(value) ⇒ Object



21
22
23
24
25
# File 'lib/fdx_v660_api/models/oauth_scope_oauth_fapi1_baseline.rb', line 21

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

  OAUTH_SCOPE_OAUTH_FAPI1_BASELINE.include?(value)
end