Class: Moloni::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_tokenObject

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_atObject

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_secretObject

Returns the value of attribute client_secret.



13
14
15
# File 'lib/moloni/configuration.rb', line 13

def client_secret
  @client_secret
end

#company_idObject

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

Parameters:

  • value

    the value to set the attribute debug to.



16
17
18
# File 'lib/moloni/configuration.rb', line 16

def debug=(value)
  @debug = value
end

#developer_idObject

Returns the value of attribute developer_id.



13
14
15
# File 'lib/moloni/configuration.rb', line 13

def developer_id
  @developer_id
end

#redirect_uriObject

Returns the value of attribute redirect_uri.



13
14
15
# File 'lib/moloni/configuration.rb', line 13

def redirect_uri
  @redirect_uri
end

#refresh_tokenObject

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_atObject

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

Returns:

  • (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

Returns:

  • (Boolean)


30
31
32
# File 'lib/moloni/configuration.rb', line 30

def debug?
  @debug
end

#refresh_token_expired?Boolean

Returns:

  • (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