dnsimple 2.0.0.alpha3 → 2.0.0.alpha4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/CHANGELOG.markdown +5 -3
  4. data/lib/dnsimple/client.rb +6 -55
  5. data/lib/dnsimple/client/{certificates_service.rb → certificates.rb} +1 -1
  6. data/lib/dnsimple/client/clients.rb +121 -0
  7. data/lib/dnsimple/client/{contacts_service.rb → contacts.rb} +1 -1
  8. data/lib/dnsimple/client/domains.rb +65 -0
  9. data/lib/dnsimple/client/domains_autorenewals.rb +35 -0
  10. data/lib/dnsimple/client/domains_forwards.rb +70 -0
  11. data/lib/dnsimple/client/domains_privacy.rb +35 -0
  12. data/lib/dnsimple/client/domains_records.rb +89 -0
  13. data/lib/dnsimple/client/domains_sharing.rb +53 -0
  14. data/lib/dnsimple/client/domains_zones.rb +22 -0
  15. data/lib/dnsimple/client/{name_servers_service.rb → name_servers.rb} +1 -1
  16. data/lib/dnsimple/client/{registrars_service.rb → registrar.rb} +1 -1
  17. data/lib/dnsimple/client/services.rb +34 -0
  18. data/lib/dnsimple/client/{services_service.rb → services_domains.rb} +1 -28
  19. data/lib/dnsimple/client/templates.rb +98 -0
  20. data/lib/dnsimple/client/{templates_service.rb → templates_records.rb} +1 -93
  21. data/lib/dnsimple/client/{users_service.rb → users.rb} +1 -1
  22. data/lib/dnsimple/version.rb +1 -1
  23. data/spec/dnsimple/client/{certificates_service_spec.rb → certificates_spec.rb} +0 -0
  24. data/spec/dnsimple/client/{contacts_service_spec.rb → contacts_spec.rb} +0 -0
  25. data/spec/dnsimple/client/domains_autorenewals_spec.rb +72 -0
  26. data/spec/dnsimple/client/domains_forwards_spec.rb +146 -0
  27. data/spec/dnsimple/client/domains_privacy_spec.rb +74 -0
  28. data/spec/dnsimple/client/domains_records_spec.rb +191 -0
  29. data/spec/dnsimple/client/domains_sharing_spec.rb +109 -0
  30. data/spec/dnsimple/client/domains_spec.rb +139 -0
  31. data/spec/dnsimple/client/domains_zones_spec.rb +40 -0
  32. data/spec/dnsimple/client/{name_servers_service_spec.rb → name_servers_spec.rb} +0 -0
  33. data/spec/dnsimple/client/{registrars_service_spec.rb → registrar_spec.rb} +9 -9
  34. data/spec/dnsimple/client/{services_service_spec.rb → services_domains_spec.rb} +1 -62
  35. data/spec/dnsimple/client/services_spec.rb +69 -0
  36. data/spec/dnsimple/client/{templates_service_spec.rb → templates_records_spec.rb} +1 -192
  37. data/spec/dnsimple/client/templates_spec.rb +198 -0
  38. data/spec/dnsimple/client/{users_service_spec.rb → users_spec.rb} +0 -0
  39. data/spec/files/{domains_whois_privacy → domains_privacy}/disable/success.http +0 -0
  40. data/spec/files/{domains_whois_privacy → domains_privacy}/enable/success.http +0 -0
  41. data/spec/files/domains_privacy/notfound-domain.http +19 -0
  42. data/spec/files/{registrars → registrar}/check/available.http +0 -0
  43. data/spec/files/{registrars → registrar}/check/registered.http +0 -0
  44. data/spec/files/{registrars → registrar}/register/badrequest-missingdomain.http +0 -0
  45. data/spec/files/{registrars → registrar}/register/badrequest-missingregistrant.http +0 -0
  46. data/spec/files/{registrars → registrar}/register/success.http +0 -0
  47. data/spec/files/{registrars → registrar}/renew/badrequest-missingrenewal.http +0 -0
  48. data/spec/files/{registrars → registrar}/renew/badrequest-unable.http +0 -0
  49. data/spec/files/{registrars → registrar}/renew/success.http +0 -0
  50. data/spec/files/{registrars → registrar}/transfer/success.http +0 -0
  51. data/spec/files/{registrars_extended_attributes → registrar_extended_attributes}/list/success.http +0 -0
  52. data/spec/files/{registrars_prices → registrar_prices}/list/success.http +0 -0
  53. data/spec/files/{subscription → subscriptions}/show/success.http +0 -0
  54. metadata +82 -56
  55. data/lib/dnsimple/client/client_service.rb +0 -8
  56. data/lib/dnsimple/client/domains_service.rb +0 -333
  57. data/spec/dnsimple/client/domains_service_spec.rb +0 -662
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59bd049e932b2627935ec1c20b461c044a469db7
4
- data.tar.gz: 339e7ddd3c26886983121c50b9f0600d4e91d458
3
+ metadata.gz: 29282f721205ff41ca5aacb60da1ea9b1034439b
4
+ data.tar.gz: a5ecddeeb95166108c8e94862797901eb8cae133
5
5
  SHA512:
6
- metadata.gz: 18d6712c612148898493bacc510a5686233407b670125cc8da40a5152b7b19dca74217b316ffd7f81a6e62ebf678f502213dcaf3887a999a96ee0fafec171337
7
- data.tar.gz: b8342199df7bee17d7483f09b9b32a22e076e694a69a12c43e06718f3392f6197bd4f06f838f67382cc911b776daa250ccc98152d7f6ab9f37ee2fcdd7e81327
6
+ metadata.gz: 31918228b994c55090c59df96764efc6c5de00b4124629f383f580740c9209a28354a35481c63aab0cf4400b2051b40f844412ee363a6a8990df6aea133ae873
7
+ data.tar.gz: 94bd0968025293dfc93acf35834ca3b119c7969bb99acf50854c7db73f8dccfa000d4cf4fde257db4d790f561a4c039e274131c6de81dae970cbc673a9139059
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 2.0.0
5
- - 2.1.0
4
+ - 2.0
5
+ - 2.1
6
+ - 2.2
6
7
  env: COVERALL=1
data/CHANGELOG.markdown CHANGED
@@ -2,9 +2,13 @@
2
2
 
3
3
  #### 2.0.0.alpha
4
4
 
5
+ 2.0 is a complete client redesign.
6
+
5
7
  - NEW: Add support changing name servers (GH-52). Thanks @rosscooperman
6
8
 
7
- - CHANGED: Drop 1.8.7 support.
9
+ - NEW: Add support for all DNSimple API methods.
10
+
11
+ - CHANGED: Drop 1.8.7, 1.9.2 support. Required Ruby >= 1.9.3.
8
12
 
