Module: DnsMadeEasy
- Defined in:
- lib/dnsmadeeasy.rb,
lib/dnsmadeeasy.rb,
lib/dnsmadeeasy/runner.rb,
lib/dnsmadeeasy/version.rb,
lib/dnsmadeeasy/api/client.rb,
lib/dnsmadeeasy/credentials.rb,
lib/dnsmadeeasy/credentials/api_keys.rb,
lib/dnsmadeeasy/credentials/yaml_file.rb
Defined Under Namespace
Modules: Api, Credentials
Classes: APIKeyAndSecretMissingError, AbstractMethodError, AuthenticationError, Error, InvalidCredentialKeys, InvalidCredentialsFormatError, NoDomainError, NoSuchAccountError, Runner
Constant Summary
collapse
- API_BASE_URL_PRODUCTION =
'https://api.dnsmadeeasy.com/V2.0'
- API_BASE_URL_SANDBOX =
'https://api.sandbox.dnsmadeeasy.com/V2.0'
- VERSION =
'0.4.0'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.default_api_key ⇒ Object
Returns the value of attribute default_api_key.
31
32
33
|
# File 'lib/dnsmadeeasy.rb', line 31
def default_api_key
@default_api_key
end
|
.default_api_secret ⇒ Object
Returns the value of attribute default_api_secret.
31
32
33
|
# File 'lib/dnsmadeeasy.rb', line 31
def default_api_secret
@default_api_secret
end
|
Class Method Details
.api_key=(value) ⇒ Object
66
67
68
|
# File 'lib/dnsmadeeasy.rb', line 66
def api_key=(value)
self.default_api_key = value
end
|
.api_secret=(value) ⇒ Object
70
71
72
|
# File 'lib/dnsmadeeasy.rb', line 70
def api_secret=(value)
self.default_api_secret = value
end
|
.client(**options) ⇒ Object
74
75
76
|
# File 'lib/dnsmadeeasy.rb', line 74
def client(**options)
@client ||= create_client(false, **options)
end
|
34
35
36
|
# File 'lib/dnsmadeeasy.rb', line 34
def configure
yield(self) if block_given?
end
|
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/dnsmadeeasy.rb', line 38
def configure_from_file(file = nil,
account = nil,
encryption_key = nil)
credentials = ::DnsMadeEasy::Credentials.keys_from_file(
file: file || ::DnsMadeEasy::Credentials.default_credentials_path(user: ENV['USER']),
account: account,
encryption_key: encryption_key
)
if credentials
configure do |config|
config.api_key = credentials.api_key
config.api_secret = credentials.api_secret
end
else
raise APIKeyAndSecretMissingError, "Unable to load valid api keys from #{file}!"
end
end
|
.create_client(sandbox = false, api_key: default_api_key, api_secret: default_api_secret, **options) ⇒ Object
82
83
84
85
86
87
88
89
90
|
# File 'lib/dnsmadeeasy.rb', line 82
def create_client(sandbox = false,
api_key: default_api_key,
api_secret: default_api_secret,
**options)
raise APIKeyAndSecretMissingError, 'Please set #api_key and #api_secret' unless api_key && api_secret
::DnsMadeEasy::Api::Client.new(api_key, api_secret, sandbox, **options)
end
|
.credentials_from_file(file: DnsMadeEasy::Credentials.default_credentials_path, account: nil, encryption_key: nil) ⇒ Object
.method_missing(method, *args, &block) ⇒ Object
Basically delegate it all to the Client instance if the method call is supported.
95
96
97
98
99
100
101
|
# File 'lib/dnsmadeeasy.rb', line 95
def method_missing(method, *args, &block)
if client.respond_to?(method)
client.send(method, *args, &block)
else
super(method, *args, &block)
end
end
|
.sandbox_client(**options) ⇒ Object
78
79
80
|
# File 'lib/dnsmadeeasy.rb', line 78
def sandbox_client(**options)
@sandbox_client ||= create_client(true, **options)
end
|