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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +22 -2
  3. data/UPGRADING.markdown +102 -0
  4. data/lib/dnsimple/client.rb +37 -16
  5. data/lib/dnsimple/client/certificates.rb +9 -7
  6. data/lib/dnsimple/client/contacts.rb +7 -5
  7. data/lib/dnsimple/client/domains.rb +6 -4
  8. data/lib/dnsimple/client/domains_forwards.rb +6 -6
  9. data/lib/dnsimple/client/domains_records.rb +7 -7
  10. data/lib/dnsimple/client/domains_sharing.rb +4 -4
  11. data/lib/dnsimple/client/domains_zones.rb +1 -1
  12. data/lib/dnsimple/client/name_servers.rb +5 -3
  13. data/lib/dnsimple/client/registrar.rb +20 -7
  14. data/lib/dnsimple/client/services.rb +5 -3
  15. data/lib/dnsimple/client/services_domains.rb +4 -4
  16. data/lib/dnsimple/client/templates.rb +8 -6
  17. data/lib/dnsimple/client/templates_records.rb +7 -7
  18. data/lib/dnsimple/error.rb +1 -1
  19. data/lib/dnsimple/version.rb +1 -1
  20. data/spec/dnsimple/client/certificates_spec.rb +20 -20
  21. data/spec/dnsimple/client/contacts_spec.rb +24 -24
  22. data/spec/dnsimple/client/domains_autorenewals_spec.rb +4 -4
  23. data/spec/dnsimple/client/domains_forwards_spec.rb +17 -17
  24. data/spec/dnsimple/client/domains_privacy_spec.rb +4 -4
  25. data/spec/dnsimple/client/domains_records_spec.rb +20 -20
  26. data/spec/dnsimple/client/domains_sharing_spec.rb +12 -12
  27. data/spec/dnsimple/client/domains_spec.rb +14 -14
  28. data/spec/dnsimple/client/domains_zones_spec.rb +2 -2
  29. data/spec/dnsimple/client/name_servers_spec.rb +13 -13
  30. data/spec/dnsimple/client/registrar_spec.rb +48 -6
  31. data/spec/dnsimple/client/services_spec.rb +11 -11
  32. data/spec/dnsimple/client/templates_records_spec.rb +17 -17
  33. data/spec/dnsimple/client/templates_spec.rb +17 -17
  34. data/spec/dnsimple/client_spec.rb +23 -19
  35. data/spec/files/certificates/{show → get}/success.http +0 -0
  36. data/spec/files/certificates/{index → list}/success.http +0 -0
  37. data/spec/files/contacts/{show → get}/success.http +1 -1
  38. data/spec/files/contacts/{index → list}/success.http +1 -1
  39. data/spec/files/domains/{show → get}/success.http +0 -0
  40. data/spec/files/domains/{index → list}/success.http +0 -0
  41. data/spec/files/domains_records/{show → get}/success.http +0 -0
  42. data/spec/files/domains_records/{index → list}/success.http +0 -0
  43. data/spec/files/services/{show → get}/success.http +0 -0
  44. data/spec/files/services/{index → list}/success.http +0 -0
  45. data/spec/files/subscriptions/{show → get}/success.http +0 -0
  46. data/spec/files/templates/{show → get}/success.http +0 -0
  47. data/spec/files/templates/{index → list}/success.http +0 -0
  48. data/spec/files/templates_records/{show → get}/success.http +0 -0
  49. data/spec/files/templates_records/{index → list}/success.http +0 -0
  50. metadata +33 -32
@@ -24,7 +24,7 @@ describe Dnsimple::Client do
24
24
  stub_request(:any, %r[/test])
25
25
 
26
26
  subject = described_class.new(username: "user", password: "pass")
27
- subject.request(:get, "test", {})
27
+ subject.execute(:get, "test", {})
28
28
 
29
29
  expect(WebMock).to have_requested(:get, "https://user:pass@api.dnsimple.com/test")
30
30
  end
@@ -33,7 +33,7 @@ describe Dnsimple::Client do
33
33
  stub_request(:any, %r[/test])
34
34
 
35
35
  subject = described_class.new(domain_api_token: "domaintoken")
36
- subject.request(:get, "test", {})
36
+ subject.execute(:get, "test", {})
37
37
 
