dnsimple 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.markdown +5 -2
  3. data/dnsimple.gemspec +1 -1
  4. data/lib/dnsimple/client/certificates.rb +11 -11
  5. data/lib/dnsimple/client/clients.rb +4 -2
  6. data/lib/dnsimple/client/contacts.rb +19 -15
  7. data/lib/dnsimple/client/domains.rb +23 -19
  8. data/lib/dnsimple/client/{domains_autorenewals.rb → domains_autorenewal.rb} +7 -7
  9. data/lib/dnsimple/client/domains_forwards.rb +13 -12
  10. data/lib/dnsimple/client/domains_privacy.rb +6 -6
  11. data/lib/dnsimple/client/domains_records.rb +14 -13
  12. data/lib/dnsimple/client/domains_sharing.rb +10 -9
  13. data/lib/dnsimple/client/domains_zones.rb +3 -3
  14. data/lib/dnsimple/client/name_servers.rb +14 -14
  15. data/lib/dnsimple/client/registrar.rb +17 -15
  16. data/lib/dnsimple/client/services.rb +7 -6
  17. data/lib/dnsimple/client/services_domains.rb +12 -12
  18. data/lib/dnsimple/client/templates.rb +18 -30
  19. data/lib/dnsimple/client/templates_domains.rb +23 -0
  20. data/lib/dnsimple/client/templates_records.rb +15 -15
  21. data/lib/dnsimple/client/users.rb +7 -5
  22. data/lib/dnsimple/version.rb +1 -1
  23. data/spec/dnsimple/client/certificates_spec.rb +2 -2
  24. data/spec/dnsimple/client/contacts_spec.rb +22 -22
  25. data/spec/dnsimple/client/domains_autorenewals_spec.rb +4 -4
  26. data/spec/dnsimple/client/domains_forwards_spec.rb +8 -8
  27. data/spec/dnsimple/client/domains_privacy_spec.rb +4 -4
  28. data/spec/dnsimple/client/domains_records_spec.rb +11 -11
  29. data/spec/dnsimple/client/domains_sharing_spec.rb +6 -6
  30. data/spec/dnsimple/client/domains_spec.rb +15 -15
  31. data/spec/dnsimple/client/domains_zones_spec.rb +2 -2
  32. data/spec/dnsimple/client/name_servers_spec.rb +1 -1
  33. data/spec/dnsimple/client/registrar_spec.rb +9 -9
  34. data/spec/dnsimple/client/services_spec.rb +3 -3
  35. data/spec/dnsimple/client/templates_domains_spec.rb +38 -0
  36. data/spec/dnsimple/client/templates_records_spec.rb +10 -10
  37. data/spec/dnsimple/client/templates_spec.rb +21 -53
  38. data/spec/files/contacts/{get → contact}/success.http +0 -0
  39. data/spec/files/contacts/{list → contacts}/success.http +0 -0
  40. data/spec/files/contacts/{create → create_contact}/badrequest-missingcontact.http +0 -0
  41. data/spec/files/contacts/{create → create_contact}/badrequest-validationerror.http +0 -0
  42. data/spec/files/contacts/{create → create_contact}/created.http +0 -0
  43. data/spec/files/contacts/{delete → delete_contact}/success-204.http +0 -0
  44. data/spec/files/contacts/{delete → delete_contact}/success.http +0 -0
  45. data/spec/files/contacts/{notfound.http → notfound-contact.http} +0 -0
  46. data/spec/files/contacts/{update → update_contact}/success.http +0 -0
  47. data/spec/files/domains/{create → create_domain}/created.http +0 -0
  48. data/spec/files/{domains_forwards/create → domains/create_forward}/created.http +0 -0
  49. data/spec/files/{domains_sharing/create → domains/create_membership}/success.http +0 -0
  50. data/spec/files/{domains_records/create → domains/create_record}/created.http +0 -0
  51. data/spec/files/domains/{delete → delete_domain}/success-204.http +0 -0
  52. data/spec/files/domains/{delete → delete_domain}/success.http +0 -0
  53. data/spec/files/{domains_forwards/delete → domains/delete_forward}/success.http +0 -0
  54. data/spec/files/{domains_sharing/delete → domains/delete_membership}/success.http +0 -0
  55. data/spec/files/{domains_records/delete → domains/delete_record}/success-204.http +0 -0
  56. data/spec/files/{domains_records/delete → domains/delete_record}/success.http +0 -0
  57. data/spec/files/{domains_autorenewal/disable → domains/disable_auto_renewal}/success.http +0 -0
  58. data/spec/files/{domains_privacy/disable → domains/disable_whois_privacy}/success.http +0 -0
  59. data/spec/files/domains/{get → domain}/success.http +0 -0
  60. data/spec/files/domains/{list → domains}/success.http +0 -0
  61. data/spec/files/{domains_autorenewal/enable → domains/enable_auto_renewal}/success.http +0 -0
  62. data/spec/files/{domains_privacy/enable → domains/enable_whois_privacy}/success.http +0 -0
  63. data/spec/files/{domains_forwards/get → domains/forward}/success.http +0 -0
  64. data/spec/files/{domains_forwards/list → domains/forwards}/success.http +0 -0
  65. data/spec/files/{domains_sharing/list → domains/memberships}/success.http +0 -0
  66. data/spec/files/domains/{notfound.http → notfound-domain.http} +0 -0
  67. data/spec/files/{domains_forwards/notfound.http → domains/notfound-forward.http} +0 -0
  68. data/spec/files/{domains_sharing/notfound.http → domains/notfound-membership.http} +0 -0
  69. data/spec/files/{domains_records/get → domains/record}/success.http +0 -0
  70. data/spec/files/{domains_records/list → domains/records}/success.http +0 -0
  71. data/spec/files/{domains_records/update → domains/update_record}/success.http +0 -0
  72. data/spec/files/{domains_zones/get → domains/zone}/success.http +0 -0
  73. data/spec/files/nameservers/{list → name_servers}/success.http +0 -0
  74. data/spec/files/{registrar_extended_attributes/list → registrar/extended_attributes}/success.http +0 -0
  75. data/spec/files/{registrar_prices/list → registrar/prices}/success.http +0 -0
  76. data/spec/files/services/{notfound.http → notfound-service.http} +0 -0
  77. data/spec/files/services/{get → service}/success.http +0 -0
  78. data/spec/files/services/{list → services}/success.http +0 -0
  79. data/spec/files/subscriptions/{get → subscription}/success.http +0 -0
  80. data/spec/files/templates/{apply → apply_template}/success.http +0 -0
  81. data/spec/files/templates/{create → create_template}/created.http +0 -0
  82. data/spec/files/templates/{delete → delete_template}/success-204.http +0 -0
  83. data/spec/files/templates/{delete → delete_template}/success.http +0 -0
  84. data/spec/files/templates/{notfound.http → notfound-template.http} +0 -0
  85. data/spec/files/templates/{get → template}/success.http +0 -0
  86. data/spec/files/templates/{list → templates}/success.http +0 -0
  87. data/spec/files/templates/{update → update_template}/success.http +0 -0
  88. data/spec/files/templates_records/{create → create_record}/created.http +0 -0
  89. data/spec/files/templates_records/{delete → delete_record}/success-204.http +0 -0
  90. data/spec/files/templates_records/{delete → delete_record}/success.http +0 -0
  91. data/spec/files/templates_records/{notfound.http → notfound-template-record.http} +0 -0
  92. data/spec/files/templates_records/{get → record}/success.http +0 -0
  93. data/spec/files/templates_records/{list → records}/success.http +0 -0
  94. data/spec/files/templates_records/{update → update_record}/success.http +0 -0
  95. metadata +121 -130
  96. data/spec/files/domains_autorenewal/notfound-domain.http +0 -19
  97. data/spec/files/domains_forwards/notfound-domain.http +0 -19
  98. data/spec/files/domains_privacy/notfound-domain.http +0 -19
  99. data/spec/files/domains_records/notfound.http +0 -17
  100. data/spec/files/domains_sharing/notfound-domain.http +0 -19
  101. data/spec/files/domains_zones/notfound-domain.http +0 -19