9
13
  - CHANGED: This package no longer provides a CLI. The CLI has been extracted to [aetrion/dnsimple-ruby-cli](https://github.com/aetrion/dnsimple-ruby-cli)
10
14
 
@@ -12,8 +16,6 @@
12
16
 
13
17
  - CHANGED: Renamed the namespace from DNSimple to Dnsimple.
14
18
 
15
- - CHANGED: Redesigned client API.
16
-
17
19
  - REMOVED: The library no longer provides built-in support for loading the credentials from a config file.
18
20
 
19
21
  #### Release 1.7.1
@@ -1,15 +1,7 @@
1
1
  require 'dnsimple/compatibility'
2
2
  require 'dnsimple/extra'
3
3
  require 'dnsimple/struct'
4
- require 'dnsimple/client/client_service'
5
- require 'dnsimple/client/certificates_service'
6
- require 'dnsimple/client/contacts_service'
7
- require 'dnsimple/client/domains_service'
8
- require 'dnsimple/client/name_servers_service'
9
- require 'dnsimple/client/registrars_service'
10
- require 'dnsimple/client/services_service'
11
- require 'dnsimple/client/templates_service'
12
- require 'dnsimple/client/users_service'
4
+ require 'dnsimple/client/clients'
13
5
 
14
6
  module Dnsimple
15
7
 
@@ -64,7 +56,7 @@ module Dnsimple
64
56
 
65
57
  # Make a HTTP GET request.
66
58
  #
67
- # @param [String] url The path, relative to {#api_endpoint}
59
+ # @param [String] path The path, relative to {#api_endpoint}
68
60
  # @param [Hash] options Query and header params for request
69
61
  # @return [HTTParty::Response]
70
62
  def get(path, options = {})
@@ -73,7 +65,7 @@ module Dnsimple
73
65
 
74
66
  # Make a HTTP POST request.
75
67
  #
76
- # @param [String] url The path, relative to {#api_endpoint}
68
+ # @param [String] path The path, relative to {#api_endpoint}
77
69
  # @param [Hash] options Body and header params for request
78
70
  # @return [HTTParty::Response]
79
71
  def post(path, options = {})
@@ -82,7 +74,7 @@ module Dnsimple
82
74
 
83
75
  # Make a HTTP PUT request.
84
76
  #
85
- # @param [String] url The path, relative to {#api_endpoint}
77
+ # @param [String] path The path, relative to {#api_endpoint}
86
78
  # @param [Hash] options Body and header params for request
87
79
  # @return [HTTParty::Response]
88
80
  def put(path, options = {})
@@ -91,7 +83,7 @@ module Dnsimple
91
83
 
92
84
  # Make a HTTP DELETE request.
93
85
  #
94
- # @param [String] url The path, relative to {#api_endpoint}
86
+ # @param [String] path The path, relative to {#api_endpoint}
95
87
  # @param [Hash] options Query and header params for request
96
88
  # @return [HTTParty::Response]
97
89
  def delete(path, options = {})
@@ -102,7 +94,7 @@ module Dnsimple
102
94
  # Make a HTTP request.
103
95
  #
104
96
  # @param [String] method The HTTP method
105
- # @param [String] url The path, relative to {#api_endpoint}
97
+ # @param [String] path The path, relative to {#api_endpoint}
106
98
  # @param [Hash] options Query and header params for request
107
99
  # @return [HTTParty::Response]
108
100
  def request(method, path, data, options = {})
@@ -129,47 +121,6 @@ module Dnsimple
129
121
  end
130
122
 
131
123
 
132
- # @return [Dnsimple::Client::CertificatesService] The certificate-related API proxy.
133
- def certificates
134
- @services[:certificates] ||= Client::CertificatesService.new(self)
135
- end
136
-
137
- # @return [Dnsimple::Client::ContactsService] The contact-related API proxy.
138
- def contacts
139
- @services[:contacts] ||= Client::ContactsService.new(self)
140
- end
141
-
142
- # @return [Dnsimple::Client::DomainsService] The domain-related API proxy.
143
- def domains
144
- @services[:domains] ||= Client::DomainsService.new(self)
145
- end
146
-
147
- # @return [Dnsimple::Client::NameServersService] The name server-related API proxy.
148
- def name_servers
149
- @services[:name_servers] ||= Client::NameServersService.new(self)
150
- end
151
-
152
- # @return [Dnsimple::Client::RegistrarsService] The registrar-related API proxy.
153
- def registrars
154
- @services[:registrars] ||= Client::RegistrarsService.new(self)
155
- end
156
-
157
- # @return [Dnsimple::Client::ServicesService] The service-related API proxy.
158
- def services
159
- @services[:services] ||= Client::ServicesService.new(self)
160
- end
161
-
162
- # @return [Dnsimple::Client::TemplatesService] The template-related API proxy.
163
- def templates
164
- @services[:templates] ||= Client::TemplatesService.new(self)
165
- end
166
-
167
- # @return [Dnsimple::Client::UsersService] The user-related API proxy.
168
- def users
169
- @services[:users] ||= Client::UsersService.new(self)
170
- end
171
-
172
-
173
124
  # @return [String] Base URL for API requests.
174
125
  def api_endpoint
175
126
  File.join(@api_endpoint, "")
@@ -1,6 +1,6 @@
1
1
  module Dnsimple
2
2
  class Client
3
- class CertificatesService < ClientService
3
+ module Certificates
4
4
 
5
5
  # Lists the certificates for a domain.
6
6
  #
@@ -0,0 +1,121 @@
1
+ module Dnsimple
2
+ class Client
3
+
4
+ # @return [Dnsimple::Client::CertificatesService] The certificate-related API proxy.
5
+ def certificates
6
+ @services[:certificates] ||= Client::CertificatesService.new(self)
7
+ end
8
+
9
+ # @return [Dnsimple::Client::ContactsService] The contact-related API proxy.
10
+ def contacts
11
+ @services[:contacts] ||= Client::ContactsService.new(self)
12
+ end
13
+
14
+ # @return [Dnsimple::Client::DomainsService] The domain-related API proxy.
15
+ def domains
16
+ @services[:domains] ||= Client::DomainsService.new(self)
17
+ end
18
+
19
+ # @return [Dnsimple::Client::NameServersService] The name server-related API proxy.
20
+ def name_servers
21
+ @services[:name_servers] ||= Client::NameServersService.new(self)
22
+ end
23
+
24
+ # @return [Dnsimple::Client::RegistrarService] The registrar-related API proxy.
25
+ def registrar
26
+ @services[:registrar] ||= Client::RegistrarService.new(self)
27
+ end
28
+
29
+ # @return [Dnsimple::Client::ServicesService] The service-related API proxy.
30
+ def services
31
+ @services[:services] ||= Client::ServicesService.new(self)
32
+ end
33
+
34
+ # @return [Dnsimple::Client::TemplatesService] The template-related API proxy.
35
+ def templates
36
+ @services[:templates] ||= Client::TemplatesService.new(self)
37
+ end
38
+
39
+ # @return [Dnsimple::Client::UsersService] The user-related API proxy.
40
+ def users
41
+ @services[:users] ||= Client::UsersService.new(self)
42
+ end
43
+
44
+
45
+ class ClientService < ::Struct.new(:client)
46
+ end
47
+
48
+
49
+ require 'dnsimple/client/certificates'
50
+
51
+ class CertificatesService < ClientService
52
+ include Client::Certificates
53
+ end
54
+
55
+
56
+ require 'dnsimple/client/contacts'
57
+
58
+ class ContactsService < ClientService
59
+ include Client::Contacts
60
+ end
61
+
62
+
63
+ require 'dnsimple/client/domains'
64
+ require 'dnsimple/client/domains_records'
65
+ require 'dnsimple/client/domains_autorenewals'
66
+ require 'dnsimple/client/domains_privacy'
67
+ require 'dnsimple/client/domains_sharing'
68
+ require 'dnsimple/client/domains_forwards'
69
+ require 'dnsimple/client/domains_zones'
70
+
71
+ class DomainsService < ClientService
72
+ include Client::Domains
73
+ include Client::DomainsRecords
74
+ include Client::DomainsAutorenewals
75
+ include Client::DomainsPrivacy
76
+ include Client::DomainsSharing
77
+ include Client::DomainsForwards
78
+ include Client::DomainsZones
79
+ end
80
+
81
+
82
+ require 'dnsimple/client/name_servers'
83
+
84
+ class NameServersService < ClientService
85
+ include Client::NameServers
86
+ end
87
+
88
+
89
+ require 'dnsimple/client/registrar'
90
+
91
+ class RegistrarService < ClientService
92
+ include Client::Registrar
93
+ end
94
+
95
+
96
+ require 'dnsimple/client/services'
97
+ require 'dnsimple/client/services_domains'
98
+
99
+ class ServicesService < ClientService
100
+ include Client::Services
101
+ include Client::ServicesDomains
102
+ end
103
+
104
+
105
+ require 'dnsimple/client/templates'
106
+ require 'dnsimple/client/templates_records'
107
+
108
+ class TemplatesService < ClientService
109
+ include Client::Templates
110
+ include Client::TemplatesRecords
111
+ end
112
+
113
+
114
+ require 'dnsimple/client/users'
115
+
116
+ class UsersService < ClientService
117
+ include Client::Users
118
+ end
119
+
120
+ end
121
+ end
@@ -1,6 +1,6 @@
1
1
  module Dnsimple
2
2
  class Client
3
- class ContactsService < ClientService
3
+ module Contacts
4
4
 
5
5
  # Lists the contacts in the account.
6
6
  #
@@ -0,0 +1,65 @@
1
+ module Dnsimple
2
+ class Client
3
+ module Domains
4
+
5
+ # Lists the domains in the account.
6
+ #
7
+ # @see http://developer.dnsimple.com/domains/#list
8
+ #
9
+ # @return [Array<Struct::Domain>]
10
+ # @raise [RequestError] When the request fails.
11
+ def list(options = {})
12
+ response = client.get("v1/domains", options)
13
+
14
+ response.map { |r| Struct::Domain.new(r["domain"]) }
15
+ end
16
+
17
+ # Gets a domain from the account.
18
+ #
19
+ # @see http://developer.dnsimple.com/domains/#get
20
+ #
21
+ # @param [#to_s] domain The domain id or domain name.
22
+ #
23
+ # @return [Struct::Domain]
24
+ # @raise [RecordNotFound]
25
+ # @raise [RequestError] When the request fails.
26
+ def find(domain)
27
+ response = client.get("v1/domains/#{domain}")
28
+
29
+ Struct::Domain.new(response["domain"])
30
+ end
31
+
32
+ # Creates a domain in the account.
33
+ #
34
+ # @see http://developer.dnsimple.com/domains/#create
35
+ #
36
+ # @param [Hash] attributes
37
+ #
38
+ # @return [Struct::Domain]
39
+ # @raise [RequestError] When the request fails.
40
+ def create(attributes = {})
41
+ Extra.validate_mandatory_attributes(attributes, [:name])
42
+ options = { domain: attributes }
43
+ response = client.post("v1/domains", options)
44
+
45
+ Struct::Domain.new(response["domain"])
46
+ end
47
+
48
+ # Deletes a domain from the account.
49
+ #
50
+ # WARNING: this cannot be undone.
51
+ #
52
+ # @see http://developer.dnsimple.com/domains/#delete
53
+ #
54
+ # @param [#to_s] domain The domain id or domain name.
55
+ #
56
+ # @return [void]
57
+ # @raise [RecordNotFound]
58
+ # @raise [RequestError] When the request fails.
59
+ def delete(domain)
60
+ client.delete("v1/domains/#{domain}")
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,35 @@
1
+ module Dnsimple
2
+ class Client
3
+ module DomainsAutorenewals
4
+
5
+ # Enables auto-renewal for a domain.
6
+ #
7
+ # @see http://developer.dnsimple.com/domains/autorenewal/#enable
8
+ #
9
+ # @param [#to_s] domain The domain id or domain name.
10
+ #
11
+ # @return [Struct::Domain]
12
+ # @raise [RequestError] When the request fails.
13
+ def enable_auto_renewal(domain)
14
+ response = client.post("v1/domains/#{domain}/auto_renewal")
15
+
16
+ Struct::Domain.new(response["domain"])
17
+ end
18
+
19
+ # Disables auto-renewal for a domain.
20
+ #
21
+ # @see http://developer.dnsimple.com/domains/autorenewal/#disable
22
+ #
23
+ # @param [#to_s] domain The domain id or domain name.
24
+ #
25
+ # @return [Struct::Domain]
26
+ # @raise [RequestError] When the request fails.
27
+ def disable_auto_renewal(domain)
28
+ response = client.delete("v1/domains/#{domain}/auto_renewal")
29
+
30
+ Struct::Domain.new(response["domain"])
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,70 @@
1
+ module Dnsimple
2
+ class Client
3
+ module DomainsForwards
4
+
5
+ # Lists the email forwards for a domain.
6
+ #
7
+ # @see http://developer.dnsimple.com/domains/forwards/#list
8
+ #
9
+ # @param [#to_s] domain The domain id or domain name.
10
+ #
11
+ # @return [Array<Struct::EmailForward>]
12
+ # @raise [RecordNotFound]
13
+ # @raise [RequestError] When the request fails.
14
+ def list_email_forwards(domain)
15
+ response = client.get("v1/domains/#{domain}/email_forwards")
16
+
17
+ response.map { |r| Struct::EmailForward.new(r["email_forward"]) }
18
+ end
19
+
20
+ # Creates an email forward for a domain.
21
+ #
22
+ # @see http://developer.dnsimple.com/domains/forwards/#create
23
+ #
24
+ # @param [#to_s] domain The domain id or domain name.
25
+ # @param [Hash] attributes
26
+ #
27
+ # @return [Struct::EmailForward]
28
+ # @raise [RecordNotFound]
29
+ # @raise [RequestError] When the request fails.
30
+ def create_email_forward(domain, attributes = {})
31
+ Extra.validate_mandatory_attributes(attributes, [:from, :to])
32
+ options = { email_forward: attributes }
33
+ response = client.post("v1/domains/#{domain}/email_forwards", options)
34
+
35
+ Struct::EmailForward.new(response["email_forward"])
36
+ end
37
+
38
+ # Gets an email forward for a domain.
39
+ #
40
+ # @see http://developer.dnsimple.com/domains/forwards/#get
41
+ #
42
+ # @param [#to_s] domain The domain id or domain name.
43
+ # @param [Fixnum] forward The forward id.
44
+ #
45
+ # @return [Struct::EmailForward]
46
+ # @raise [RecordNotFound]
47
+ # @raise [RequestError] When the request fails.
48
+ def find_email_forward(domain, forward)
49
+ response = client.get("v1/domains/#{domain}/email_forwards/#{forward}")
50
+
51
+ Struct::EmailForward.new(response["email_forward"])
52
+ end
53
+
54
+ # Deletes an email forward for a domain.
55
+ #
56
+ # @see http://developer.dnsimple.com/domains/forwards/#delete
57
+ #
58
+ # @param [#to_s] domain The domain id or domain name.
59
+ # @param [Fixnum] forward The forward id.
60
+ #
61
+ # @return [void]
62
+ # @raise [RecordNotFound]
63
+ # @raise [RequestError] When the request fails.
64
+ def delete_email_forward(domain, forward)
65
+ client.delete("v1/domains/#{domain}/email_forwards/#{forward}")
66
+ end
67
+
68
+ end
69
+ end
70
+ end