38
38
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.com/test").
39
39
  with { |req| req.headers["X-Dnsimple-Domain-Token"] == "domaintoken" }
@@ -43,7 +43,7 @@ describe Dnsimple::Client do
43
43
  stub_request(:any, %r[/test])
44
44
 
45
45
  subject = described_class.new(username: "user", api_token: "token")
46
- subject.request(:get, "test", {})
46
+ subject.execute(:get, "test", {})
47
47
 
48
48
  expect(WebMock).to have_requested(:get, "https://api.dnsimple.com/test").
49
49
  with { |req| req.headers["X-Dnsimple-Token"] == "user:token" }
@@ -53,7 +53,7 @@ describe Dnsimple::Client do
53
53
  stub_request(:any, %r[/test])
54
54
 
55
55
  subject = described_class.new(username: "user", password: "pass", exchange_token: "exchange-token")
56
- subject.request(:get, "test", {})
56
+ subject.execute(:get, "test", {})
57
57
 
58
58
  expect(WebMock).to have_requested(:get, "https://exchange-token:x-2fa-basic@api.dnsimple.com/test")
59
59
  end
@@ -62,7 +62,7 @@ describe Dnsimple::Client do
62
62
  subject = described_class.new(username: "user")
63
63
 
64
64
  expect {
65
- subject.request(:get, "test", {})
65
+ subject.execute(:get, "test", {})
66
66
  }.to raise_error(Dnsimple::Error, 'A password or API token is required for all API requests.')
67
67
  end
68
68
 
@@ -76,7 +76,7 @@ describe Dnsimple::Client do
76
76
 
77
77
  it "raises a TwoFactorAuthenticationRequired error" do
78
78
  expect {
79
- subject.request(:get, "test", {})
79
+ subject.execute(:get, "test", {})
80
80
  }.to raise_error(Dnsimple::TwoFactorAuthenticationRequired)
81
81
  end
82
82
  end
@@ -84,32 +84,45 @@ describe Dnsimple::Client do
84
84
 
85
85
  describe "#get" do
86
86
  it "delegates to #request" do
87
- expect(subject).to receive(:request).with(:get, "path", { foo: "bar" }).and_return(:returned)
87
+ expect(subject).to receive(:execute).with(:get, "path", { foo: "bar" }).and_return(:returned)
88
88
  expect(subject.get("path", foo: "bar")).to eq(:returned)
89
89
  end
90
90
  end
91
91
 
92
92
  describe "#post" do
93
93
  it "delegates to #request" do
94
- expect(subject).to receive(:request).with(:post, "path", { foo: "bar" }).and_return(:returned)
94
+ expect(subject).to receive(:execute).with(:post, "path", { foo: "bar" }).and_return(:returned)
95
95
  expect(subject.post("path", foo: "bar")).to eq(:returned)
96
96
  end
97
97
  end
98
98
 
99
99
  describe "#put" do
100
100
  it "delegates to #request" do
101
- expect(subject).to receive(:request).with(:put, "path", { foo: "bar" }).and_return(:returned)
101
+ expect(subject).to receive(:execute).with(:put, "path", { foo: "bar" }).and_return(:returned)
102
102
  expect(subject.put("path", foo: "bar")).to eq(:returned)
103
103
  end
104
104
  end
105
105
 
106
106
  describe "#delete" do
107
107
  it "delegates to #request" do
108
- expect(subject).to receive(:request).with(:delete, "path", { foo: "bar" }).and_return(:returned)
108
+ expect(subject).to receive(:execute).with(:delete, "path", { foo: "bar" }).and_return(:returned)
109
109
  expect(subject.delete("path", foo: "bar")).to eq(:returned)
110
110
  end
111
111
  end
112
112
 
113
+ describe "#execute" do
114
+ subject { described_class.new(username: "user", password: "pass") }
115
+
116
+ it "raises RequestError in case of error" do
117
+ stub_request(:get, %r[/foo]).
118
+ to_return(status: [500, "Internal Server Error"])
119
+
120
+ expect {
121
+ subject.execute(:get, "foo", {})
122
+ }.to raise_error(Dnsimple::RequestError, "500")
123
+ end
124
+ end
125
+
113
126
  describe "#request" do
