Class: Vng::Configuration

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

Overview

Provides an object to store global configuration settings.

This class is typically not used directly, but by calling Vng.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:

  • VNG_HOST to store the host for the Vonigo API

  • VNG_USERNAME to store the username for the Vonigo API

  • VNG_PASSWORD to store the password for the Vonigo API

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

Examples:

Set the Security Token for the API client:

Vng.configure do |config|
  config.security_token = 'ABCDEFGHIJ1234567890'
end

Set the API credentials

ENV['VNG_HOST'] = 'subdomain.vonigo.com'
ENV['VNG_USERNAME'] = 'VonigoUser'
ENV['VNG_Password'] = 'VonigoPassword'

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.



48
49
50
51
52
53
# File 'lib/vng/configuration.rb', line 48

def initialize
  @host = ENV['VNG_HOST']
  @username = ENV['VNG_USERNAME']
  @password = ENV['VNG_PASSWORD']
  @mock = ENV['VNG_MOCK'] == '1'
end

Instance Attribute Details

#hostString

Returns the URI host for the API calls.

Returns:

  • (String)

    the URI host for the API calls.



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

def host
  @host
end

#mockBoolean

Returns whether to mock the HTTP calls to Vonigo.

Returns:

  • (Boolean)

    whether to mock the HTTP calls to Vonigo



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

def mock
  @mock
end

#passwordString

Returns the password for the API calls.

Returns:

  • (String)

    the password for the API calls.



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

def password
  @password
end

#security_tokenString

Returns the Security Token for the API calls.

Returns:

  • (String)

    the Security Token for the API calls.



32
33
34
# File 'lib/vng/configuration.rb', line 32

def security_token
  @security_token
end

#usernameString

Returns the username for the API calls.

Returns:

  • (String)

    the username for the API calls.



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

def username
  @username
end