Class: Lmb::Developers::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Initial config.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lmb/developers/configuration.rb', line 11

def initialize
    @config = {
        'DEV' => {
            'url': 'https://api-dev.leroymerlin.com.br'
        },
        'TEST' => {
            'url': 'https://api-test.leroymerlin.com.br'
        },
        'PROD' => {
            'url': 'https://api.leroymerlin.com.br'
        }
    }
    configure('DEV', nil)
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



4
5
6
# File 'lib/lmb/developers/configuration.rb', line 4

def api_key
  @api_key
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/lmb/developers/configuration.rb', line 4

def password
  @password
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/lmb/developers/configuration.rb', line 8

def url
  @url
end

#usernameObject

Returns the value of attribute username.



4
5
6
# File 'lib/lmb/developers/configuration.rb', line 4

def username
  @username
end

Instance Method Details

#configure(environment = 'DEV', api_key = 'api_key', username = 'username', password = 'password') ⇒ Lmb::Developers::Configuration

Configure global parameters

Parameters:

  • environment (String) (defaults to: 'DEV')

    environment to consume APIs, ‘DEV`, `TEST` or `PROD`

  • api_key (String) (defaults to: 'api_key')

    ApiKey to consume APIs.

  • username (String) (defaults to: 'username')

    Username to consume APIs.

  • password (String) (defaults to: 'password')

    Password to consume APIs.

Returns:



32
33
34
35
36
37
38
39
# File 'lib/lmb/developers/configuration.rb', line 32

def configure(environment = 'DEV', api_key = 'api_key', username = 'username', password = 'password')
    @api_key = api_key
    @username = username
    @password = password
    @environment = environment
    @url = @config[environment][:url]
    self
end