114
127
  subject { described_class.new(username: "user", password: "pass") }
115
128
 
@@ -149,15 +162,6 @@ describe Dnsimple::Client do
149
162
 
150
163
  subject.request(:put, 'foo', { something: "else", query: { foo: "bar" }, headers: { "Custom" => "Header" } })
151
164
  end
152
-
153
- it "raises RequestError in case of error" do
154
- stub_request(:get, %r[/foo]).
155
- to_return(status: [500, "Internal Server Error"])
156
-
157
- expect {
158
- subject.request(:get, "foo", {})
159
- }.to raise_error(Dnsimple::RequestError, "500")
160
- end
161
165
  end
162
166
 
163
167
  end
File without changes
@@ -16,4 +16,4 @@ X-Request-Id: 954fef00cf763b3de6211670a740ebc9
16
16
  X-Runtime: 0.040477
17
17
  Strict-Transport-Security: max-age=315360000
18
18
 
19
- {"contact":{"id":2,"user_id":2,"label":"Default","first_name":"Simone","last_name":"Carletti","job_title":"Underwater Programmer","organization_name":"Dnsimple","email_address":"example@example.com","phone":"+1 111 000000","fax":"+1 222 000000","address1":"Awesome Street","address2":"c/o Someone","city":"Rome","state_province":"RM","postal_code":"00171","country":"IT","created_at":"2013-11-08T17:23:15Z","updated_at":"2013-11-08T17:23:15Z","phone_ext":null}}
19
+ {"contact":{"id":1,"user_id":21,"label":"Default","first_name":"Simone","last_name":"Carletti","job_title":"Underwater Programmer","organization_name":"DNSimple","email_address":"simone.carletti@dnsimple.com","phone":"+1 111 4567890","fax":"+1 222 4567890","address1":"Awesome Street","address2":"c/o Someone","city":"Rome","state_province":"RM","postal_code":"00171","country":"IT","created_at":"2014-01-15T22:08:07.390Z","updated_at":"2014-01-15T22:08:07.390Z"}}
@@ -20,4 +20,4 @@ X-Request-Id: 935327a1-d72e-4c11-b382-e817200496b6
20
20
  X-Runtime: 0.018471
21
21
  Strict-Transport-Security: max-age=315360000
22
22
 
23
- [{"contact":{"id":28,"user_id":19,"label":"Simone","first_name":"Simone","last_name":"Carletti","job_title":"Underwater Programmer","organization_name":"DNSimple","email_address":"simone.carletti@dnsimple.com","phone":"+1 111 4567890","fax":"+1 222 4567890","address1":"Awesome Street","address2":"c/o Someone","city":"Rome","state_province":"RM","postal_code":"00171","country":"IT","created_at":"2014-01-15T22:08:07.390Z","updated_at":"2014-01-15T22:08:07.390Z","phone_ext":null}}]
23
+ [{"contact":{"id":1,"user_id":21,"label":"Default","first_name":"Simone","last_name":"Carletti","job_title":"Underwater Programmer","organization_name":"DNSimple","email_address":"simone.carletti@dnsimple.com","phone":"+1 111 4567890","fax":"+1 222 4567890","address1":"Awesome Street","address2":"c/o Someone","city":"Rome","state_province":"RM","postal_code":"00171","country":"IT","created_at":"2014-01-15T22:08:07.390Z","updated_at":"2014-01-15T22:08:07.390Z"}},{"contact":{"id":2,"user_id":22,"label":"Simone","first_name":"Simone","last_name":"Carletti","job_title":"Underwater Programmer","organization_name":"DNSimple","email_address":"simone.carletti@dnsimple.com","phone":"+1 111 4567890","fax":"+1 222 4567890","address1":"Awesome Street","address2":"c/o Someone","city":"Rome","state_province":"RM","postal_code":"00171","country":"IT","created_at":"2014-01-15T22:08:07.390Z","updated_at":"2014-01-15T22:08:07.390Z"}}]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha4
4
+ version: 2.0.0.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Eden
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-03 00:00:00.000000000 Z
12
+ date: 2015-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -102,6 +102,7 @@ files:
102
102
  - LICENSE
103
103
  - README.markdown
104
104
  - Rakefile
