class Breinify::BreinConfig
Description¶ ↑
Provides the configuration of the library for the properties supplied.
Possible parameters are:
apiKey: The API-key to be used (mandatory). url: The url of the API activityEndpoint: The end-point of the API to send activities. lookupEndpoint: The end-point of the API to retrieve lookup results. secret: The secret attached to the API-key timeout: The maximum amount of time in milliseconds an API-call should take. If the API does not response after this amount of time, the call is cancelled.
If no parameters are set the default parameters will be used.
Constants
- DEF_ACTIVITY_ENDPOINT
default endpoint of activity
- DEF_CATEGORY
default category
- DEF_LOOKUP_ENDPOINT
default endpoint of lookup
- DEF_SECRET
default secret value
- DEF_TIMEOUT
default timeout (open in seconds)
- DEF_URL
default breinify url
Attributes
activity_endpoint[RW]
instance members
api_key[RW]
instance members
category[RW]
instance members
lookup_endpoint[RW]
instance members
secret[RW]
instance members
timeout[RW]
instance members
url[RW]
instance members
Public Class Methods
instance()
click to toggle source
Description¶ ↑
Returns the instance of BreinConfig
(Singleton Pattern)
# File lib/Breinify.rb, line 83 def self.instance return @@instance end
Private Class Methods
Public Instance Methods
set_config(options = {})
click to toggle source
Description¶ ↑
Sets the configuration for the API
# File lib/Breinify.rb, line 91 def set_config(options = {}) if options == nil $log.debug 'BreinifyConfig: values are nil' return end begin @api_key = options.fetch('apiKey', '') $log.debug ('apiKey: ' + @api_key) @url = options.fetch('url', DEF_URL) $log.debug ('url: ' + @url) @activity_endpoint = options.fetch('activityEndpoint', DEF_ACTIVITY_ENDPOINT) $log.debug ('ActivityEndpoint: ' + @activity_endpoint) @lookup_endpoint = options.fetch('lookupEndpoint', DEF_LOOKUP_ENDPOINT) $log.debug ('LookupEndpoint: ' + @lookup_endpoint) @secret = options.fetch('secret', DEF_SECRET) $log.debug ('Secret: ' + @secret) @timeout = options.fetch('timeout', DEF_TIMEOUT) $log.debug ('Timeout: ' + @timeout.to_s) @category = options.fetch('category', DEF_CATEGORY) $log.debug ('Category: ' + @category) rescue Exception => e $log.debug 'Exception caught: ' + e.message $log.debug ' Backtrace is: ' + e.backtrace.inspect return end end