@@ -8,8 +8,8 @@ module Dnsimple
8
8
  #
9
9
  # @param [#to_s] domain The domain id or domain name.
10
10
  # @param [Hash] options
11
- #
12
11
  # @return [Array<Struct::Record>]
12
+ #
13
13
  # @raise [NotFoundError]
14
14
  # @raise [RequestError] When the request fails.
15
15
  def records(domain, options = {})
@@ -17,6 +17,7 @@ module Dnsimple
17
17
 
18
18
  response.map { |r| Struct::Record.new(r["record"]) }
19
19
  end
20
+ alias :list_record :records
20
21
 
21
22
  # Creates a record for a domain.
22
23
  #
@@ -24,13 +25,13 @@ module Dnsimple
24
25
  #
25
26
  # @param [#to_s] domain The domain id or domain name.
26
27
  # @param [Hash] attributes
27
- #
28
28
  # @return [Struct::Record]
29
+ #
29
30
  # @raise [NotFoundError]
30
31
  # @raise [RequestError] When the request fails.
31
- def create_record(domain, attributes = {})
32
+ def create_record(domain, attributes = {}, options = {})
32
33
  Extra.validate_mandatory_attributes(attributes, [:name, :record_type, :content])
33
- options = { record: attributes }
34
+ options = options.merge({ record: attributes })
34
35
  response = client.post("v1/domains/#{domain}/records", options)
