Class: BookingSync::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/bookingsync/engine.rb

Defined Under Namespace

Modules: AuthHelpers, Helpers, Model, SessionHelpers, TokenHelpers

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.application_tokenObject



82
83
84
# File 'lib/bookingsync/engine.rb', line 82

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.



53
54
55
# File 'lib/bookingsync/engine.rb', line 53

def self.embedded!
  self.embedded = true
end

.oauth_clientOAuth2::Client

OAuth client configured for the application.

The ENV variables used for configuration are described in README.

Returns:

  • (OAuth2::Client)

    configured OAuth client



72
73
74
75
76
77
78
79
80
# File 'lib/bookingsync/engine.rb', line 72

def self.oauth_client
  client_options = {
    site: ENV['BOOKINGSYNC_URL'] || 'https://www.bookingsync.com',
    connection_opts: { headers: { accept: "application/vnd.api+json" } }
  }
  client_options[:ssl] = { verify: ENV['BOOKINGSYNC_VERIFY_SSL'] != 'false' }
  OAuth2::Client.new(ENV['BOOKINGSYNC_APP_ID'], ENV['BOOKINGSYNC_APP_SECRET'],
    client_options)
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.



63
64
65
# File 'lib/bookingsync/engine.rb', line 63

def self.standalone!
  self.embedded = false
end

Instance Method Details

#embeddedBoolean

Returns:

  • (Boolean)


39
# File 'lib/bookingsync/engine.rb', line 39

cattr_accessor :embedded

#sign_out_afterFixnum

Duration of inactivity after which the authorization will be reset. See BookingSync::Engine::SessionHelpers#sign_out_if_inactive.

Returns:

  • (Fixnum)


45
# File 'lib/bookingsync/engine.rb', line 45

cattr_accessor :sign_out_after