Class: Moloni::Configuration
- Inherits:
-
Object
- Object
- Moloni::Configuration
- Defined in:
- lib/moloni/configuration.rb
Constant Summary collapse
- REQUIRED_ATTRIBUTES =
%i[ developer_id redirect_uri client_secret refresh_token access_token ].freeze
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#access_token_expires_at ⇒ Object
Returns the value of attribute access_token_expires_at.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#company_id ⇒ Object
Returns the value of attribute company_id.
-
#debug ⇒ Object
writeonly
Sets the attribute debug.
-
#developer_id ⇒ Object
Returns the value of attribute developer_id.
-
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
#refresh_token_expires_at ⇒ Object
Returns the value of attribute refresh_token_expires_at.
Instance Method Summary collapse
- #access_token_expired?(margin_seconds: 300) ⇒ Boolean
- #debug? ⇒ Boolean
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #refresh_token_expired? ⇒ Boolean
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/moloni/configuration.rb', line 18 def initialize @developer_id = '' @redirect_uri = '' @client_secret = '' @refresh_token = '' @access_token = '' @company_id = 0 @debug = false @access_token_expires_at = nil @refresh_token_expires_at = nil end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
13 14 15 |
# File 'lib/moloni/configuration.rb', line 13 def access_token @access_token end |
#access_token_expires_at ⇒ Object
Returns the value of attribute access_token_expires_at.
13 14 15 |
# File 'lib/moloni/configuration.rb', line 13 def access_token_expires_at @access_token_expires_at end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
13 14 15 |
# File 'lib/moloni/configuration.rb', line 13 def client_secret @client_secret end |
#company_id ⇒ Object
Returns the value of attribute company_id.
13 14 15 |
# File 'lib/moloni/configuration.rb', line 13 def company_id @company_id end |
#debug=(value) ⇒ Object (writeonly)
Sets the attribute debug
16 17 18 |
# File 'lib/moloni/configuration.rb', line 16 def debug=(value) @debug = value end |
#developer_id ⇒ Object
Returns the value of attribute developer_id.
13 14 15 |
# File 'lib/moloni/configuration.rb', line 13 def developer_id @developer_id end |
#redirect_uri ⇒ Object
Returns the value of attribute redirect_uri.
13 14 15 |
# File 'lib/moloni/configuration.rb', line 13 def redirect_uri @redirect_uri end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
13 14 15 |
# File 'lib/moloni/configuration.rb', line 13 def refresh_token @refresh_token end |
#refresh_token_expires_at ⇒ Object
Returns the value of attribute refresh_token_expires_at.
13 14 15 |
# File 'lib/moloni/configuration.rb', line 13 def refresh_token_expires_at @refresh_token_expires_at end |
Instance Method Details
#access_token_expired?(margin_seconds: 300) ⇒ Boolean
34 35 36 37 38 |
# File 'lib/moloni/configuration.rb', line 34 def access_token_expired?(margin_seconds: 300) return true if @access_token_expires_at.nil? Time.now >= (@access_token_expires_at - margin_seconds) end |
#debug? ⇒ Boolean
30 31 32 |
# File 'lib/moloni/configuration.rb', line 30 def debug? @debug end |
#refresh_token_expired? ⇒ Boolean
40 41 42 43 44 |
# File 'lib/moloni/configuration.rb', line 40 def refresh_token_expired? return true if @refresh_token_expires_at.nil? Time.now >= @refresh_token_expires_at end |