Module: PaylocityWebService::Configuration

Included in:
PaylocityWebService, Client
Defined in:
lib/paylocity_web_service/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
  :client_id,
  :client_secret,
  :endpoint,
  :public_key,
  :company_id,
  :proxy,
  :ssl_verify_mode,
  :format,
  :connection_options,
  :user_agent
]
DEFAULT_ACCESS_TOKEN =

By default, don’t set a user access token

nil
DEFAULT_ADAPTER =
Note:

The default faraday adapter is Net::HTTP.

The adapter that will be used to connect if none is set

Faraday.default_adapter
DEFAULT_CLIENT_ID =

By default, don’t set an application ID

nil
DEFAULT_CLIENT_SECRET =

By default, don’t set an application secret

nil
DEFAULT_CONNECTION_OPTIONS =

By default, don’t set any connection options

{}
DEFAULT_ENDPOINT =
Note:

There is no reason to use any other endpoint at this time

The endpoint that will be used to connect if none is set

'https://apisandbox.paylocity.com'.freeze
DEFAULT_FORMAT =
Note:

JSON is the only available format at this time

The response format appended to the path and sent in the ‘Accept’ header if none is set

:json
DEFAULT_PROXY =

By default, don’t use a proxy server

nil
DEFAULT_SSL_VERIFY_MODE =

By default, the ssl_verify_mode is true

true
DEFAULT_USER_AGENT =

The user agent that will be sent to the API endpoint if none is set

"paylocity-ruby-gem #{PaylocityWebService::VERSION}".freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Sets all configuration options to their default values when this module is extended.

[View source]

56
57
58
# File 'lib/paylocity_web_service/configuration.rb', line 56

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Set configuration options using a block

Yields:

  • (_self)

Yield Parameters:

[View source]

61
62
63
# File 'lib/paylocity_web_service/configuration.rb', line 61

def configure
  yield self
end

#optionsObject

Creates a hash of options and their values.

[View source]

66
67
68
69
70
# File 'lib/paylocity_web_service/configuration.rb', line 66

def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#resetObject

Reset configuration options to default values

[View source]

73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/paylocity_web_service/configuration.rb', line 73

def reset
  self.client_id          = DEFAULT_CLIENT_ID
  self.client_secret      = DEFAULT_CLIENT_SECRET
  self.connection_options = DEFAULT_CONNECTION_OPTIONS
  self.endpoint           = DEFAULT_ENDPOINT
  self.format             = DEFAULT_FORMAT
  self.proxy              = DEFAULT_PROXY
  self.user_agent         = DEFAULT_USER_AGENT
  self.ssl_verify_mode    = DEFAULT_SSL_VERIFY_MODE

  self
end