Class: Puree::API::Configuration

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

Overview

Configuration for Pure host and credentials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:) ⇒ Configuration

Returns a new instance of Configuration.



18
19
20
21
# File 'lib/puree/api/configuration.rb', line 18

def initialize(url:)
  raise 'Missing URL in configuration' if !url
  @url = url
end

Instance Attribute Details

#passwordString? (readonly)

Returns:

  • (String, nil)


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

def password
  @password
end

#urlString (readonly)

Returns:

  • (String)


10
11
12
# File 'lib/puree/api/configuration.rb', line 10

def url
  @url
end

#usernameString? (readonly)

Returns:

  • (String, nil)


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

def username
  @username
end

Instance Method Details

#basic_auth(username:, password:) ⇒ Object

Provide Basic Authentication credentials if required

Parameters:

  • username (String)
  • password (String)


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

def basic_auth(username:, password:)
  @username = username
  @password = password
  msg = 'Credentials incomplete in configuration'
  raise msg if username && !password
  raise msg if password && !username
end

#basic_auth?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/puree/api/configuration.rb', line 35

def basic_auth?
  @username && @password
end