dnsimple 2.0.0.alpha3 → 2.0.0.alpha4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,35 @@
1
+ module Dnsimple
2
+ class Client
3
+ module DomainsPrivacy
4
+
5
+ # Enables WHOIS privacy for a domain.
6
+ #
7
+ # @see http://developer.dnsimple.com/domains/privacy/#enable
8
+ #
9
+ # @param [#to_s] domain The domain id or domain name.
10
+ #
11
+ # @return [Struct::WhoisPrivacy]
12
+ # @raise [RequestError] When the request fails.
13
+ def enable_whois_privacy(domain)
14
+ response = client.post("v1/domains/#{domain}/whois_privacy")
15
+
16
+ Struct::WhoisPrivacy.new(response["whois_privacy"])
17
+ end
18
+
19
+ # Disables WHOIS privacy for a domain.
20
+ #
21
+ # @see http://developer.dnsimple.com/domains/privacy/#disable
22
+ #
23
+ # @param [#to_s] domain The domain id or domain name.
24
+ #
25
+ # @return [Struct::WhoisPrivacy]
26
+ # @raise [RequestError] When the request fails.
27
+ def disable_whois_privacy(domain)
28
+ response = client.delete("v1/domains/#{domain}/whois_privacy")
29
+
30
+ Struct::WhoisPrivacy.new(response["whois_privacy"])
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,89 @@
1
+ module Dnsimple
2
+ class Client
3
+ module DomainsRecords
4
+
5
+ # Lists the records for a domain.
6
+ #
7
+ # @see http://developer.dnsimple.com/domains/records/#list
8
+ #
9
+ # @param [#to_s] domain The domain id or domain name.
10
+ # @param [Hash] options
11
+ #
12
+ # @return [Array<Struct::Record>]
13
+ # @raise [RecordNotFound]
14
+ # @raise [RequestError] When the request fails.
15
+ def list_records(domain, options = {})
16
+ response = client.get("v1/domains/#{domain}/records", options)
17
+
18
+ response.map { |r| Struct::Record.new(r["record"]) }
19
+ end
20
+
21
+ # Creates a record for a domain.
22
+ #
23
+ # @see http://developer.dnsimple.com/domains/records/#create
24
+ #
25
+ # @param [#to_s] domain The domain id or domain name.
26
+ # @param [Hash] attributes
27
+ #
28
+ # @return [Struct::Record]
29
+ # @raise [RecordNotFound]
30
+ # @raise [RequestError] When the request fails.
31
+ def create_record(domain, attributes = {})
32
+ Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content])
33
+ options = { record: attributes }
34
+ response = client.post("v1/domains/#{domain}/records", options)
35
+
36
+ Struct::Record.new(response["record"])
37
+ end
38
+
39
+ # Gets a record for a domain.
40
+ #
41
+ # @see http://developer.dnsimple.com/domains/records/#get
42
+ #
43
+ # @param [#to_s] domain The domain id or domain name.
44
+ # @param [Fixnum] record The record id.
45
+ #
46
+ # @return [Struct::Record]
47
+ # @raise [RecordNotFound]
48
+ # @raise [RequestError] When the request fails.
49
+ def find_record(domain, record)
50
+ response = client.get("v1/domains/#{domain}/records/#{record}")
51
+
52
+ Struct::Record.new(response["record"])
53
+ end
54
+
55
+ # Updates a record for a domain.
56
+ #
57
+ # @see http://developer.dnsimple.com/domains/records/#update
58
+ #
59
+ # @param [#to_s] domain The domain id or domain name.
60
+ # @param [Fixnum] record The record id.
61
+ # @param [Hash] attributes
62
+ #
63
+ # @return [Struct::Record]
64
+ # @raise [RecordNotFound]
65
+ # @raise [RequestError] When the request fails.
66
+ def update_record(domain, record, attributes = {})
67
+ options = { record: attributes }
68
+ response = client.put("v1/domains/#{domain}/records/#{record}", options)
69
+
70
+ Struct::Record.new(response["record"])
71
+ end
72
+
73
+ # Deletes a record for a domain.
74
+ #
75
+ # @see http://developer.dnsimple.com/domains/records/#delete
76
+ #
77
+ # @param [#to_s] domain The domain id or domain name.
78
+ # @param [Fixnum] record The record id.
79
+ #
80
+ # @return [void]
81
+ # @raise [RecordNotFound]
82
+ # @raise [RequestError] When the request fails.
83
+ def delete_record(domain, record)
84
+ client.delete("v1/domains/#{domain}/records/#{record}")
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,53 @@
1
+ module Dnsimple
2
+ class Client
3
+ module DomainsSharing
4
+
5
+ # Lists the memberships.
6
+ #
7
+ # @see http://developer.dnsimple.com/domains/sharing/#list
8
+ #
9
+ # @param [#to_s] domain The domain id or domain name.
10
+ #
11
+ # @return [Array<Struct::Membership>]
12
+ # @raise [RecordNotFound]
13
+ # @raise [RequestError] When the request fails.
14
+ def list_memberships(domain)
15
+ response = client.get("v1/domains/#{domain}/memberships")
16
+
17
+ response.map { |r| Struct::Membership.new(r["membership"]) }
18
+ end
19
+
20
+ # Shares a domain.
21
+ #
22
+ # @see http://developer.dnsimple.com/domains/sharing/#create
23
+ #
24
+ # @param [#to_s] domain The domain id or domain name.
25
+ # @param [String] email
26
+ #
27
+ # @return [Struct::Membership]
28
+ # @raise [RecordNotFound]
29
+ # @raise [RequestError] When the request fails.
30
+ def create_membership(domain, email)
31
+ options = { membership: { email: email }}
32
+ response = client.post("v1/domains/#{domain}/memberships", options)
33
+
34
+ Struct::Membership.new(response["membership"])
35
+ end
36
+
37
+ # Un-shares a domain.
38
+ #
39
+ # @see http://developer.dnsimple.com/domains/sharing/#delete
40
+ #
41
+ # @param [#to_s] domain The domain id or domain name.
42
+ # @param [Fixnum] membership The membership id.
43
+ #
44
+ # @return [void]
45
+ # @raise [RecordNotFound]
46
+ # @raise [RequestError] When the request fails.
47
+ def delete_membership(domain, membership)
48
+ client.delete("v1/domains/#{domain}/memberships/#{membership}")
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,22 @@
1
+ module Dnsimple
2
+ class Client
3
+ module DomainsZones
4
+
5
+ # Gets a domain zone as zone file.
6
+ #
7
+ # @see http://developer.dnsimple.com/domains/zones/#get
8
+ #
9
+ # @param [#to_s] domain The domain id or domain name.
10
+ #
11
+ # @return [String]
12
+ # @raise [RecordNotFound]
13
+ # @raise [RequestError] When the request fails.
14
+ def zone(domain)
15
+ response = client.get("v1/domains/#{domain}/zone")
16
+
17
+ response["zone"]
18
+ end
19
+
20
+ end
21
+ end
22
+ end
@@ -1,6 +1,6 @@
1
1
  module Dnsimple
