Class: WhoisXMLAPI2::Configuration

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

Constant Summary collapse

DEFAULT_SERVICE_ENDPOINT =
"https://whoisxmlapi.com/whoisserver/WhoisService?".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Configuration

Returns a new instance of Configuration.



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

def initialize(params = {})
  apply_configuration(params)
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/whoisxmlapi2/configuration.rb', line 3

def api_key
  @api_key
end

#browser_keyObject

Returns the value of attribute browser_key.



3
4
5
# File 'lib/whoisxmlapi2/configuration.rb', line 3

def browser_key
  @browser_key
end

#mock_out_for_testingObject

Returns the value of attribute mock_out_for_testing.



3
4
5
# File 'lib/whoisxmlapi2/configuration.rb', line 3

def mock_out_for_testing
  @mock_out_for_testing
end

#secretObject

Returns the value of attribute secret.



3
4
5
# File 'lib/whoisxmlapi2/configuration.rb', line 3

def secret
  @secret
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/whoisxmlapi2/configuration.rb', line 3

def url
  @url
end

#usernameObject

Returns the value of attribute username.



3
4
5
# File 'lib/whoisxmlapi2/configuration.rb', line 3

def username
  @username
end

Class Method Details

.set?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/whoisxmlapi2/configuration.rb', line 13

def set?
  WhoisXMLAPI2.configuration.url && \
  WhoisXMLAPI2.configuration.api_key || \
  WhoisXMLAPI2.configuration.mock_out_for_testing
end

.set_v1?Boolean

Returns:

  • (Boolean)


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

def set_v1?
  WhoisXMLAPI2.configuration.url && \
  WhoisXMLAPI2.configuration.username && \
  WhoisXMLAPI2.configuration.api_key && \
  WhoisXMLAPI2.configuration.secret || \
  WhoisXMLAPI2.configuration.mock_out_for_testing
end

Instance Method Details

#apply_configuration(params) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/whoisxmlapi2/configuration.rb', line 28

def apply_configuration(params)
  params[:url] ||= DEFAULT_SERVICE_ENDPOINT

  @username = params[:username]
  @api_key = params[:api_key]
  @secret = params[:secret]
  @url = params[:url]
  @browser_key = params[:browser_key]
  @mock_out_for_testing = params[:mock_out_for_testing]
end