dnsimple-ruby 1.7.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +3 -9
- data/{CHANGELOG.markdown → CHANGELOG.md} +4 -0
- data/Gemfile +0 -2
- data/LICENSE +1 -1
- data/README.md +5 -0
- data/Rakefile +0 -15
- data/dnsimple-ruby.gemspec +11 -19
- data/lib/dnsimple-ruby.rb +2 -0
- metadata +20 -288
- data/README.markdown +0 -159
- data/bin/dnsimple +0 -4
- data/bin/dnsimple.rb +0 -156
- data/features/README.md +0 -9
- data/features/cli/certificates/purchase_certificate.feature +0 -10
- data/features/cli/contacts/create_contact.feature +0 -10
- data/features/cli/domains/check_domain.feature +0 -10
- data/features/cli/domains/create_domain.feature +0 -10
- data/features/cli/domains/delete_domain.feature +0 -11
- data/features/cli/domains/register_domain.feature +0 -10
- data/features/cli/records/create_ptr_record.feature +0 -11
- data/features/cli/records/create_record.feature +0 -12
- data/features/cli/records/delete_record.feature +0 -14
- data/features/cli/templates/apply_template.feature +0 -11
- data/features/step_definitions/certificate_steps.rb +0 -3
- data/features/step_definitions/cli_steps.rb +0 -8
- data/features/step_definitions/domain_steps.rb +0 -32
- data/features/step_definitions/record_steps.rb +0 -38
- data/features/step_definitions/template_steps.rb +0 -9
- data/features/support/env.rb +0 -19
- data/lib/dnsimple.rb +0 -33
- data/lib/dnsimple/base.rb +0 -10
- data/lib/dnsimple/certificate.rb +0 -140
- data/lib/dnsimple/cli.rb +0 -121
- data/lib/dnsimple/client.rb +0 -128
- data/lib/dnsimple/commands/certificate_describe.rb +0 -34
- data/lib/dnsimple/commands/certificate_list.rb +0 -15
- data/lib/dnsimple/commands/certificate_purchase.rb +0 -17
- data/lib/dnsimple/commands/certificate_submit.rb +0 -17
- data/lib/dnsimple/commands/contact_create.rb +0 -23
- data/lib/dnsimple/commands/contact_delete.rb +0 -14
- data/lib/dnsimple/commands/contact_describe.rb +0 -25
- data/lib/dnsimple/commands/contact_list.rb +0 -13
- data/lib/dnsimple/commands/contact_update.rb +0 -25
- data/lib/dnsimple/commands/domain_apply_template.rb +0 -15
- data/lib/dnsimple/commands/domain_check.rb +0 -11
- data/lib/dnsimple/commands/domain_clear.rb +0 -16
- data/lib/dnsimple/commands/domain_create.rb +0 -16
- data/lib/dnsimple/commands/domain_delete.rb +0 -14
- data/lib/dnsimple/commands/domain_describe.rb +0 -14
- data/lib/dnsimple/commands/domain_list.rb +0 -13
- data/lib/dnsimple/commands/domain_register.rb +0 -33
- data/lib/dnsimple/commands/domain_transfer.rb +0 -21
- data/lib/dnsimple/commands/extended_attribute_list.rb +0 -25
- data/lib/dnsimple/commands/me.rb +0 -18
- data/lib/dnsimple/commands/record_create.rb +0 -18
- data/lib/dnsimple/commands/record_delete.rb +0 -16
- data/lib/dnsimple/commands/record_describe.rb +0 -16
- data/lib/dnsimple/commands/record_list.rb +0 -19
- data/lib/dnsimple/commands/record_update.rb +0 -23
- data/lib/dnsimple/commands/service_add.rb +0 -14
- data/lib/dnsimple/commands/service_describe.rb +0 -12
- data/lib/dnsimple/commands/service_list.rb +0 -14
- data/lib/dnsimple/commands/service_list_applied.rb +0 -16
- data/lib/dnsimple/commands/service_list_available.rb +0 -16
- data/lib/dnsimple/commands/service_remove.rb +0 -14
- data/lib/dnsimple/commands/template_create.rb +0 -14
- data/lib/dnsimple/commands/template_delete.rb +0 -13
- data/lib/dnsimple/commands/template_list.rb +0 -13
- data/lib/dnsimple/commands/template_record_create.rb +0 -18
- data/lib/dnsimple/commands/template_record_delete.rb +0 -16
- data/lib/dnsimple/commands/template_record_list.rb +0 -17
- data/lib/dnsimple/contact.rb +0 -154
- data/lib/dnsimple/domain.rb +0 -217
- data/lib/dnsimple/error.rb +0 -32
- data/lib/dnsimple/extended_attribute.rb +0 -52
- data/lib/dnsimple/record.rb +0 -94
- data/lib/dnsimple/service.rb +0 -42
- data/lib/dnsimple/template.rb +0 -63
- data/lib/dnsimple/template_record.rb +0 -80
- data/lib/dnsimple/transfer_order.rb +0 -34
- data/lib/dnsimple/user.rb +0 -51
- data/lib/dnsimple/version.rb +0 -3
- data/spec/ci/.dnsimple.test +0 -3
- data/spec/commands/certificate_purchase_spec.rb +0 -25
- data/spec/commands/certificate_submit_spec.rb +0 -18
- data/spec/commands/record_create_spec.rb +0 -23
- data/spec/commands/record_list_spec.rb +0 -23
- data/spec/commands/service_add_spec.rb +0 -20
- data/spec/dnsimple/certificate_spec.rb +0 -59
- data/spec/dnsimple/client_spec.rb +0 -154
- data/spec/dnsimple/contact_spec.rb +0 -45
- data/spec/dnsimple/domain_spec.rb +0 -133
- data/spec/dnsimple/extended_attributes_spec.rb +0 -54
- data/spec/dnsimple/record_spec.rb +0 -51
- data/spec/dnsimple/template_spec.rb +0 -31
- data/spec/dnsimple/user_spec.rb +0 -70
- data/spec/files/2fa/error-badtoken.http +0 -22
- data/spec/files/2fa/error-required.http +0 -23
- data/spec/files/2fa/exchange-token.http +0 -25
- data/spec/files/account/user/success.http +0 -19
- data/spec/files/certificates/index/success.http +0 -19
- data/spec/files/certificates/show/notfound.http +0 -17
- data/spec/files/certificates/show/success.http +0 -19
- data/spec/files/contacts/show/notfound.http +0 -17
- data/spec/files/contacts/show/success.http +0 -19
- data/spec/files/domains/auto_renewal_disable/notfound.http +0 -21
- data/spec/files/domains/auto_renewal_disable/success.http +0 -23
- data/spec/files/domains/auto_renewal_enable/notfound.http +0 -21
- data/spec/files/domains/auto_renewal_enable/success.http +0 -23
- data/spec/files/domains/show/notfound.http +0 -17
- data/spec/files/domains/show/success.http +0 -19
- data/spec/files/extended_attributes/ca.http +0 -19
- data/spec/files/extended_attributes/com.http +0 -19
- data/spec/files/extended_attributes/success.http +0 -19
- data/spec/files/records/index/success.http +0 -19
- data/spec/files/records/show/notfound.http +0 -17
- data/spec/files/records/show/success.http +0 -19
- data/spec/files/templates/show/notfound.http +0 -17
- data/spec/files/templates/show/success.http +0 -19
- data/spec/spec_helper.rb +0 -39
- data/spec/support/helpers.rb +0 -15
- data/spec/support/webmock.rb +0 -11
data/lib/dnsimple/error.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module DNSimple
|
2
|
-
|
3
|
-
class Error < StandardError
|
4
|
-
end
|
5
|
-
|
6
|
-
class RecordExists < Error
|
7
|
-
end
|
8
|
-
|
9
|
-
class RecordNotFound < Error
|
10
|
-
end
|
11
|
-
|
12
|
-
# An exception that is raised if a method is called with missing or invalid parameter values.
|
13
|
-
class ValidationError < Error
|
14
|
-
end
|
15
|
-
|
16
|
-
class RequestError < Error
|
17
|
-
def initialize(description, response)
|
18
|
-
super("#{description}: #{response["error"]}")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class AuthenticationError < Error
|
23
|
-
end
|
24
|
-
|
25
|
-
class AuthenticationFailed < AuthenticationError
|
26
|
-
end
|
27
|
-
|
28
|
-
# An exception that is raised if a request is executed for an account that requires two-factor authentication.
|
29
|
-
class TwoFactorAuthenticationRequired < AuthenticationError
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module DNSimple
|
2
|
-
|
3
|
-
# Used for domains that require extended attributes.
|
4
|
-
class ExtendedAttribute < Base
|
5
|
-
|
6
|
-
# An option for an extended attribute
|
7
|
-
class Option < Base
|
8
|
-
# The option name
|
9
|
-
attr_accessor :title
|
10
|
-
|
11
|
-
# The option value
|
12
|
-
attr_accessor :value
|
13
|
-
|
14
|
-
# A long description of the option
|
15
|
-
attr_accessor :description
|
16
|
-
end
|
17
|
-
|
18
|
-
# The extended attribute name
|
19
|
-
attr_accessor :name
|
20
|
-
|
21
|
-
# A description of the extended attribute
|
22
|
-
attr_accessor :description
|
23
|
-
|
24
|
-
# Boolean indicating if the extended attribute is required
|
25
|
-
attr_accessor :required
|
26
|
-
|
27
|
-
# An array of options for the extended attribute
|
28
|
-
def options
|
29
|
-
@options ||= []
|
30
|
-
end
|
31
|
-
|
32
|
-
def options=(opts)
|
33
|
-
@options = []
|
34
|
-
opts.each do |opt|
|
35
|
-
@options << DNSimple::ExtendedAttribute::Option.new(opt)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Find the extended attributes for the given TLD
|
40
|
-
def self.find(tld, options={})
|
41
|
-
response = DNSimple::Client.get("/v1/extended_attributes/#{tld}", options)
|
42
|
-
|
43
|
-
case response.code
|
44
|
-
when 200
|
45
|
-
response.map { |r| new(r) }
|
46
|
-
else
|
47
|
-
raise RequestError.new("Error finding extended attributes", response)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
data/lib/dnsimple/record.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
module DNSimple
|
2
|
-
|
3
|
-
class Record < Base
|
4
|
-
Aliases = {
|
5
|
-
'priority' => 'prio',
|
6
|
-
'time-to-live' => 'ttl'
|
7
|
-
}
|
8
|
-
|
9
|
-
attr_accessor :id
|
10
|
-
attr_accessor :domain
|
11
|
-
attr_accessor :name
|
12
|
-
attr_accessor :content
|
13
|
-
attr_accessor :ttl
|
14
|
-
attr_accessor :prio
|
15
|
-
attr_accessor :record_type
|
16
|
-
|
17
|
-
|
18
|
-
def fqdn
|
19
|
-
[name, domain.name].delete_if { |v| v !~ DNSimple::BLANK_REGEX }.join(".")
|
20
|
-
end
|
21
|
-
|
22
|
-
def save(options={})
|
23
|
-
record_hash = {}
|
24
|
-
%w(name content ttl prio).each do |attribute|
|
25
|
-
record_hash[DNSimple::Record.resolve(attribute)] = self.send(attribute)
|
26
|
-
end
|
27
|
-
|
28
|
-
options.merge!(:body => {:record => record_hash})
|
29
|
-
|
30
|
-
response = DNSimple::Client.put("/v1/domains/#{domain.id}/records/#{id}", options)
|
31
|
-
|
32
|
-
case response.code
|
33
|
-
when 200
|
34
|
-
self
|
35
|
-
else
|
36
|
-
raise RequestError.new("Error updating record", response)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def delete(options={})
|
41
|
-
DNSimple::Client.delete("/v1/domains/#{domain.id}/records/#{id}", options)
|
42
|
-
end
|
43
|
-
alias :destroy :delete
|
44
|
-
|
45
|
-
def self.resolve(name)
|
46
|
-
DNSimple::Record::Aliases[name] || name
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.create(domain, name, record_type, content, options={})
|
50
|
-
record_hash = {:name => name, :record_type => record_type, :content => content}
|
51
|
-
record_hash[:ttl] = options.delete(:ttl) || 3600
|
52
|
-
record_hash[:prio] = options.delete(:priority)
|
53
|
-
record_hash[:prio] = options.delete(:prio) || ''
|
54
|
-
|
55
|
-
options.merge!({:body => {:record => record_hash}})
|
56
|
-
|
57
|
-
response = DNSimple::Client.post("/v1/domains/#{domain.name}/records", options)
|
58
|
-
|
59
|
-
case response.code
|
60
|
-
when 201
|
61
|
-
new({:domain => domain}.merge(response["record"]))
|
62
|
-
when 406
|
63
|
-
raise RecordExists, "Record #{name}.#{domain.name} already exists"
|
64
|
-
else
|
65
|
-
raise RequestError.new("Error creating record", response)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def self.find(domain, id, options={})
|
70
|
-
response = DNSimple::Client.get("/v1/domains/#{domain.name}/records/#{id}", options)
|
71
|
-
|
72
|
-
case response.code
|
73
|
-
when 200
|
74
|
-
new({:domain => domain}.merge(response["record"]))
|
75
|
-
when 404
|
76
|
-
raise RecordNotFound, "Could not find record #{id} for domain #{domain.name}"
|
77
|
-
else
|
78
|
-
raise RequestError.new("Error finding record", response)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def self.all(domain, options={})
|
83
|
-
response = DNSimple::Client.get("/v1/domains/#{domain.name}/records", options)
|
84
|
-
|
85
|
-
case response.code
|
86
|
-
when 200
|
87
|
-
response.map { |r| new({:domain => domain}.merge(r["record"])) }
|
88
|
-
else
|
89
|
-
raise RequestError.new("Error listing records", response)
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
data/lib/dnsimple/service.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
module DNSimple
|
2
|
-
|
3
|
-
# Represents a service that can be applied to a domain.
|
4
|
-
class Service < Base
|
5
|
-
|
6
|
-
attr_accessor :id
|
7
|
-
|
8
|
-
attr_accessor :name
|
9
|
-
|
10
|
-
attr_accessor :short_name
|
11
|
-
|
12
|
-
attr_accessor :description
|
13
|
-
|
14
|
-
# Find a service by its ID or short name
|
15
|
-
def self.find(id_or_short_name, options={})
|
16
|
-
id = id_or_short_name
|
17
|
-
response = DNSimple::Client.get("/v1/services/#{id}", options)
|
18
|
-
|
19
|
-
case response.code
|
20
|
-
when 200
|
21
|
-
new(response["service"])
|
22
|
-
when 404
|
23
|
-
raise RecordNotFound, "Could not find service #{id}"
|
24
|
-
else
|
25
|
-
raise RequestError.new("Error finding service", response)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Get all of the services that can be applied to a domain
|
30
|
-
def self.all(options={})
|
31
|
-
response = DNSimple::Client.get("/v1/services", options)
|
32
|
-
|
33
|
-
case response.code
|
34
|
-
when 200
|
35
|
-
response.map { |r| new(r["service"]) }
|
36
|
-
else
|
37
|
-
raise RequestError.new("Error listing services", response)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
end
|
data/lib/dnsimple/template.rb
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
module DNSimple
|
2
|
-
class Template < Base
|
3
|
-
|
4
|
-
attr_accessor :id
|
5
|
-
attr_accessor :name
|
6
|
-
attr_accessor :short_name
|
7
|
-
attr_accessor :description
|
8
|
-
|
9
|
-
|
10
|
-
def self.create(name, short_name, description=nil, options={})
|
11
|
-
template_hash = {
|
12
|
-
:name => name,
|
13
|
-
:short_name => short_name,
|
14
|
-
:description => description
|
15
|
-
}
|
16
|
-
|
17
|
-
options.merge!(:body => {:dns_template => template_hash})
|
18
|
-
|
19
|
-
response = DNSimple::Client.post("/v1/templates", options)
|
20
|
-
|
21
|
-
case response.code
|
22
|
-
when 201
|
23
|
-
new(response["dns_template"])
|
24
|
-
else
|
25
|
-
raise RequestError.new("Error creating template", response)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.find(id_or_short_name, options={})
|
30
|
-
id = id_or_short_name
|
31
|
-
response = DNSimple::Client.get("/v1/templates/#{id}", options)
|
32
|
-
|
33
|
-
case response.code
|
34
|
-
when 200
|
35
|
-
new(response["dns_template"])
|
36
|
-
when 404
|
37
|
-
raise RecordNotFound, "Could not find template #{id}"
|
38
|
-
else
|
39
|
-
raise RequestError.new("Error finding template", response)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def self.all(options={})
|
44
|
-
response = DNSimple::Client.get("/v1/templates", options)
|
45
|
-
|
46
|
-
case response.code
|
47
|
-
when 200
|
48
|
-
response.map { |r| new(r["dns_template"]) }
|
49
|
-
else
|
50
|
-
raise RequestError.new("Error listing templates", response)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
# Delete the template from DNSimple.
|
56
|
-
# WARNING: this cannot be undone.
|
57
|
-
def delete(options={})
|
58
|
-
DNSimple::Client.delete("/v1/templates/#{id}", options)
|
59
|
-
end
|
60
|
-
alias :destroy :delete
|
61
|
-
|
62
|
-
end
|
63
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
module DNSimple
|
2
|
-
|
3
|
-
# A single record in a template.
|
4
|
-
class TemplateRecord < Base
|
5
|
-
|
6
|
-
# The id of the template record
|
7
|
-
attr_accessor :id
|
8
|
-
|
9
|
-
# The template the record belongs to
|
10
|
-
attr_accessor :template
|
11
|
-
|
12
|
-
# The name the record points to. This may be blank.
|
13
|
-
attr_accessor :name
|
14
|
-
|
15
|
-
# The content for the record.
|
16
|
-
attr_accessor :content
|
17
|
-
|
18
|
-
# The record type
|
19
|
-
attr_accessor :record_type
|
20
|
-
|
21
|
-
# The time-to-live
|
22
|
-
attr_accessor :ttl
|
23
|
-
|
24
|
-
# The priority (only for MX records)
|
25
|
-
attr_accessor :prio
|
26
|
-
|
27
|
-
def delete(options={})
|
28
|
-
DNSimple::Client.delete("/v1/templates/#{template.id}/template_records/#{id}", options)
|
29
|
-
end
|
30
|
-
alias :destroy :delete
|
31
|
-
|
32
|
-
def self.create(short_name, name, record_type, content, options={})
|
33
|
-
template = DNSimple::Template.find(short_name)
|
34
|
-
|
35
|
-
record_hash = {:name => name, :record_type => record_type, :content => content}
|
36
|
-
record_hash[:ttl] = options.delete(:ttl) || 3600
|
37
|
-
record_hash[:prio] = options.delete(:prio) || ''
|
38
|
-
|
39
|
-
options.merge!({:query => {:dns_template_record => record_hash}})
|
40
|
-
|
41
|
-
response = DNSimple::Client.post("/v1/templates/#{template.id}/template_records", options)
|
42
|
-
|
43
|
-
case response.code
|
44
|
-
when 201
|
45
|
-
new({:template => template}.merge(response["dns_template_record"]))
|
46
|
-
else
|
47
|
-
raise RequestError.new("Error creating template record", response)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def self.find(short_name, id, options={})
|
52
|
-
template = DNSimple::Template.find(short_name)
|
53
|
-
response = DNSimple::Client.get("/v1/templates/#{template.id}/template_records/#{id}", options)
|
54
|
-
|
55
|
-
case response.code
|
56
|
-
when 200
|
57
|
-
new({:template => template}.merge(response["dns_template_record"]))
|
58
|
-
when 404
|
59
|
-
raise RecordNotFound, "Could not find template record #{id} for template #{template.id}"
|
60
|
-
else
|
61
|
-
raise RequestError.new("Error finding template record", response)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Get all of the template records for the template with the
|
66
|
-
# given short name.
|
67
|
-
def self.all(short_name, options={})
|
68
|
-
template = DNSimple::Template.find(short_name)
|
69
|
-
response = DNSimple::Client.get("/v1/templates/#{template.id}/template_records", options)
|
70
|
-
|
71
|
-
case response.code
|
72
|
-
when 200
|
73
|
-
response.map { |r| new({:template => template}.merge(r["dns_template_record"])) }
|
74
|
-
else
|
75
|
-
raise RequestError.new("Error listing template records", response)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module DNSimple
|
2
|
-
|
3
|
-
# Represents a transfer order.
|
4
|
-
class TransferOrder < Base
|
5
|
-
|
6
|
-
attr_accessor :id
|
7
|
-
|
8
|
-
attr_accessor :status
|
9
|
-
|
10
|
-
def self.create(name, authinfo='', registrant={}, extended_attributes={}, options={})
|
11
|
-
body = {:domain => {:name => name}, :transfer_order => {:authinfo => authinfo}}
|
12
|
-
|
13
|
-
if registrant[:id]
|
14
|
-
body[:domain][:registrant_id] = registrant[:id]
|
15
|
-
else
|
16
|
-
body.merge!(:contact => Contact.resolve_attributes(registrant))
|
17
|
-
end
|
18
|
-
|
19
|
-
body.merge!(:extended_attribute => extended_attributes)
|
20
|
-
|
21
|
-
options.merge!({:body => body})
|
22
|
-
|
23
|
-
response = DNSimple::Client.post("/v1/domain_transfers", options)
|
24
|
-
|
25
|
-
case response.code
|
26
|
-
when 201
|
27
|
-
new(response["transfer_order"])
|
28
|
-
else
|
29
|
-
raise RequestError.new("Error creating transfer order", response)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
data/lib/dnsimple/user.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
module DNSimple
|
2
|
-
class User < Base
|
3
|
-
|
4
|
-
attr_accessor :id
|
5
|
-
attr_accessor :email
|
6
|
-
attr_accessor :domain_count
|
7
|
-
attr_accessor :domain_limit
|
8
|
-
attr_accessor :login_count
|
9
|
-
attr_accessor :failed_login_count
|
10
|
-
attr_accessor :created_at
|
11
|
-
attr_accessor :updated_at
|
12
|
-
|
13
|
-
|
14
|
-
# Gets the information about the authenticated user.
|
15
|
-
#
|
16
|
-
# @return [User] the authenticated user
|
17
|
-
# @raise [RequestError] if the user doesn't exist
|
18
|
-
def self.me
|
19
|
-
response = DNSimple::Client.get("/v1/user")
|
20
|
-
|
21
|
-
case response.code
|
22
|
-
when 200
|
23
|
-
new(response["user"])
|
24
|
-
else
|
25
|
-
raise RequestError.new("Error finding account", response)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Requests a new two-factor authentication exchange token.
|
30
|
-
#
|
31
|
-
# The exchange-token is required to validate API requests
|
32
|
-
# using HTTP Basic Authentication when the account has two-factor authentication enabled.
|
33
|
-
#
|
34
|
-
# @see http://developer.dnsimple.com/authentication/#twofa
|
35
|
-
#
|
36
|
-
# @example Request an Exchange Token
|
37
|
-
#
|
38
|
-
# DNSimple::User.two_factor_exchange_token('0000000')
|
39
|
-
# # => "cda038832591e34f5df642ce2b61dc78"
|
40
|
-
#
|
41
|
-
# @param [String] otp_token the two-factor one time (OTP) token
|
42
|
-
#
|
43
|
-
# @return [String] the two-factor API exchange token
|
44
|
-
# @raise [AuthenticationFailed] if the provided OTP token is invalid
|
45
|
-
def self.two_factor_exchange_token(otp_token)
|
46
|
-
response = DNSimple::Client.get("/v1/user", :headers => { DNSimple::Client::HEADER_2FA_STRICT => "1", DNSimple::Client::HEADER_OTP_TOKEN => otp_token })
|
47
|
-
response.headers[DNSimple::Client::HEADER_EXCHANGE_TOKEN]
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|