dnsimple 2.0.0.alpha4 → 2.0.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +22 -2
- data/UPGRADING.markdown +102 -0
- data/lib/dnsimple/client.rb +37 -16
- data/lib/dnsimple/client/certificates.rb +9 -7
- data/lib/dnsimple/client/contacts.rb +7 -5
- data/lib/dnsimple/client/domains.rb +6 -4
- data/lib/dnsimple/client/domains_forwards.rb +6 -6
- data/lib/dnsimple/client/domains_records.rb +7 -7
- data/lib/dnsimple/client/domains_sharing.rb +4 -4
- data/lib/dnsimple/client/domains_zones.rb +1 -1
- data/lib/dnsimple/client/name_servers.rb +5 -3
- data/lib/dnsimple/client/registrar.rb +20 -7
- data/lib/dnsimple/client/services.rb +5 -3
- data/lib/dnsimple/client/services_domains.rb +4 -4
- data/lib/dnsimple/client/templates.rb +8 -6
- data/lib/dnsimple/client/templates_records.rb +7 -7
- data/lib/dnsimple/error.rb +1 -1
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/certificates_spec.rb +20 -20
- data/spec/dnsimple/client/contacts_spec.rb +24 -24
- data/spec/dnsimple/client/domains_autorenewals_spec.rb +4 -4
- data/spec/dnsimple/client/domains_forwards_spec.rb +17 -17
- data/spec/dnsimple/client/domains_privacy_spec.rb +4 -4
- data/spec/dnsimple/client/domains_records_spec.rb +20 -20
- data/spec/dnsimple/client/domains_sharing_spec.rb +12 -12
- data/spec/dnsimple/client/domains_spec.rb +14 -14
- data/spec/dnsimple/client/domains_zones_spec.rb +2 -2
- data/spec/dnsimple/client/name_servers_spec.rb +13 -13
- data/spec/dnsimple/client/registrar_spec.rb +48 -6
- data/spec/dnsimple/client/services_spec.rb +11 -11
- data/spec/dnsimple/client/templates_records_spec.rb +17 -17
- data/spec/dnsimple/client/templates_spec.rb +17 -17
- data/spec/dnsimple/client_spec.rb +23 -19
- data/spec/files/certificates/{show → get}/success.http +0 -0
- data/spec/files/certificates/{index → list}/success.http +0 -0
- data/spec/files/contacts/{show → get}/success.http +1 -1
- data/spec/files/contacts/{index → list}/success.http +1 -1
- data/spec/files/domains/{show → get}/success.http +0 -0
- data/spec/files/domains/{index → list}/success.http +0 -0
- data/spec/files/domains_records/{show → get}/success.http +0 -0
- data/spec/files/domains_records/{index → list}/success.http +0 -0
- data/spec/files/services/{show → get}/success.http +0 -0
- data/spec/files/services/{index → list}/success.http +0 -0
- data/spec/files/subscriptions/{show → get}/success.http +0 -0
- data/spec/files/templates/{show → get}/success.http +0 -0
- data/spec/files/templates/{index → list}/success.http +0 -0
- data/spec/files/templates_records/{show → get}/success.http +0 -0
- data/spec/files/templates_records/{index → list}/success.http +0 -0
- metadata +33 -32
@@ -9,9 +9,9 @@ module Dnsimple
|
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
#
|
11
11
|
# @return [Array<Struct::Membership>]
|
12
|
-
# @raise [
|
12
|
+
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
|
-
def
|
14
|
+
def memberships(domain)
|
15
15
|
response = client.get("v1/domains/#{domain}/memberships")
|
16
16
|
|
17
17
|
response.map { |r| Struct::Membership.new(r["membership"]) }
|
@@ -25,7 +25,7 @@ module Dnsimple
|
|
25
25
|
# @param [String] email
|
26
26
|
#
|
27
27
|
# @return [Struct::Membership]
|
28
|
-
# @raise [
|
28
|
+
# @raise [NotFoundError]
|
29
29
|
# @raise [RequestError] When the request fails.
|
30
30
|
def create_membership(domain, email)
|
31
31
|
options = { membership: { email: email }}
|
@@ -42,7 +42,7 @@ module Dnsimple
|
|
42
42
|
# @param [Fixnum] membership The membership id.
|
43
43
|
#
|
44
44
|
# @return [void]
|
45
|
-
# @raise [
|
45
|
+
# @raise [NotFoundError]
|
46
46
|
# @raise [RequestError] When the request fails.
|
47
47
|
def delete_membership(domain, membership)
|
48
48
|
client.delete("v1/domains/#{domain}/memberships/#{membership}")
|
@@ -9,7 +9,7 @@ module Dnsimple
|
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
#
|
11
11
|
# @return [String]
|
12
|
-
# @raise [
|
12
|
+
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
14
|
def zone(domain)
|
15
15
|
response = client.get("v1/domains/#{domain}/zone")
|
@@ -9,14 +9,16 @@ module Dnsimple
|
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
#
|
11
11
|
# @return [Array<String>] The delegates name servers.
|
12
|
-
# @raise [
|
12
|
+
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
|
-
def
|
14
|
+
def name_servers(domain)
|
15
15
|
response = client.get("v1/domains/#{domain}/name_servers")
|
16
16
|
|
17
17
|
response.parsed_response
|
18
18
|
end
|
19
19
|
|
20
|
+
alias :list :name_servers
|
21
|
+
|
20
22
|
# Changes the name servers for a domain.
|
21
23
|
#
|
22
24
|
# @see http://developer.dnsimple.com/domains/nameservers/#change
|
@@ -25,7 +27,7 @@ module Dnsimple
|
|
25
27
|
# @param [Array<String>] servers The name server list.
|
26
28
|
#
|
27
29
|
# @return [Array<String>] The delegates name servers.
|
28
|
-
# @raise [
|
30
|
+
# @raise [NotFoundError]
|
29
31
|
# @raise [RequestError] When the request fails.
|
30
32
|
def change(domain, servers)
|
31
33
|
servers = servers.inject({}) { |hash, server| hash.merge("ns#{hash.length + 1}" => server) }
|
@@ -8,15 +8,28 @@ module Dnsimple
|
|
8
8
|
#
|
9
9
|
# @param [#to_s] name The domain name to check.
|
10
10
|
#
|
11
|
-
# @return [
|
11
|
+
# @return [Hash] The response containing the status, price, and more details.
|
12
12
|
# @raise [RequestError] When the request fails.
|
13
|
-
def check(name
|
14
|
-
begin
|
15
|
-
client.get("v1/domains/#{name}/check"
|
16
|
-
|
17
|
-
|
18
|
-
"available"
|
13
|
+
def check(name)
|
14
|
+
response = begin
|
15
|
+
client.get("v1/domains/#{name}/check")
|
16
|
+
rescue NotFoundError => e
|
17
|
+
e.response
|
19
18
|
end
|
19
|
+
|
20
|
+
response.parsed_response
|
21
|
+
end
|
22
|
+
|
23
|
+
# Checks the availability of a domain name.
|
24
|
+
#
|
25
|
+
# @see http://developer.dnsimple.com/domains/registry/#check
|
26
|
+
#
|
27
|
+
# @param [#to_s] name The domain name to check.
|
28
|
+
#
|
29
|
+
# @return [Boolean] true if the domain is available
|
30
|
+
# @raise [RequestError] When the request fails.
|
31
|
+
def available?(name)
|
32
|
+
check(name)["status"] == "available"
|
20
33
|
end
|
21
34
|
|
22
35
|
# Registers a domain.
|
@@ -8,12 +8,14 @@ module Dnsimple
|
|
8
8
|
#
|
9
9
|
# @return [Array<Struct::Service>]
|
10
10
|
# @raise [RequestError] When the request fails.
|
11
|
-
def
|
11
|
+
def services
|
12
12
|
response = client.get("v1/services")
|
13
13
|
|
14
14
|
response.map { |r| Struct::Service.new(r["service"]) }
|
15
15
|
end
|
16
16
|
|
17
|
+
alias :list :services
|
18
|
+
|
17
19
|
# Gets a service.
|
18
20
|
#
|
19
21
|
# @see http://developer.dnsimple.com/services/#get
|
@@ -21,9 +23,9 @@ module Dnsimple
|
|
21
23
|
# @param [Fixnum] service The service id.
|
22
24
|
#
|
23
25
|
# @return [Struct::Service]
|
24
|
-
# @raise [
|
26
|
+
# @raise [NotFoundError]
|
25
27
|
# @raise [RequestError] When the request fails.
|
26
|
-
def
|
28
|
+
def service(service)
|
27
29
|
response = client.get("v1/services/#{service}")
|
28
30
|
|
29
31
|
Struct::Service.new(response["service"])
|
@@ -9,7 +9,7 @@ module Dnsimple
|
|
9
9
|
# @param [#to_s] domain The domain id or domain name.
|
10
10
|
#
|
11
11
|
# @return [Array<Struct::Service>]
|
12
|
-
# @raise [
|
12
|
+
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
14
|
def applied(domain)
|
15
15
|
response = client.get("v1/domains/#{domain}/applied_services")
|
@@ -24,7 +24,7 @@ module Dnsimple
|
|
24
24
|
# @param [#to_s] domain The domain id or domain name.
|
25
25
|
#
|
26
26
|
# @return [Array<Struct::Service>]
|
27
|
-
# @raise [
|
27
|
+
# @raise [NotFoundError]
|
28
28
|
# @raise [RequestError] When the request fails.
|
29
29
|
def available(domain)
|
30
30
|
response = client.get("v1/domains/#{domain}/available_services")
|
@@ -40,7 +40,7 @@ module Dnsimple
|
|
40
40
|
# @param [Fixnum] service The service id.
|
41
41
|
#
|
42
42
|
# @return [void]
|
43
|
-
# @raise [
|
43
|
+
# @raise [NotFoundError]
|
44
44
|
# @raise [RequestError] When the request fails.
|
45
45
|
def apply(domain, service)
|
46
46
|
options = { service: { id: service }}
|
@@ -56,7 +56,7 @@ module Dnsimple
|
|
56
56
|
# @param [Fixnum] service The service id.
|
57
57
|
#
|
58
58
|
# @return [void]
|
59
|
-
# @raise [
|
59
|
+
# @raise [NotFoundError]
|
60
60
|
# @raise [RequestError] When the request fails.
|
61
61
|
def unapply(domain, service)
|
62
62
|
response = client.delete("v1/domains/#{domain}/applied_services/#{service}")
|
@@ -8,12 +8,14 @@ module Dnsimple
|
|
8
8
|
#
|
9
9
|
# @return [Array<Struct::Template>]
|
10
10
|
# @raise [RequestError] When the request fails.
|
11
|
-
def
|
11
|
+
def templates
|
12
12
|
response = client.get("v1/templates")
|
13
13
|
|
14
14
|
response.map { |r| Struct::Template.new(r["dns_template"]) }
|
15
15
|
end
|
16
16
|
|
17
|
+
alias :list :templates
|
18
|
+
|
17
19
|
# Creates a template in the account.
|
18
20
|
#
|
19
21
|
# @see http://developer.dnsimple.com/templates/#create
|
@@ -37,9 +39,9 @@ module Dnsimple
|
|
37
39
|
# @param [#to_s] template The template id or short-name.
|
38
40
|
#
|
39
41
|
# @return [Struct::Template]
|
40
|
-
# @raise [
|
42
|
+
# @raise [NotFoundError]
|
41
43
|
# @raise [RequestError] When the request fails.
|
42
|
-
def
|
44
|
+
def template(template)
|
43
45
|
response = client.get("v1/templates/#{template}")
|
44
46
|
|
45
47
|
Struct::Template.new(response["dns_template"])
|
@@ -53,7 +55,7 @@ module Dnsimple
|
|
53
55
|
# @param [Hash] attributes
|
54
56
|
#
|
55
57
|
# @return [Struct::Template]
|
56
|
-
# @raise [
|
58
|
+
# @raise [NotFoundError]
|
57
59
|
# @raise [RequestError] When the request fails.
|
58
60
|
def update(template, attributes = {})
|
59
61
|
options = { dns_template: attributes }
|
@@ -71,7 +73,7 @@ module Dnsimple
|
|
71
73
|
# @param [#to_s] template The template id or short-name.
|
72
74
|
#
|
73
75
|
# @return [void]
|
74
|
-
# @raise [
|
76
|
+
# @raise [NotFoundError]
|
75
77
|
# @raise [RequestError] When the request fails.
|
76
78
|
def delete(template)
|
77
79
|
client.delete("v1/templates/#{template}")
|
@@ -86,7 +88,7 @@ module Dnsimple
|
|
86
88
|
# @param [#to_s] template The template id or short-name.
|
87
89
|
#
|
88
90
|
# @return [void]
|
89
|
-
# @raise [
|
91
|
+
# @raise [NotFoundError]
|
90
92
|
# @raise [RequestError] When the request fails.
|
91
93
|
def apply(domain, template)
|
92
94
|
response = client.post("v1/domains/#{domain}/templates/#{template}/apply")
|
@@ -9,9 +9,9 @@ module Dnsimple
|
|
9
9
|
# @param [#to_s] template The template id or short-name.
|
10
10
|
#
|
11
11
|
# @return [Array<Struct::TemplateRecord>]
|
12
|
-
# @raise [
|
12
|
+
# @raise [NotFoundError]
|
13
13
|
# @raise [RequestError] When the request fails.
|
14
|
-
def
|
14
|
+
def records(template)
|
15
15
|
response = client.get("v1/templates/#{template}/records")
|
16
16
|
|
17
17
|
response.map { |r| Struct::TemplateRecord.new(r["dns_template_record"]) }
|
@@ -25,7 +25,7 @@ module Dnsimple
|
|
25
25
|
# @param [Hash] attributes
|
26
26
|
#
|
27
27
|
# @return [Struct::TemplateRecord]
|
28
|
-
# @raise [
|
28
|
+
# @raise [NotFoundError]
|
29
29
|
# @raise [RequestError] When the request fails.
|
30
30
|
def create_record(template, attributes = {})
|
31
31
|
Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content])
|
@@ -43,9 +43,9 @@ module Dnsimple
|
|
43
43
|
# @param [Fixnum] record The record id.
|
44
44
|
#
|
45
45
|
# @return [Struct::TemplateRecord]
|
46
|
-
# @raise [
|
46
|
+
# @raise [NotFoundError]
|
47
47
|
# @raise [RequestError] When the request fails.
|
48
|
-
def
|
48
|
+
def record(template, record)
|
49
49
|
response = client.get("v1/templates/#{template}/records/#{record}")
|
50
50
|
|
51
51
|
Struct::TemplateRecord.new(response["dns_template_record"])
|
@@ -60,7 +60,7 @@ module Dnsimple
|
|
60
60
|
# @param [Hash] attributes
|
61
61
|
#
|
62
62
|
# @return [Struct::TemplateRecord]
|
63
|
-
# @raise [
|
63
|
+
# @raise [NotFoundError]
|
64
64
|
# @raise [RequestError] When the request fails.
|
65
65
|
def update_record(template, record, attributes = {})
|
66
66
|
options = { dns_template_record: attributes }
|
@@ -77,7 +77,7 @@ module Dnsimple
|
|
77
77
|
# @param [Fixnum] record The record id.
|
78
78
|
#
|
79
79
|
# @return [Template]
|
80
|
-
# @raise [
|
80
|
+
# @raise [NotFoundError]
|
81
81
|
# @raise [RequestError] When the request fails.
|
82
82
|
def delete_record(template, record)
|
83
83
|
client.delete("v1/templates/#{template}/records/#{record}")
|
data/lib/dnsimple/error.rb
CHANGED
data/lib/dnsimple/version.rb
CHANGED
@@ -5,21 +5,21 @@ describe Dnsimple::Client, ".certificates" do
|
|
5
5
|
subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").certificates }
|
6
6
|
|
7
7
|
|
8
|
-
describe "#
|
8
|
+
describe "#certificates" do
|
9
9
|
before do
|
10
10
|
stub_request(:get, %r[/v1/domains/.+/certificates$]).
|
11
|
-
to_return(read_fixture("certificates/
|
11
|
+
to_return(read_fixture("certificates/list/success.http"))
|
12
12
|
end
|
13
13
|
|
14
14
|
it "builds the correct request" do
|
15
|
-
subject.
|
15
|
+
subject.certificates("example.com")
|
16
16
|
|
17
17
|
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/certificates").
|
18
18
|
with(headers: { 'Accept' => 'application/json' })
|
19
19
|
end
|
20
20
|
|
21
21
|
it "returns the records" do
|
22
|
-
results = subject.
|
22
|
+
results = subject.certificates("example.com")
|
23
23
|
|
24
24
|
expect(results).to be_a(Array)
|
25
25
|
expect(results.size).to eq(2)
|
@@ -31,32 +31,32 @@ describe Dnsimple::Client, ".certificates" do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
context "when something does not exist" do
|
34
|
-
it "raises
|
34
|
+
it "raises NotFoundError" do
|
35
35
|
stub_request(:get, %r[/v1]).
|
36
36
|
to_return(read_fixture("domains/notfound.http"))
|
37
37
|
|
38
38
|
expect {
|
39
|
-
subject.
|
40
|
-
}.to raise_error(Dnsimple::
|
39
|
+
subject.certificates("example.com")
|
40
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
describe "#
|
45
|
+
describe "#certificate" do
|
46
46
|
before do
|
47
47
|
stub_request(:get, %r[/v1/domains/.+/certificates/.+$]).
|
48
|
-
to_return(read_fixture("certificates/
|
48
|
+
to_return(read_fixture("certificates/get/success.http"))
|
49
49
|
end
|
50
50
|
|
51
51
|
it "builds the correct request" do
|
52
|
-
subject.
|
52
|
+
subject.certificate("example.com", 2)
|
53
53
|
|
54
54
|
expect(WebMock).to have_requested(:get, "https://api.zone/v1/domains/example.com/certificates/2").
|
55
55
|
with(headers: { 'Accept' => 'application/json' })
|
56
56
|
end
|
57
57
|
|
58
58
|
it "returns the certificate" do
|
59
|
-
result = subject.
|
59
|
+
result = subject.certificate("example.com", 2)
|
60
60
|
|
61
61
|
expect(result).to be_a(Dnsimple::Struct::Certificate)
|
62
62
|
expect(result.id).to eq(4576)
|
@@ -75,13 +75,13 @@ describe Dnsimple::Client, ".certificates" do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
context "when something does not exist" do
|
78
|
-
it "raises
|
78
|
+
it "raises NotFoundError" do
|
79
79
|
stub_request(:get, %r[/v1]).
|
80
80
|
to_return(read_fixture("certificates/notfound.http"))
|
81
81
|
|
82
82
|
expect {
|
83
|
-
subject.
|
84
|
-
}.to raise_error(Dnsimple::
|
83
|
+
subject.certificate("example.com", 2)
|
84
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|
@@ -116,13 +116,13 @@ describe Dnsimple::Client, ".certificates" do
|
|
116
116
|
end
|
117
117
|
|
118
118
|
context "when something does not exist" do
|
119
|
-
it "raises
|
119
|
+
it "raises NotFoundError" do
|
120
120
|
stub_request(:post, %r[/v1]).
|
121
121
|
to_return(read_fixture("domains/notfound.http"))
|
122
122
|
|
123
123
|
expect {
|
124
124
|
subject.purchase("example.com", "www", 100)
|
125
|
-
}.to raise_error(Dnsimple::
|
125
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
@@ -149,13 +149,13 @@ describe Dnsimple::Client, ".certificates" do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
context "when something does not exist" do
|
152
|
-
it "raises
|
152
|
+
it "raises NotFoundError" do
|
153
153
|
stub_request(:put, %r[/v1]).
|
154
154
|
to_return(read_fixture("certificates/notfound.http"))
|
155
155
|
|
156
156
|
expect {
|
157
157
|
subject.configure("example.com", 2)
|
158
|
-
}.to raise_error(Dnsimple::
|
158
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
@@ -182,13 +182,13 @@ describe Dnsimple::Client, ".certificates" do
|
|
182
182
|
end
|
183
183
|
|
184
184
|
context "when something does not exist" do
|
185
|
-
it "raises
|
185
|
+
it "raises NotFoundError" do
|
186
186
|
stub_request(:put, %r[/v1]).
|
187
187
|
to_return(read_fixture("certificates/notfound.http"))
|
188
188
|
|
189
189
|
expect {
|
190
190
|
subject.submit("example.com", 2, "admin@example.com")
|
191
|
-
}.to raise_error(Dnsimple::
|
191
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
end
|
@@ -5,24 +5,24 @@ describe Dnsimple::Client, ".contacts" do
|
|
5
5
|
subject { described_class.new(api_endpoint: "https://api.zone", username: "user", api_token: "token").contacts }
|
6
6
|
|
7
7
|
|
8
|
-
describe "#
|
8
|
+
describe "#contacts" do
|
9
9
|
before do
|
10
10
|
stub_request(:get, %r[/v1/contacts$]).
|
11
|
-
to_return(read_fixture("contacts/
|
11
|
+
to_return(read_fixture("contacts/list/success.http"))
|
12
12
|
end
|
13
13
|
|
14
14
|
it "builds the correct request" do
|
15
|
-
subject.
|
15
|
+
subject.contacts
|
16
16
|
|
17
17
|
expect(WebMock).to have_requested(:get, "https://api.zone/v1/contacts").
|
18
18
|
with(headers: { 'Accept' => 'application/json' })
|
19
19
|
end
|
20
20
|
|
21
21
|
it "returns the contacts" do
|
22
|
-
results = subject.
|
22
|
+
results = subject.contacts
|
23
23
|
|
24
24
|
expect(results).to be_a(Array)
|
25
|
-
expect(results.size).to eq(
|
25
|
+
expect(results.size).to eq(2)
|
26
26
|
|
27
27
|
results.each do |result|
|
28
28
|
expect(result).to be_a(Dnsimple::Struct::Contact)
|
@@ -33,7 +33,7 @@ describe Dnsimple::Client, ".contacts" do
|
|
33
33
|
|
34
34
|
describe "#create" do
|
35
35
|
before do
|
36
|
-
stub_request(:post, %r[/v1/contacts]).
|
36
|
+
stub_request(:post, %r[/v1/contacts$]).
|
37
37
|
to_return(read_fixture("contacts/create/created.http"))
|
38
38
|
end
|
39
39
|
|
@@ -55,50 +55,50 @@ describe Dnsimple::Client, ".contacts" do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
describe "#
|
58
|
+
describe "#contact" do
|
59
59
|
before do
|
60
60
|
stub_request(:get, %r[/v1/contacts/.+$]).
|
61
|
-
to_return(read_fixture("contacts/
|
61
|
+
to_return(read_fixture("contacts/get/success.http"))
|
62
62
|
end
|
63
63
|
|
64
64
|
it "builds the correct request" do
|
65
|
-
subject.
|
65
|
+
subject.contact(1)
|
66
66
|
|
67
67
|
expect(WebMock).to have_requested(:get, "https://api.zone/v1/contacts/1").
|
68
68
|
with(headers: { 'Accept' => 'application/json' })
|
69
69
|
end
|
70
70
|
|
71
71
|
it "returns the contact" do
|
72
|
-
result = subject.
|
72
|
+
result = subject.contact(1)
|
73
73
|
|
74
74
|
expect(result).to be_a(Dnsimple::Struct::Contact)
|
75
|
-
expect(result.id).to eq(
|
75
|
+
expect(result.id).to eq(1)
|
76
76
|
expect(result.label).to eq("Default")
|
77
77
|
expect(result.first_name).to eq("Simone")
|
78
78
|
expect(result.last_name).to eq("Carletti")
|
79
79
|
expect(result.job_title).to eq("Underwater Programmer")
|
80
|
-
expect(result.organization_name).to eq("
|
81
|
-
expect(result.email_address).to eq("
|
82
|
-
expect(result.phone).to eq("+1 111
|
83
|
-
expect(result.fax).to eq("+1 222
|
80
|
+
expect(result.organization_name).to eq("DNSimple")
|
81
|
+
expect(result.email_address).to eq("simone.carletti@dnsimple.com")
|
82
|
+
expect(result.phone).to eq("+1 111 4567890")
|
83
|
+
expect(result.fax).to eq("+1 222 4567890")
|
84
84
|
expect(result.address1).to eq("Awesome Street")
|
85
85
|
expect(result.address2).to eq("c/o Someone")
|
86
86
|
expect(result.city).to eq("Rome")
|
87
87
|
expect(result.state_province).to eq("RM")
|
88
88
|
expect(result.postal_code).to eq("00171")
|
89
89
|
expect(result.country).to eq("IT")
|
90
|
-
expect(result.created_at).to eq("
|
91
|
-
expect(result.updated_at).to eq("
|
90
|
+
expect(result.created_at).to eq("2014-01-15T22:08:07.390Z")
|
91
|
+
expect(result.updated_at).to eq("2014-01-15T22:08:07.390Z")
|
92
92
|
end
|
93
93
|
|
94
94
|
context "when something does not exist" do
|
95
|
-
it "raises
|
95
|
+
it "raises NotFoundError" do
|
96
96
|
stub_request(:get, %r[/v1]).
|
97
97
|
to_return(read_fixture("contacts/notfound.http"))
|
98
98
|
|
99
99
|
expect {
|
100
|
-
subject.
|
101
|
-
}.to raise_error(Dnsimple::
|
100
|
+
subject.contact(1)
|
101
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
end
|
@@ -125,13 +125,13 @@ describe Dnsimple::Client, ".contacts" do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
context "when something does not exist" do
|
128
|
-
it "raises
|
128
|
+
it "raises NotFoundError" do
|
129
129
|
stub_request(:put, %r[/v1]).
|
130
130
|
to_return(read_fixture("contacts/notfound.http"))
|
131
131
|
|
132
132
|
expect {
|
133
133
|
subject.update(1, {})
|
134
|
-
}.to raise_error(Dnsimple::
|
134
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
end
|
@@ -165,13 +165,13 @@ describe Dnsimple::Client, ".contacts" do
|
|
165
165
|
end
|
166
166
|
|
167
167
|
context "when something does not exist" do
|
168
|
-
it "raises
|
168
|
+
it "raises NotFoundError" do
|
169
169
|
stub_request(:delete, %r[/v1]).
|
170
170
|
to_return(read_fixture("contacts/notfound.http"))
|
171
171
|
|
172
172
|
expect {
|
173
173
|
subject.delete(1)
|
174
|
-
}.to raise_error(Dnsimple::
|
174
|
+
}.to raise_error(Dnsimple::NotFoundError)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|