2
2
  class Client
3
- class NameServersService < ClientService
3
+ module NameServers
4
4
 
5
5
  # Lists the name servers for a domain.
6
6
  #
@@ -1,6 +1,6 @@
1
1
  module Dnsimple
2
2
  class Client
3
- class RegistrarsService < ClientService
3
+ module Registrar
4
4
 
5
5
  # Checks the availability of a domain name.
6
6
  #
@@ -0,0 +1,34 @@
1
+ module Dnsimple
2
+ class Client
3
+ module Services
4
+
5
+ # Lists the supported services.
6
+ #
7
+ # @see http://developer.dnsimple.com/services/#list
8
+ #
9
+ # @return [Array<Struct::Service>]
10
+ # @raise [RequestError] When the request fails.
11
+ def list
12
+ response = client.get("v1/services")
13
+
14
+ response.map { |r| Struct::Service.new(r["service"]) }
15
+ end
16
+
17
+ # Gets a service.
18
+ #
19
+ # @see http://developer.dnsimple.com/services/#get
20
+ #
21
+ # @param [Fixnum] service The service id.
22
+ #
23
+ # @return [Struct::Service]
24
+ # @raise [RecordNotFound]
25
+ # @raise [RequestError] When the request fails.
26
+ def find(service)
27
+ response = client.get("v1/services/#{service}")
28
+
29
+ Struct::Service.new(response["service"])
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -1,33 +1,6 @@
1
1
  module Dnsimple