35
36
 
36
37
  Struct::Record.new(response["record"])
@@ -42,12 +43,12 @@ module Dnsimple
42
43
  #
43
44
  # @param [#to_s] domain The domain id or domain name.
44
45
  # @param [Fixnum] record The record id.
45
- #
46
46
  # @return [Struct::Record]
47
+ #
47
48
  # @raise [NotFoundError]
48
49
  # @raise [RequestError] When the request fails.
49
- def record(domain, record)
50
- response = client.get("v1/domains/#{domain}/records/#{record}")
50
+ def record(domain, record, options = {})
51
+ response = client.get("v1/domains/#{domain}/records/#{record}", options)
51
52
 
52
53
  Struct::Record.new(response["record"])
53
54
  end
@@ -59,12 +60,12 @@ module Dnsimple
59
60
  # @param [#to_s] domain The domain id or domain name.
60
61
  # @param [Fixnum] record The record id.
61
62
  # @param [Hash] attributes
62
- #
63
63
  # @return [Struct::Record]
64
+ #
64
65
  # @raise [NotFoundError]
65
66
  # @raise [RequestError] When the request fails.
66
- def update_record(domain, record, attributes = {})
67
- options = { record: attributes }
67
+ def update_record(domain, record, attributes = {}, options = {})
68
+ options = options.merge({ record: attributes })
68
69
  response = client.put("v1/domains/#{domain}/records/#{record}", options)
69
70
 
70
71
  Struct::Record.new(response["record"])
@@ -76,12 +77,12 @@ module Dnsimple
76
77
  #
77
78
  # @param [#to_s] domain The domain id or domain name.
78
79
  # @param [Fixnum] record The record id.
79
- #
80
80
  # @return [void]
81
+ #
81
82
  # @raise [NotFoundError]
82
83
  # @raise [RequestError] When the request fails.
83
- def delete_record(domain, record)
84
- client.delete("v1/domains/#{domain}/records/#{record}")
84
+ def delete_record(domain, record, options = {})
85
+ client.delete("v1/domains/#{domain}/records/#{record}", options)
85
86
  end
86
87
 
87
88
  end
@@ -7,15 +7,16 @@ module Dnsimple
7
7
  # @see http://developer.dnsimple.com/domains/sharing/#list
8
8
  #
9
9
  # @param [#to_s] domain The domain id or domain name.
10
- #
11
10
  # @return [Array<Struct::Membership>]
11
+ #
12
12
  # @raise [NotFoundError]
13
13
  # @raise [RequestError] When the request fails.
14
- def memberships(domain)
15
- response = client.get("v1/domains/#{domain}/memberships")
14
+ def memberships(domain, options = {})
15
+ response = client.get("v1/domains/#{domain}/memberships", options)
16
16
 
17
17
  response.map { |r| Struct::Membership.new(r["membership"]) }
18
18
  end
19
+ alias :list_memberships :memberships
19
20
 
20
21
  # Shares a domain.
21
22
  #
@@ -23,12 +24,12 @@ module Dnsimple
23
24
  #
24
25
  # @param [#to_s] domain The domain id or domain name.
25
26
  # @param [String] email
26
- #
27
27
  # @return [Struct::Membership]
