class BookingSync::Engine
Public Class Methods
application_token(client_id: ENV["BOOKINGSYNC_APP_ID"], client_secret: ENV["BOOKINGSYNC_APP_SECRET"])
click to toggle source
# File lib/bookingsync/engine.rb, line 92 def self.application_token(client_id: ENV["BOOKINGSYNC_APP_ID"], client_secret: ENV["BOOKINGSYNC_APP_SECRET"]) token_refresh_timeout_attempts_allowed = ::BookingSyncEngine.token_refresh_timeout_retry_count + 1 BookingSync::Engine::Retryable.perform(times: token_refresh_timeout_attempts_allowed, errors: [Faraday::TimeoutError]) do oauth_client(client_id: client_id, client_secret: client_secret).client_credentials.get_token end end
embedded!()
click to toggle source
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.
# File lib/bookingsync/engine.rb, line 60 def self.embedded! self.embedded = true end
oauth_client(client_id: ENV["BOOKINGSYNC_APP_ID"], client_secret: ENV["BOOKINGSYNC_APP_SECRET"])
click to toggle source
OAuth client configured for the application.
The ENV variables used for configuration are described in {file:README.md}.
@return [OAuth2::Client] configured OAuth client
# File lib/bookingsync/engine.rb, line 79 def self.oauth_client(client_id: ENV["BOOKINGSYNC_APP_ID"], client_secret: ENV["BOOKINGSYNC_APP_SECRET"]) connection_options = { headers: { accept: "application/vnd.api+json" } }.merge(::BookingSyncEngine.oauth_client_connection_options) client_options = { site: ENV["BOOKINGSYNC_URL"] || 'https://www.bookingsync.com', connection_opts: connection_options } client_options[:ssl] = { verify: ENV['BOOKINGSYNC_VERIFY_SSL'] != 'false' } OAuth2::Client.new(client_id, client_secret, client_options) end
standalone!()
click to toggle source
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.
# File lib/bookingsync/engine.rb, line 70 def self.standalone! self.embedded = false end