2
2
  class Client
3
- class ServicesService < ClientService
4
-
5
- # Lists the supported services.
6
- #
7
- # @see http://developer.dnsimple.com/services/#list
8
- #
9
- # @return [Array<Struct::Service>]
10
- # @raise [RequestError] When the request fails.
11
- def list
12
- response = client.get("v1/services")
13
-
14
- response.map { |r| Struct::Service.new(r["service"]) }
15
- end
16
-
17
- # Gets a service.
18
- #
19
- # @see http://developer.dnsimple.com/services/#get
20
- #
21
- # @param [Fixnum] service The service id.
22
- #
23
- # @return [Struct::Service]
24
- # @raise [RecordNotFound]
25
- # @raise [RequestError] When the request fails.
26
- def find(service)
27
- response = client.get("v1/services/#{service}")
28
-
29
- Struct::Service.new(response["service"])
30
- end
3
+ module ServicesDomains
31
4
 
32
5
  # Lists the services applied to a domain.
33
6
  #
@@ -0,0 +1,98 @@
1
+ module Dnsimple
2
+ class Client
3
+ module Templates
4
+
5
+ # Lists the templates in the account.
6
+ #
7
+ # @see http://developer.dnsimple.com/templates/#list
8
+ #
9
+ # @return [Array<Struct::Template>]
10
+ # @raise [RequestError] When the request fails.
11
+ def list
12
+ response = client.get("v1/templates")
13
+
14
+ response.map { |r| Struct::Template.new(r["dns_template"]) }
15
+ end
16
+
17
+ # Creates a template in the account.
18
+ #
19
+ # @see http://developer.dnsimple.com/templates/#create
20
+ #
21
+ # @param [Hash] attributes
22
+ #
23
+ # @return [Struct::Template]
24
+ # @raise [RequestError] When the request fails.
25
+ def create(attributes = {})
26
+ Extra.validate_mandatory_attributes(attributes, [:name, :short_name])
27
+ options = { dns_template: attributes }
28
+ response = client.post("v1/templates", options)
29
+
30
+ Struct::Template.new(response["dns_template"])
31
+ end
32
+
33
+ # Gets a template from the account.
34
+ #
35
+ # @see http://developer.dnsimple.com/templates/#get
36
+ #
37
+ # @param [#to_s] template The template id or short-name.
38
+ #
39
+ # @return [Struct::Template]
40
+ # @raise [RecordNotFound]
41
+ # @raise [RequestError] When the request fails.
42
+ def find(template)
43
+ response = client.get("v1/templates/#{template}")
44
+
45
+ Struct::Template.new(response["dns_template"])
46
+ end
47
+
48
+ # Updates a template in the account.
49
+ #
50
+ # @see http://developer.dnsimple.com/templates/#update
51
+ #
52
+ # @param [#to_s] template The template id or short-name.
53
+ # @param [Hash] attributes
54
+ #
55
+ # @return [Struct::Template]
56
+ # @raise [RecordNotFound]
57
+ # @raise [RequestError] When the request fails.
58
+ def update(template, attributes = {})
59
+ options = { dns_template: attributes }
60
+ response = client.put("v1/templates/#{template}", options)
61
+
62
+ Struct::Template.new(response["dns_template"])
63
+ end
64
+
65
+ # Deletes a template from the account.
66
+ #
67
+ # WARNING: this cannot be undone.
68
+ #
69
+ # @see http://developer.dnsimple.com/templates/#delete
70
+ #
71
+ # @param [#to_s] template The template id or short-name.
72
+ #
73
+ # @return [void]
74
+ # @raise [RecordNotFound]
75
+ # @raise [RequestError] When the request fails.
76
+ def delete(template)
77
+ client.delete("v1/templates/#{template}")
78
+ end
79
+
80
+
81
+ # Applies the template to the domain.
82
+ #
83
+ # @see http://developer.dnsimple.com/templates/#apply
84
+ #
85
+ # @param [#to_s] domain The domain id or domain name.
86
+ # @param [#to_s] template The template id or short-name.
87
+ #
88
+ # @return [void]
89
+ # @raise [RecordNotFound]
90
+ # @raise [RequestError] When the request fails.
91
+ def apply(domain, template)
92
+ response = client.post("v1/domains/#{domain}/templates/#{template}/apply")
93
+ response.code == 200
94
+ end
95
+
96
+ end
97
+ end
98
+ end
@@ -1,98 +1,6 @@
1
1
  module Dnsimple