105
+ - UPGRADING.markdown
105
106
  - dnsimple.gemspec
106
107
  - lib/dnsimple.rb
107
108
  - lib/dnsimple/client.rb
@@ -165,26 +166,26 @@ files:
165
166
  - spec/files/2fa/exchange-token.http
166
167
  - spec/files/badgateway.http
167
168
  - spec/files/certificates/configure/success.http
168
- - spec/files/certificates/index/success.http
169
+ - spec/files/certificates/get/success.http
170
+ - spec/files/certificates/list/success.http
169
171
  - spec/files/certificates/notfound.http
170
172
  - spec/files/certificates/purchase/success.http
171
- - spec/files/certificates/show/success.http
172
173
  - spec/files/certificates/submit/success.http
173
174
  - spec/files/contacts/create/badrequest-missingcontact.http
174
175
  - spec/files/contacts/create/badrequest-validationerror.http
175
176
  - spec/files/contacts/create/created.http
176
177
  - spec/files/contacts/delete/success-204.http
177
178
  - spec/files/contacts/delete/success.http
178
- - spec/files/contacts/index/success.http
179
+ - spec/files/contacts/get/success.http
180
+ - spec/files/contacts/list/success.http
179
181
  - spec/files/contacts/notfound.http
180
- - spec/files/contacts/show/success.http
181
182
  - spec/files/contacts/update/success.http
182
183
  - spec/files/domains/create/created.http
183
184
  - spec/files/domains/delete/success-204.http
184
185
  - spec/files/domains/delete/success.http
185
- - spec/files/domains/index/success.http
186
+ - spec/files/domains/get/success.http
187
+ - spec/files/domains/list/success.http
186
188
  - spec/files/domains/notfound.http
187
- - spec/files/domains/show/success.http
188
189
  - spec/files/domains_autorenewal/disable/success.http
189
190
  - spec/files/domains_autorenewal/enable/success.http
190
191
  - spec/files/domains_autorenewal/notfound-domain.http
@@ -200,9 +201,9 @@ files:
200
201
  - spec/files/domains_records/create/created.http
201
202
  - spec/files/domains_records/delete/success-204.http
202
203
  - spec/files/domains_records/delete/success.http
203
- - spec/files/domains_records/index/success.http
204
+ - spec/files/domains_records/get/success.http
205
+ - spec/files/domains_records/list/success.http
204
206
  - spec/files/domains_records/notfound.http
205
- - spec/files/domains_records/show/success.http
206
207
  - spec/files/domains_records/update/success.http
207
208
  - spec/files/domains_sharing/create/success.http
208
209
  - spec/files/domains_sharing/delete/success.http
@@ -231,25 +232,25 @@ files:
231
232
  - spec/files/services/applied/success.http
232
233
  - spec/files/services/apply/success.http
233
234
  - spec/files/services/available/success.http
234
- - spec/files/services/index/success.http
235
+ - spec/files/services/get/success.http
236
+ - spec/files/services/list/success.http
235
237
  - spec/files/services/notfound.http
236
- - spec/files/services/show/success.http
237
238
  - spec/files/services/unapply/success.http
238
- - spec/files/subscriptions/show/success.http
239
+ - spec/files/subscriptions/get/success.http
239
240
  - spec/files/templates/apply/success.http
240
241
  - spec/files/templates/create/created.http
241
242
  - spec/files/templates/delete/success-204.http
242
243
  - spec/files/templates/delete/success.http
243
- - spec/files/templates/index/success.http
244
+ - spec/files/templates/get/success.http
245
+ - spec/files/templates/list/success.http
244
246
  - spec/files/templates/notfound.http
245
- - spec/files/templates/show/success.http
246
247
  - spec/files/templates/update/success.http
247
248
  - spec/files/templates_records/create/created.http
248
249
  - spec/files/templates_records/delete/success-204.http
249
250
  - spec/files/templates_records/delete/success.http
250
- - spec/files/templates_records/index/success.http
251
+ - spec/files/templates_records/get/success.http
252
+ - spec/files/templates_records/list/success.http
251
253
  - spec/files/templates_records/notfound.http
252
- - spec/files/templates_records/show/success.http
253
254
  - spec/files/templates_records/update/success.http