28
+ #
28
29
  # @raise [NotFoundError]
29
30
  # @raise [RequestError] When the request fails.
30
- def create_membership(domain, email)
31
- options = { membership: { email: email }}
31
+ def create_membership(domain, email, options = {})
32
+ options = options.merge({ membership: { email: email }})
32
33
  response = client.post("v1/domains/#{domain}/memberships", options)
33
34
 
34
35
  Struct::Membership.new(response["membership"])
@@ -40,12 +41,12 @@ module Dnsimple
40
41
  #
41
42
  # @param [#to_s] domain The domain id or domain name.
42
43
  # @param [Fixnum] membership The membership id.
43
- #
44
44
  # @return [void]
45
+ #
45
46
  # @raise [NotFoundError]
46
47
  # @raise [RequestError] When the request fails.
47
- def delete_membership(domain, membership)
48
- client.delete("v1/domains/#{domain}/memberships/#{membership}")
48
+ def delete_membership(domain, membership, options = {})
49
+ client.delete("v1/domains/#{domain}/memberships/#{membership}", options)
49
50
  end
50
51
 
51
52
  end
@@ -7,12 +7,12 @@ module Dnsimple
7
7
  # @see http://developer.dnsimple.com/domains/zones/#get
8
8
  #
9
9
  # @param [#to_s] domain The domain id or domain name.
10
- #
11
10
  # @return [String]
11
+ #
12
12
  # @raise [NotFoundError]
13
13
  # @raise [RequestError] When the request fails.
14
- def zone(domain)
15
- response = client.get("v1/domains/#{domain}/zone")
14
+ def zone(domain, options = {})
15
+ response = client.get("v1/domains/#{domain}/zone", options)
16
16
 
17
17
  response["zone"]
18
18
  end
@@ -7,17 +7,17 @@ module Dnsimple
7
7
  # @see http://developer.dnsimple.com/domains/nameservers/#list
8
8
  #
9
9
  # @param [#to_s] domain The domain id or domain name.
10
- #
11
10
  # @return [Array<String>] The delegates name servers.
11
+ #
12
12
  # @raise [NotFoundError]
13
13
  # @raise [RequestError] When the request fails.
14
- def name_servers(domain)
15
- response = client.get("v1/domains/#{domain}/name_servers")
14
+ def name_servers(domain, options = {})
15
+ response = client.get("v1/domains/#{domain}/name_servers", options)
16
16
 
17
17
  response.parsed_response
18
18
  end
19
-
20
19
  alias :list :name_servers
20
+ alias :list_name_servers :name_servers
21
21
 
22
22
  # Changes the name servers for a domain.
23
23
  #
@@ -25,13 +25,13 @@ module Dnsimple
25
25
  #
26
26
  # @param [#to_s] domain The domain id or domain name.
27
27
  # @param [Array<String>] servers The name server list.
28
- #
29
28
  # @return [Array<String>] The delegates name servers.
29
+ #
30
30
  # @raise [NotFoundError]
31
31
  # @raise [RequestError] When the request fails.
32
- def change(domain, servers)
33
- servers = servers.inject({}) { |hash, server| hash.merge("ns#{hash.length + 1}" => server) }
34
- options = { name_servers: servers }
32
+ def change(domain, servers, options = {})
33
+ servers = servers.inject({}) { |hash, server| hash.merge("ns#{hash.length + 1}" => server) }
34
+ options = options.merge({ name_servers: servers })
35
35
  response = client.post("v1/domains/#{domain}/name_servers", options)
36
36
 
37
37
  response.parsed_response
@@ -45,11 +45,11 @@ module Dnsimple
45
45
  # @param [#to_s] domain The domain id or domain name.
46
46
  # @param [String] name The hostname to register.
47
47
  # @param [String] ip The hostname IP address.
48
- #
49
48
  # @return [void]
49
+ #
50
50
  # @raise [RequestError] When the request fails.
51
- def register(domain, name, ip)
52
- options = { name_server: { name: name, ip: ip } }
51
+ def register(domain, name, ip, options = {})
52
+ options = options.merge({ name_server: { name: name, ip: ip } })
53
53
  client.post("v1/domains/#{domain}/registry_name_servers", options)
54
54
  end
55
55
 
@@ -59,11 +59,11 @@ module Dnsimple
59
59
  #