2
2
  class Client
3
- class TemplatesService < ClientService
4
-
5
- # Lists the templates in the account.
6
- #
7
- # @see http://developer.dnsimple.com/templates/#list
8
- #
9
- # @return [Array<Struct::Template>]
10
- # @raise [RequestError] When the request fails.
11
- def list
12
- response = client.get("v1/templates")
13
-
14
- response.map { |r| Struct::Template.new(r["dns_template"]) }
15
- end
16
-
17
- # Creates a template in the account.
18
- #
19
- # @see http://developer.dnsimple.com/templates/#create
20
- #
21
- # @param [Hash] attributes
22
- #
23
- # @return [Struct::Template]
24
- # @raise [RequestError] When the request fails.
25
- def create(attributes = {})
26
- Extra.validate_mandatory_attributes(attributes, [:name, :short_name])
27
- options = { dns_template: attributes }
28
- response = client.post("v1/templates", options)
29
-
30
- Struct::Template.new(response["dns_template"])
31
- end
32
-
33
- # Gets a template from the account.
34
- #
35
- # @see http://developer.dnsimple.com/templates/#get
36
- #
37
- # @param [#to_s] template The template id or short-name.
38
- #
39
- # @return [Struct::Template]
40
- # @raise [RecordNotFound]
41
- # @raise [RequestError] When the request fails.
42
- def find(template)
43
- response = client.get("v1/templates/#{template}")
44
-
45
- Struct::Template.new(response["dns_template"])
46
- end
47
-
48
- # Updates a template in the account.
49
- #
50
- # @see http://developer.dnsimple.com/templates/#update
51
- #
52
- # @param [#to_s] template The template id or short-name.
53
- # @param [Hash] attributes
54
- #
55
- # @return [Struct::Template]
56
- # @raise [RecordNotFound]
57
- # @raise [RequestError] When the request fails.
58
- def update(template, attributes = {})
59
- options = { dns_template: attributes }
60
- response = client.put("v1/templates/#{template}", options)
61
-
62
- Struct::Template.new(response["dns_template"])
63
- end
64
-
65
- # Deletes a template from the account.
66
- #
67
- # WARNING: this cannot be undone.
68
- #
69
- # @see http://developer.dnsimple.com/templates/#delete
70
- #
71
- # @param [#to_s] template The template id or short-name.
72
- #
73
- # @return [void]
74
- # @raise [RecordNotFound]
75
- # @raise [RequestError] When the request fails.
76
- def delete(template)
77
- client.delete("v1/templates/#{template}")
78
- end
79
-
80
-
81
- # Applies the template to the domain.
82
- #
83
- # @see http://developer.dnsimple.com/templates/#apply
84
- #
85
- # @param [#to_s] domain The domain id or domain name.
86
- # @param [#to_s] template The template id or short-name.
87
- #
88
- # @return [void]
89
- # @raise [RecordNotFound]
90
- # @raise [RequestError] When the request fails.
91
- def apply(domain, template)
92
- response = client.post("v1/domains/#{domain}/templates/#{template}/apply")
93
- response.code == 200
94
- end
95
-
3
+ module TemplatesRecords
96
4
 
97
5
  # Lists the records for a template.
98
6
  #