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.



52
53
54
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 52

def initialize(response_hash)
  @response_hash = response_hash
end

Class Method Details

.from_response(response) ⇒ Object



48
49
50
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 48

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

Instance Method Details

#account_idObject



60
61
62
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 60

def 
  auth.fetch("account_id")
end

#accounts_user_idObject



64
65
66
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 64

def accounts_user_id
  auth.fetch("accounts_user_id")
end

#allows_access_for?(required_scopes) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 72

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

#scopesObject



56
57
58
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 56

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

#user_idObject



68
69
70
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 68

def user_id
  auth.fetch("user_id")
end