Class: Twinfield::Configuration
- Inherits:
-
Object
- Object
- Twinfield::Configuration
- Defined in:
- lib/twinfield/configuration.rb
Overview
Used for configuration of the Twinfield gem.
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#cluster ⇒ Object
in case Twinfield::Api::OAuthSession is used.
-
#company ⇒ Object
Returns the value of attribute company.
-
#log_level ⇒ Object
Log level, e.g.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#organisation ⇒ Object
Returns the value of attribute organisation.
-
#password ⇒ Object
Returns the value of attribute password.
-
#session_type ⇒ Object
Twinfield::Api::OAuthSession or Twinfield::Api::Session.
-
#username ⇒ Object
in case Twinfield::Api::Session is used.
Instance Method Summary collapse
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
20 21 22 |
# File 'lib/twinfield/configuration.rb', line 20 def access_token @access_token end |
#cluster ⇒ Object
in case Twinfield::Api::OAuthSession is used
19 20 21 |
# File 'lib/twinfield/configuration.rb', line 19 def cluster @cluster end |
#company ⇒ Object
Returns the value of attribute company.
16 17 18 |
# File 'lib/twinfield/configuration.rb', line 16 def company @company end |
#log_level ⇒ Object
Log level, e.g. :info, :debug; currently only forwarded to Savon
23 24 25 |
# File 'lib/twinfield/configuration.rb', line 23 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
24 25 26 |
# File 'lib/twinfield/configuration.rb', line 24 def logger @logger end |
#organisation ⇒ Object
Returns the value of attribute organisation.
15 16 17 |
# File 'lib/twinfield/configuration.rb', line 15 def organisation @organisation end |
#password ⇒ Object
Returns the value of attribute password.
14 15 16 |
# File 'lib/twinfield/configuration.rb', line 14 def password @password end |
#session_type ⇒ Object
Twinfield::Api::OAuthSession or Twinfield::Api::Session
10 11 12 |
# File 'lib/twinfield/configuration.rb', line 10 def session_type @session_type end |
#username ⇒ Object
in case Twinfield::Api::Session is used
13 14 15 |
# File 'lib/twinfield/configuration.rb', line 13 def username @username end |
Instance Method Details
#access_token_expired? ⇒ Boolean
34 35 36 37 38 |
# File 'lib/twinfield/configuration.rb', line 34 def access_token_expired? Time.at(JSON.parse(Base64.decode64(access_token.split(".")[1]))["exp"]) < Time.now rescue => e raise Twinfield::Configuration::Error, "No valid access token provided (#{e.message})" end |
#session_class ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/twinfield/configuration.rb', line 40 def session_class case session_type when "Twinfield::Api::OAuthSession" Twinfield::Api::OAuthSession else Twinfield::Api::Session end end |
#to_logon_hash ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/twinfield/configuration.rb', line 26 def to_logon_hash { "user" => @username, "password" => @password, "organisation" => @organisation } end |