60
60
  # @param [#to_s] domain The domain id or domain name.
61
61
  # @param [String] name The hostname to register.
62
- #
63
62
  # @return [void]
63
+ #
64
64
  # @raise [RequestError] When the request fails.
65
- def deregister(domain, name)
66
- client.delete("v1/domains/#{domain}/registry_name_servers/#{name}")
65
+ def deregister(domain, name, options = {})
66
+ client.delete("v1/domains/#{domain}/registry_name_servers/#{name}", options)
67
67
  end
68
68
 
69
69
  end
@@ -7,12 +7,12 @@ module Dnsimple
7
7
  # @see http://developer.dnsimple.com/domains/registry/#check
8
8
  #
9
9
  # @param [#to_s] name The domain name to check.
10
- #
11
10
  # @return [Hash] The response containing the status, price, and more details.
11
+ #
12
12
  # @raise [RequestError] When the request fails.
13
- def check(name)
13
+ def check(name, options = {})
14
14
  response = begin
15
- client.get("v1/domains/#{name}/check")
15
+ client.get("v1/domains/#{name}/check", options)
16
16
  rescue NotFoundError => e
17
17
  e.response
18
18
  end
@@ -25,11 +25,11 @@ module Dnsimple
25
25
  # @see http://developer.dnsimple.com/domains/registry/#check
26
26
  #
27
27
  # @param [#to_s] name The domain name to check.
28
- #
29
28
  # @return [Boolean] true if the domain is available
29
+ #
30
30
  # @raise [RequestError] When the request fails.
31
- def available?(name)
32
- check(name)["status"] == "available"
31
+ def available?(name, options = {})
32
+ check(name, options)["status"] == "available"
33
33
  end
34
34
 
35
35
  # Registers a domain.
@@ -40,8 +40,8 @@ module Dnsimple
40
40
  # @param [Fixnum] registrant_id The id of the contact to use as registrant.
41
41
  # @param [Hash] extended_attributes
42
42
  # @param [Hash] options
43
- #
44
43
  # @return [Struct::Domain]
44
+ #
45
45
  # @raise [RequestError] When the request fails.
46
46
  def register(name, registrant_id, extended_attributes = {}, options = {})
47
47
  options = Extra.deep_merge(options, { domain: { name: name, registrant_id: registrant_id }, extended_attribute: extended_attributes })
@@ -59,8 +59,8 @@ module Dnsimple
59
59
  # @param [Fixnum] registrant_id The id of the contact to use as registrant.
60
60
  # @param [Hash] extended_attributes
61
61
  # @param [Hash] options
62
- #
63
62
  # @return [Struct::TransferOrder]
63
+ #
64
64
  # @raise [RequestError] When the request fails.
65
65
  def transfer(name, auth_code, registrant_id, extended_attributes = {}, options = {})
66
66
  options = Extra.deep_merge(options, { domain: { name: name, registrant_id: registrant_id }, extended_attribute: extended_attributes, transfer_order: { authinfo: auth_code }})
@@ -75,8 +75,8 @@ module Dnsimple
75
75
  #
76
76
  # @param [#to_s] name The domain name to renew.
77
77
  # @param [Hash] options
78
- #
79
78
  # @return [Struct::Domain]
79
+ #
80
80
  # @raise [RequestError] When the request fails.
81
81
  def renew(name, options = {})
82
82
  options = Extra.deep_merge(options, { domain: { name: name }})
@@ -91,27 +91,29 @@ module Dnsimple
91
91
  # @see http://developer.dnsimple.com/registrar/extended-attributes/#list
92
92
  #
93
93
  # @param [#to_s] tld The TLD name.
94
- #
95
94
  # @return [Array<Struct::ExtendedAttribute>]
95
+ #
96
96
  # @raise [RequestError] When the request fails.
97
- def list_extended_attributes(tld)
98
- response = client.get("v1/extended_attributes/#{tld}")
97
+ def extended_attributes(tld, options = {})
98
+ response = client.get("v1/extended_attributes/#{tld}", options)
99
99
 
100
100
  response.map { |r| Struct::ExtendedAttribute.new(r) }
101
101
  end
102
-
102
+ alias :list_extended_attributes :extended_attributes
103
103
 
104
104
  # List all the TLD prices.
