Class: Umami::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/umami/configuration.rb

Constant Summary collapse

UMAMI_CLOUD_URL =
"https://api.umami.is".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
# File 'lib/umami/configuration.rb', line 7

def initialize
  @uri_base = nil
  @request_timeout = 120
  @access_token = nil
  @username = nil
  @password = nil
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



5
6
7
# File 'lib/umami/configuration.rb', line 5

def access_token
  @access_token
end

#passwordObject (readonly)

Returns the value of attribute password.



5
6
7
# File 'lib/umami/configuration.rb', line 5

def password
  @password
end

#request_timeoutObject (readonly)

Returns the value of attribute request_timeout.



5
6
7
# File 'lib/umami/configuration.rb', line 5

def request_timeout
  @request_timeout
end

#uri_baseObject

Returns the value of attribute uri_base.



5
6
7
# File 'lib/umami/configuration.rb', line 5

def uri_base
  @uri_base
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/umami/configuration.rb', line 5

def username
  @username
end

Instance Method Details

#cloud?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/umami/configuration.rb', line 36

def cloud?
  @access_token && @uri_base.nil?
end

#credentials=(creds) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/umami/configuration.rb', line 27

def credentials=(creds)
  raise Umami::ConfigurationError, "Both username and password are required" unless creds[:username] && creds[:password]

  @username = creds[:username]
  @password = creds[:password]
  @access_token = nil
  validate_configuration
end