Class: BookingSync::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- BookingSync::Engine
- Defined in:
- lib/bookingsync/engine.rb
Defined Under Namespace
Modules: AuthHelpers, Helpers, Model, SessionHelpers Classes: APIClient
Class Method Summary collapse
- .application_token ⇒ Object
-
.embedded! ⇒ Object
Set the engine into embedded mode.
-
.oauth_client ⇒ OAuth2::Client
OAuth client configured for the application.
-
.standalone! ⇒ Object
Set the engine into standalone mode.
Instance Method Summary collapse
- #embedded ⇒ Boolean
-
#sign_out_after ⇒ Fixnum
Duration of inactivity after which the authorization will be reset.
Class Method Details
.application_token ⇒ Object
80 81 82 |
# File 'lib/bookingsync/engine.rb', line 80 def self.application_token oauth_client.client_credentials.get_token end |
.embedded! ⇒ Object
Set the engine into embedded mode.
Embedded apps are loaded from within the BookingSync app store, and have a different method to redirect during the OAuth authorization process. This method will not work when the app is not embedded.
51 52 53 |
# File 'lib/bookingsync/engine.rb', line 51 def self. self. = true end |
.oauth_client ⇒ OAuth2::Client
OAuth client configured for the application.
The ENV variables used for configuration are described in README.
70 71 72 73 74 75 76 77 78 |
# File 'lib/bookingsync/engine.rb', line 70 def self.oauth_client = { site: ENV['BOOKINGSYNC_URL'] || 'https://www.bookingsync.com', connection_opts: { headers: { accept: "application/vnd.api+json" } } } [:ssl] = { verify: ENV['BOOKINGSYNC_VERIFY_SSL'] != 'false' } OAuth2::Client.new(ENV['BOOKINGSYNC_APP_ID'], ENV['BOOKINGSYNC_APP_SECRET'], ) end |
.standalone! ⇒ Object
Set the engine into standalone mode.
This setting is requried for the applications using this Engine to work outside of the BookingSync app store.
Restores the normal mode of redirecting during OAuth authorization.
61 62 63 |
# File 'lib/bookingsync/engine.rb', line 61 def self.standalone! self. = false end |
Instance Method Details
#embedded ⇒ Boolean
37 |
# File 'lib/bookingsync/engine.rb', line 37 cattr_accessor :embedded |
#sign_out_after ⇒ Fixnum
Duration of inactivity after which the authorization will be reset. See BookingSync::Engine::SessionHelpers#sign_out_if_inactive.
43 |
# File 'lib/bookingsync/engine.rb', line 43 cattr_accessor :sign_out_after |