Class: BookingsyncApplication::Controllers::BookingsyncUniverseApiAccess::AuthorizationScope

Inherits:
Object
  • Object
show all
Defined in:
lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_hash) ⇒ AuthorizationScope

Returns a new instance of AuthorizationScope.



50
51
52
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 50

def initialize(response_hash)
  @response_hash = response_hash
end

Class Method Details

.from_response(response) ⇒ Object



46
47
48
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 46

def self.from_response(response)
  new(JSON.parse(response.body))
end

Instance Method Details

#account_idObject



58
59
60
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 58

def 
  auth.fetch("account_id")
end

#allows_access_for?(required_scopes) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 62

def allows_access_for?(required_scopes)
  required_scopes.any? { |scope| scopes.include?(scope) }
end

#scopesObject



54
55
56
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 54

def scopes
  auth.fetch("scopes").map(&:to_s)
end