Class: TqlOtrFactoringDataExchange::OauthScope

Inherits:
Object
  • Object
show all
Defined in:
lib/tql_otr_factoring_data_exchange/models/oauth_scope.rb

Overview

OAuth 2 scopes supported by the API

Constant Summary collapse

OAUTH_SCOPE =
[
  # Submit invoices, upload documents, manage assignments
  FACTORING_WRITE = 'Factoring.Write'.freeze,

  # Query invoice status, search invoices
  FACTORING_READ = 'Factoring.Read'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = FACTORING_WRITE) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tql_otr_factoring_data_exchange/models/oauth_scope.rb', line 23

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

  str = value.to_s.strip

  case str.downcase
  when 'factoring_write' then FACTORING_WRITE
  when 'factoring_read' then FACTORING_READ
  else
    default_value
  end
end

.validate(value) ⇒ Object



17
18
19
20
21
# File 'lib/tql_otr_factoring_data_exchange/models/oauth_scope.rb', line 17

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

  OAUTH_SCOPE.include?(value)
end