254
255
  - spec/files/users/user/success.http
255
256
  - spec/spec_helper.rb
@@ -302,26 +303,26 @@ test_files:
302
303
  - spec/files/2fa/exchange-token.http
303
304
  - spec/files/badgateway.http
304
305
  - spec/files/certificates/configure/success.http
305
- - spec/files/certificates/index/success.http
306
+ - spec/files/certificates/get/success.http
307
+ - spec/files/certificates/list/success.http
306
308
  - spec/files/certificates/notfound.http
307
309
  - spec/files/certificates/purchase/success.http
308
- - spec/files/certificates/show/success.http
309
310
  - spec/files/certificates/submit/success.http
310
311
  - spec/files/contacts/create/badrequest-missingcontact.http
311
312
  - spec/files/contacts/create/badrequest-validationerror.http
312
313
  - spec/files/contacts/create/created.http
313
314
  - spec/files/contacts/delete/success-204.http
314
315
  - spec/files/contacts/delete/success.http
315
- - spec/files/contacts/index/success.http
316
+ - spec/files/contacts/get/success.http
317
+ - spec/files/contacts/list/success.http
316
318
  - spec/files/contacts/notfound.http
317
- - spec/files/contacts/show/success.http
318
319
  - spec/files/contacts/update/success.http
319
320
  - spec/files/domains/create/created.http
320
321
  - spec/files/domains/delete/success-204.http
321
322
  - spec/files/domains/delete/success.http
322
- - spec/files/domains/index/success.http
323
+ - spec/files/domains/get/success.http
324
+ - spec/files/domains/list/success.http
323
325
  - spec/files/domains/notfound.http
324
- - spec/files/domains/show/success.http
325
326
  - spec/files/domains_autorenewal/disable/success.http
326
327
  - spec/files/domains_autorenewal/enable/success.http
327
328
  - spec/files/domains_autorenewal/notfound-domain.http
@@ -337,9 +338,9 @@ test_files:
337
338
  - spec/files/domains_records/create/created.http
338
339
  - spec/files/domains_records/delete/success-204.http
339
340
  - spec/files/domains_records/delete/success.http
340
- - spec/files/domains_records/index/success.http
341
+ - spec/files/domains_records/get/success.http
342
+ - spec/files/domains_records/list/success.http
341
343
  - spec/files/domains_records/notfound.http
342
- - spec/files/domains_records/show/success.http
343
344
  - spec/files/domains_records/update/success.http
344
345
  - spec/files/domains_sharing/create/success.http
345
346
  - spec/files/domains_sharing/delete/success.http
@@ -368,25 +369,25 @@ test_files:
368
369
  - spec/files/services/applied/success.http
369
370
  - spec/files/services/apply/success.http
370
371
  - spec/files/services/available/success.http
371
- - spec/files/services/index/success.http
372
+ - spec/files/services/get/success.http
373
+ - spec/files/services/list/success.http
372
374
  - spec/files/services/notfound.http
373
- - spec/files/services/show/success.http
374
375
  - spec/files/services/unapply/success.http
375
- - spec/files/subscriptions/show/success.http
376
+ - spec/files/subscriptions/get/success.http
376
377
  - spec/files/templates/apply/success.http
377
378
  - spec/files/templates/create/created.http
378
379
  - spec/files/templates/delete/success-204.http
379
380
  - spec/files/templates/delete/success.http
380
- - spec/files/templates/index/success.http
381
+ - spec/files/templates/get/success.http
382
+ - spec/files/templates/list/success.http
381
383
  - spec/files/templates/notfound.http
382
- - spec/files/templates/show/success.http
383
384
  - spec/files/templates/update/success.http
384
385
  - spec/files/templates_records/create/created.http
385
386
  - spec/files/templates_records/delete/success-204.http
386
387
  - spec/files/templates_records/delete/success.http
387
- - spec/files/templates_records/index/success.http
388
+ - spec/files/templates_records/get/success.http
389
+ - spec/files/templates_records/list/success.http
388
390
  - spec/files/templates_records/notfound.http
389
- - spec/files/templates_records/show/success.http
390
391
  - spec/files/templates_records/update/success.http
391
392
  - spec/files/users/user/success.http
392
393
  - spec/spec_helper.rb