105
105
  #
106
106
  # @see http://developer.dnsimple.com/registrar/prices/#list
107
107
  #
108
108
  # @return [Array<Struct::Price>]
109
+ #
109
110
  # @raise [RequestError] When the request fails.
110
- def list_prices
111
- response = client.get("v1/prices")
111
+ def prices(options = {})
112
+ response = client.get("v1/prices", options)
112
113
 
113
114
  response.map { |r| Struct::Price.new(r["price"]) }
114
115
  end
116
+ alias :list_prices :prices
115
117
 
116
118
  end
117
119
  end
@@ -7,26 +7,27 @@ module Dnsimple
7
7
  # @see http://developer.dnsimple.com/services/#list
8
8
  #
9
9
  # @return [Array<Struct::Service>]
10
+ #
10
11
  # @raise [RequestError] When the request fails.
11
- def services
12
- response = client.get("v1/services")
12
+ def services(options = {})
13
+ response = client.get("v1/services", options)
13
14
 
14
15
  response.map { |r| Struct::Service.new(r["service"]) }
15
16
  end
16
-
17
17
  alias :list :services
18
+ alias :list_services :services
18
19
 
19
20
  # Gets a service.
20
21
  #
21
22
  # @see http://developer.dnsimple.com/services/#get
22
23
  #
23
24
  # @param [Fixnum] service The service id.
24
- #
25
25
  # @return [Struct::Service]
26
+ #
26
27
  # @raise [NotFoundError]
27
28
  # @raise [RequestError] When the request fails.
28
- def service(service)
29
- response = client.get("v1/services/#{service}")
29
+ def service(service, options = {})
30
+ response = client.get("v1/services/#{service}", options)
30
31
 
31
32
  Struct::Service.new(response["service"])
32
33
  end
@@ -7,12 +7,12 @@ module Dnsimple
7
7
  # @see http://developer.dnsimple.com/services/#applied
8
8
  #
9
9
  # @param [#to_s] domain The domain id or domain name.
10
- #
11
10
  # @return [Array<Struct::Service>]
11
+ #
12
12
  # @raise [NotFoundError]
13
13
  # @raise [RequestError] When the request fails.
14
- def applied(domain)
15
- response = client.get("v1/domains/#{domain}/applied_services")
14
+ def applied(domain, options = {})
15
+ response = client.get("v1/domains/#{domain}/applied_services", options)
16
16
 
17
17
  response.map { |r| Struct::Service.new(r["service"]) }
18
18
  end
@@ -22,12 +22,12 @@ module Dnsimple
22
22
  # @see http://developer.dnsimple.com/services/#available
23
23
  #
24
24
  # @param [#to_s] domain The domain id or domain name.
25
- #
26
25
  # @return [Array<Struct::Service>]
26
+ #
27
27
  # @raise [NotFoundError]
28
28
  # @raise [RequestError] When the request fails.
29
- def available(domain)
30
- response = client.get("v1/domains/#{domain}/available_services")
29
+ def available(domain, options = {})
30
+ response = client.get("v1/domains/#{domain}/available_services", options)
31
31
 
32
32
  response.map { |r| Struct::Service.new(r["service"]) }
33
33
  end
@@ -38,12 +38,12 @@ module Dnsimple
38
38
  #
39
39
  # @param [#to_s] domain The domain id or domain name.
40
40
  # @param [Fixnum] service The service id.
41
- #
42
41
  # @return [void]
42
+ #
43
43
  # @raise [NotFoundError]
44
44
  # @raise [RequestError] When the request fails.
45
- def apply(domain, service)
46
- options = { service: { id: service }}
45
+ def apply(domain, service, options = {})
46
+ options = Extra.deep_merge(options, { service: { id: service }})
47
47
  response = client.post("v1/domains/#{domain}/applied_services", options)
48
48
  response.code == 200
49
49
  end
@@ -54,12 +54,12 @@ module Dnsimple
54
54
  #
55
55
  # @param [#to_s] domain The domain id or domain name.
56
56
  # @param [Fixnum] service The service id.
57
- #
58
57
  # @return [void]
58
+ #
59
59
  # @raise [NotFoundError]
60
60
  # @raise [RequestError] When the request fails.
