Class: Stn::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/stn/configuration.rb

Overview

Provides an object to store global configuration settings.

This class is typically not used directly, but by calling Stn.configure, which creates and updates a single instance of Models::Configuration.

An alternative way to set global configuration settings is by storing them in the following environment variables:

  • STN_APP_KEY to store …

  • STN_TENANT_ID to store …

  • STN_CLIENT_ID to store …

  • STN_CLIENT_SECRET to store …

In case both methods are used together, Stn.configure takes precedence.

Examples:

Set the Security Token for the API client:

Stn.configure do |config|
  config.access_token = 'ABCDEFGHIJ1234567890'
end

Set the API credentials

ENV['STN_APP_KEY'] = '...'
ENV['STN_TENANT_ID'] = '...'
ENV['STN_CLIENT_ID'] = '...'
ENV['STN_CLIENT_SECRET'] = '...'

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Initialize the global configuration settings, using the values of the specified following environment variables by default.



54
55
56
57
58
59
60
# File 'lib/stn/configuration.rb', line 54

def initialize
  @app_key = ENV['STN_APP_KEY']
  @tenant_id = ENV['STN_TENANT_ID']
  @client_id = ENV['STN_CLIENT_ID']
  @client_secret = ENV['STN_CLIENT_SECRET']
  @mock = ENV['STN_MOCK'] == '1'
end

Instance Attribute Details

#access_tokenString

Returns the Security Token for the API calls.

Returns:

  • (String)

    the Security Token for the API calls.



35
36
37
# File 'lib/stn/configuration.rb', line 35

def access_token
  @access_token
end

#app_keyString

Returns …

Returns:

  • (String)



38
39
40
# File 'lib/stn/configuration.rb', line 38

def app_key
  @app_key
end

#client_idString

Returns …

Returns:

  • (String)



44
45
46
# File 'lib/stn/configuration.rb', line 44

def client_id
  @client_id
end

#client_secretString

Returns …

Returns:

  • (String)



47
48
49
# File 'lib/stn/configuration.rb', line 47

def client_secret
  @client_secret
end

#mockBoolean

Returns whether to mock the HTTP calls to ServiceTitan.

Returns:

  • (Boolean)

    whether to mock the HTTP calls to ServiceTitan



50
51
52
# File 'lib/stn/configuration.rb', line 50

def mock
  @mock
end

#tenant_idString

Returns …

Returns:

  • (String)



41
42
43
# File 'lib/stn/configuration.rb', line 41

def tenant_id
  @tenant_id
end