Class: Dhis2::Configuration

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

Constant Summary collapse

ALLOWED_VERSIONS =
%w(2.24 2.25 2.26 2.27 2.28).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



7
8
9
# File 'lib/dhis2/configuration.rb', line 7

def debug
  @debug
end

#no_ssl_verificationObject

Returns the value of attribute no_ssl_verification.



7
8
9
# File 'lib/dhis2/configuration.rb', line 7

def no_ssl_verification
  @no_ssl_verification
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/dhis2/configuration.rb', line 7

def password
  @password
end

#timeoutObject

Returns the value of attribute timeout.



7
8
9
# File 'lib/dhis2/configuration.rb', line 7

def timeout
  @timeout
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/dhis2/configuration.rb', line 7

def url
  @url
end

#userObject

Returns the value of attribute user.



7
8
9
# File 'lib/dhis2/configuration.rb', line 7

def user
  @user
end

Instance Method Details

#client_paramsObject



9
10
11
12
13
14
15
16
17
# File 'lib/dhis2/configuration.rb', line 9

def client_params
  {
    url:        no_credentials? ? url : build_url,
    debug:      debug,
    version:    version,
    timeout:    timeout,
    verify_ssl: verify_ssl
  }
end

#play_params(with_debug, version) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/dhis2/configuration.rb', line 19

def play_params(with_debug, version)
  {
    url:     "https://admin:[email protected]/#{version}/",
    debug:   with_debug,
    version: version
  }
end

#version=(version) ⇒ Object



27
28
29
30
# File 'lib/dhis2/configuration.rb', line 27

def version=(version)
  raise Dhis2::InvalidVersionError, version.to_s unless ALLOWED_VERSIONS.include?(version)
  @version = version
end