61
- def unapply(domain, service)
62
- response = client.delete("v1/domains/#{domain}/applied_services/#{service}")
61
+ def unapply(domain, service, options = {})
62
+ response = client.delete("v1/domains/#{domain}/applied_services/#{service}", options)
63
63
  response.code == 200
64
64
  end
65
65
 
@@ -7,42 +7,44 @@ module Dnsimple
7
7
  # @see http://developer.dnsimple.com/templates/#list
8
8
  #
9
9
  # @return [Array<Struct::Template>]
10
+ #
10
11
  # @raise [RequestError] When the request fails.
11
- def templates
12
- response = client.get("v1/templates")
12
+ def templates(options = {})
13
+ response = client.get("v1/templates", options)
13
14
 
14
15
  response.map { |r| Struct::Template.new(r["dns_template"]) }
15
16
  end
16
-
17
17
  alias :list :templates
18
+ alias :list_templates :templates
18
19
 
19
20
  # Creates a template in the account.
20
21
  #
21
22
  # @see http://developer.dnsimple.com/templates/#create
22
23
  #
23
24
  # @param [Hash] attributes
24
- #
25
25
  # @return [Struct::Template]
26
+ #
26
27
  # @raise [RequestError] When the request fails.
27
- def create(attributes = {})
28
+ def create_template(attributes = {}, options = {})
28
29
  Extra.validate_mandatory_attributes(attributes, [:name, :short_name])
29
- options = { dns_template: attributes }
30
+ options = options.merge({ dns_template: attributes })
30
31
  response = client.post("v1/templates", options)
31
32
 
32
33
  Struct::Template.new(response["dns_template"])
33
34
  end
35
+ alias :create :create_template
34
36
 
35
37
  # Gets a template from the account.
36
38
  #
37
39
  # @see http://developer.dnsimple.com/templates/#get
38
40
  #
39
41
  # @param [#to_s] template The template id or short-name.
40
- #
41
42
  # @return [Struct::Template]
43
+ #
42
44
  # @raise [NotFoundError]
43
45
  # @raise [RequestError] When the request fails.
44
- def template(template)
45
- response = client.get("v1/templates/#{template}")
46
+ def template(template, options = {})
47
+ response = client.get("v1/templates/#{template}", options)
46
48
 
47
49
  Struct::Template.new(response["dns_template"])
48
50
  end
@@ -53,16 +55,17 @@ module Dnsimple
53
55
  #
54
56
  # @param [#to_s] template The template id or short-name.
55
57
  # @param [Hash] attributes
56
- #
57
58
  # @return [Struct::Template]
59
+ #
58
60
  # @raise [NotFoundError]
59
61
  # @raise [RequestError] When the request fails.
60
- def update(template, attributes = {})
61
- options = { dns_template: attributes }
62
+ def update_template(template, attributes = {}, options = {})
63
+ options = options.merge({ dns_template: attributes })
62
64
  response = client.put("v1/templates/#{template}", options)
63
65
 
64
66
  Struct::Template.new(response["dns_template"])
65
67
  end
68
+ alias :update :update_template
66
69
 
67
70
  # Deletes a template from the account.
68
71
  #
@@ -71,29 +74,14 @@ module Dnsimple
71
74
  # @see http://developer.dnsimple.com/templates/#delete
72
75
  #
73
76
  # @param [#to_s] template The template id or short-name.
74
- #
75
77
  # @return [void]
76
- # @raise [NotFoundError]
77
- # @raise [RequestError] When the request fails.
78
- def delete(template)
79
- client.delete("v1/templates/#{template}")
80
- end
81
-
82
-
83
- # Applies the template to the domain.
84
78
  #
85
- # @see http://developer.dnsimple.com/templates/#apply
86
- #
87
- # @param [#to_s] domain The domain id or domain name.
88
- # @param [#to_s] template The template id or short-name.
89
- #
90
- # @return [void]
91
79
  # @raise [NotFoundError]
92
80
  # @raise [RequestError] When the request fails.
93
- def apply(domain, template)
94
- response = client.post("v1/domains/#{domain}/templates/#{template}/apply")
95
- response.code == 200
81
+ def delete_template(template, options = {})
82
+ client.delete("v1/templates/#{template}", options)
96
83
  end
84
+ alias :delete :delete_template
97
85
 
98
86
  end
99
87
  end