Class: BookingsyncApplication::Controllers::BookingsyncUniverseApiAccess::AuthorizationScope
- Inherits:
-
Object
- Object
- BookingsyncApplication::Controllers::BookingsyncUniverseApiAccess::AuthorizationScope
- Defined in:
- lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb
Class Method Summary collapse
Instance Method Summary collapse
- #account_id ⇒ Object
- #accounts_user_id ⇒ Object
- #allows_access_for?(required_scopes) ⇒ Boolean
-
#initialize(response_hash) ⇒ AuthorizationScope
constructor
A new instance of AuthorizationScope.
- #scopes ⇒ Object
- #user_id ⇒ Object
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_id ⇒ Object
60 61 62 |
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 60 def account_id auth.fetch("account_id") end |
#accounts_user_id ⇒ Object
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
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 |
#scopes ⇒ Object
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_id ⇒ Object
68 69 70 |
# File 'lib/bookingsync_application/controllers/bookingsync_universe_api_access.rb', line 68 def user_id auth.fetch("user_id") end |