dnsimple 3.0.0.pre.beta2 → 3.0.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -0
- data/.rubocop_dnsimple.yml +216 -0
- data/.rubocop_todo.yml +14 -0
- data/CHANGELOG.md +16 -1
- data/Gemfile +1 -0
- data/Rakefile +8 -3
- data/lib/dnsimple/client.rb +9 -12
- data/lib/dnsimple/client/clients.rb +36 -2
- data/lib/dnsimple/client/contacts.rb +6 -6
- data/lib/dnsimple/client/domains.rb +5 -5
- data/lib/dnsimple/client/identity.rb +2 -2
- data/lib/dnsimple/client/oauth.rb +2 -2
- data/lib/dnsimple/client/registrar.rb +1 -1
- data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -2
- data/lib/dnsimple/client/registrar_delegation.rb +49 -0
- data/lib/dnsimple/client/registrar_whois_privacy.rb +1 -1
- data/lib/dnsimple/client/services.rb +68 -0
- data/lib/dnsimple/client/templates.rb +139 -0
- data/lib/dnsimple/client/tlds.rb +3 -3
- data/lib/dnsimple/client/webhooks.rb +4 -4
- data/lib/dnsimple/client/zones.rb +2 -2
- data/lib/dnsimple/client/zones_records.rb +1 -1
- data/lib/dnsimple/default.rb +2 -2
- data/lib/dnsimple/error.rb +14 -1
- data/lib/dnsimple/struct.rb +3 -1
- data/lib/dnsimple/struct/contact.rb +2 -2
- data/lib/dnsimple/struct/extended_attribute.rb +5 -1
- data/lib/dnsimple/struct/service.rb +64 -0
- data/lib/dnsimple/struct/template.rb +22 -0
- data/lib/dnsimple/struct/tld.rb +1 -1
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/client_service_spec.rb +6 -6
- data/spec/dnsimple/client/contacts_spec.rb +30 -30
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +25 -25
- data/spec/dnsimple/client/domains_spec.rb +27 -27
- data/spec/dnsimple/client/identity_spec.rb +8 -8
- data/spec/dnsimple/client/oauth_spec.rb +9 -9
- data/spec/dnsimple/client/registrar_auto_renewal_spec.rb +13 -13
- data/spec/dnsimple/client/registrar_delegation_spec.rb +55 -0
- data/spec/dnsimple/client/registrar_spec.rb +29 -29
- data/spec/dnsimple/client/registrar_whois_privacy_spec.rb +16 -16
- data/spec/dnsimple/client/services_spec.rb +78 -0
- data/spec/dnsimple/client/templates_spec.rb +163 -0
- data/spec/dnsimple/client/tlds_spec.rb +22 -23
- data/spec/dnsimple/client/webhooks_spec.rb +22 -22
- data/spec/dnsimple/client/zones_records_spec.rb +40 -40
- data/spec/dnsimple/client/zones_spec.rb +12 -12
- data/spec/dnsimple/client_spec.rb +52 -44
- data/spec/dnsimple/extra_spec.rb +3 -3
- data/spec/fixtures.http/changeDomainDelegation/success.http +17 -0
- data/spec/fixtures.http/createTemplate/created.http +17 -0
- data/spec/fixtures.http/deleteTemplate/success.http +13 -0
- data/spec/fixtures.http/getDomainDelegation/success-empty.http +17 -0
- data/spec/fixtures.http/getDomainDelegation/success.http +17 -0
- data/spec/fixtures.http/getService/success.http +17 -0
- data/spec/fixtures.http/getTemplate/success.http +17 -0
- data/spec/fixtures.http/listServices/success.http +17 -0
- data/spec/fixtures.http/listTemplates/success.http +17 -0
- data/spec/fixtures.http/method-not-allowed.http +11 -0
- data/spec/fixtures.http/updateTemplate/success.http +17 -0
- metadata +41 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aca4eb6f6813b601531e5c5d82f9db0ec222dd5
|
4
|
+
data.tar.gz: 6076520c66e7ac64e23e1e006a9342f96cefabc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b56cb8d598eec60f48cf0eb63594e323b3a16d2d02a73a003e4fd7c64030f6a2d488fc77b8e4abab8c33598a28411aa15fdb946db4c0db2dc4faeafb1507303
|
7
|
+
data.tar.gz: d9cc0e1e056166b2cc5952ecd3d317bb524341ea92aaaac581a9e414bbc4e6164837f40b65566420281633a17ecb6c707430db2d0ee56e3053e439c9d96d9a65
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
inherit_from:
|
2
|
+
- .rubocop_todo.yml
|
3
|
+
- .rubocop_dnsimple.yml
|
4
|
+
|
5
|
+
# [codesmell]
|
6
|
+
# It's irrelevant here, but it could be a code smell.
|
7
|
+
# Hence keep it disabled, but don't include it in the DNSimple suite.
|
8
|
+
Lint/Loop:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
# It doesn't seem to work as expected.
|
12
|
+
Style/IfUnlessModifier:
|
13
|
+
Enabled: false
|
@@ -0,0 +1,216 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
# Exclude .gemspec files because they are generally auto-generated
|
4
|
+
- '*.gemspec'
|
5
|
+
|
6
|
+
# Generally, the keyword style uses a lot of space. This is particularly true when
|
7
|
+
# you use case/if statements, in combination with a long-name variable.
|
8
|
+
#
|
9
|
+
# invoice_error_message = case error
|
10
|
+
# when 1 == 1
|
11
|
+
# do_something
|
12
|
+
# else
|
13
|
+
# do_else
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
Lint/EndAlignment:
|
17
|
+
AlignWith: variable
|
18
|
+
|
19
|
+
# [codesmell]
|
20
|
+
Metrics/AbcSize:
|
21
|
+
Enabled: false
|
22
|
+
Exclude:
|
23
|
+
- 'spec/**/*_spec.rb'
|
24
|
+
- 'test/**/*_test.rb'
|
25
|
+
|
26
|
+
# For the same reason of EndAlignment, aligning with the case may have a bad impact
|
27
|
+
# on a case after a very long variable.
|
28
|
+
#
|
29
|
+
# invoice_error_message = case error
|
30
|
+
# when 1 == 1
|
31
|
+
# do_something
|
32
|
+
# else
|
33
|
+
# do_else
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
Style/CaseIndentation:
|
37
|
+
IndentWhenRelativeTo: end
|
38
|
+
|
39
|
+
# [codesmell]
|
40
|
+
Metrics/ClassLength:
|
41
|
+
Enabled: false
|
42
|
+
Exclude:
|
43
|
+
- 'spec/**/*_spec.rb'
|
44
|
+
- 'test/**/*_test.rb'
|
45
|
+
|
46
|
+
# [codesmell]
|
47
|
+
Metrics/MethodLength:
|
48
|
+
Enabled: false
|
49
|
+
Exclude:
|
50
|
+
- 'spec/**/*_spec.rb'
|
51
|
+
- 'test/**/*_test.rb'
|
52
|
+
Max: 10
|
53
|
+
|
54
|
+
# [codesmell]
|
55
|
+
Metrics/ModuleLength:
|
56
|
+
Enabled: false
|
57
|
+
Exclude:
|
58
|
+
- 'spec/**/*_spec.rb'
|
59
|
+
- 'test/**/*_test.rb'
|
60
|
+
|
61
|
+
# [codesmell]
|
62
|
+
Metrics/LineLength:
|
63
|
+
Enabled: false
|
64
|
+
Exclude:
|
65
|
+
- 'spec/**/*_spec.rb'
|
66
|
+
- 'test/**/*_test.rb'
|
67
|
+
Max: 100
|
68
|
+
|
69
|
+
# [codesmell]
|
70
|
+
# I don't really get the point of this cop.
|
71
|
+
Performance/RedundantMerge:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
# Do not use "and" or "or" in conditionals, but for readability we can use it
|
75
|
+
# to chain executions. Just beware of operator order.
|
76
|
+
Style/AndOr:
|
77
|
+
EnforcedStyle: conditionals
|
78
|
+
|
79
|
+
# No specific reason, except that %q() is easier to grep than %()
|
80
|
+
Style/BarePercentLiterals:
|
81
|
+
EnforcedStyle: percent_q
|
82
|
+
|
83
|
+
# braces_for_chaining seems a good fit of what we've been doing so far.
|
84
|
+
Style/BlockDelimiters:
|
85
|
+
EnforcedStyle: braces_for_chaining
|
86
|
+
IgnoredMethods:
|
87
|
+
- expect
|
88
|
+
|
89
|
+
# I'd rather use context_dependent, even if I'm not even sure we should enforce a style.
|
90
|
+
Style/BracesAroundHashParameters:
|
91
|
+
EnforcedStyle: context_dependent
|
92
|
+
|
93
|
+
# I was a big fan of leading, but trailing seems to be more commonly adopted.
|
94
|
+
# At least at the time being.
|
95
|
+
Style/DotPosition:
|
96
|
+
EnforcedStyle: trailing
|
97
|
+
|
98
|
+
# Warn on empty else.
|
99
|
+
Style/EmptyElse:
|
100
|
+
EnforcedStyle: empty
|
101
|
+
|
102
|
+
# Double empty lines are useful to separate conceptually different methods
|
103
|
+
# in the same class or module.
|
104
|
+
Style/EmptyLines:
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
Style/EmptyLinesAroundBlockBody:
|
108
|
+
Exclude:
|
109
|
+
# RSpec is all made of blocks. Disable this config in RSpec
|
110
|
+
# to be consistent with EmptyLinesAroundClassBody and EmptyLinesAroundModuleBody
|
111
|
+
- 'spec/**/*_spec.rb'
|
112
|
+
- 'test/**/*_test.rb'
|
113
|
+
|
114
|
+
# In most cases, a space is nice. Sometimes, it's not.
|
115
|
+
# Just be consistent with the rest of the surrounding code.
|
116
|
+
Style/EmptyLinesAroundClassBody:
|
117
|
+
Enabled: false
|
118
|
+
|
119
|
+
# In most cases, a space is nice. Sometimes, it's not.
|
120
|
+
# Just be consistent with the rest of the surrounding code.
|
121
|
+
Style/EmptyLinesAroundModuleBody:
|
122
|
+
Enabled: false
|
123
|
+
|
124
|
+
# I personally don't care about the format style.
|
125
|
+
# In most cases I like to use %, but not at the point I want to enforce it
|
126
|
+
# as a convention in the entire code.
|
127
|
+
Style/FormatString:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
# Multi-line differs from standard indentation, they are indented twice.
|
131
|
+
Style/FirstParameterIndentation:
|
132
|
+
IndentationWidth: 4
|
133
|
+
|
134
|
+
# Prefer the latest Hash syntax
|
135
|
+
Style/HashSyntax:
|
136
|
+
Exclude:
|
137
|
+
# But Rakefiles generally have some definition like
|
138
|
+
# :default => :test
|
139
|
+
# that looks nicer with the old rocket syntax.
|
140
|
+
- 'Rakefile'
|
141
|
+
|
142
|
+
# We want to be able to decide when to use one-line if/unless modifiers.
|
143
|
+
Style/IfUnlessModifier:
|
144
|
+
Enabled: false
|
145
|
+
|
146
|
+
# Array indentation should be considered like MultilineMethodCallIndentation indentation
|
147
|
+
# and use 4 spaces instead of 2.
|
148
|
+
Style/IndentArray:
|
149
|
+
IndentationWidth: 4
|
150
|
+
|
151
|
+
# Hash indentation should be considered like MultilineMethodCallIndentation indentation
|
152
|
+
# and use 4 spaces instead of 2.
|
153
|
+
Style/IndentHash:
|
154
|
+
IndentationWidth: 4
|
155
|
+
|
156
|
+
# [codesmell]
|
157
|
+
# It's not always that bad.
|
158
|
+
Style/IfInsideElse:
|
159
|
+
Enabled: false
|
160
|
+
|
161
|
+
# Multi-line differs from standard indentation, they are indented twice.
|
162
|
+
Style/MultilineMethodCallIndentation:
|
163
|
+
EnforcedStyle: indented
|
164
|
+
IndentationWidth: 4
|
165
|
+
|
166
|
+
# Multi-line differs from standard indentation, they are indented twice.
|
167
|
+
Style/MultilineOperationIndentation:
|
168
|
+
EnforcedStyle: indented
|
169
|
+
IndentationWidth: 4
|
170
|
+
|
171
|
+
# unless is not always cool.
|
172
|
+
Style/NegatedIf:
|
173
|
+
Enabled: false
|
174
|
+
|
175
|
+
# Magic numbers are not welcomed
|
176
|
+
Style/NumericLiterals:
|
177
|
+
Exclude:
|
178
|
+
# however tests can use numeric literals for method calls,
|
179
|
+
# without the need to define a variable just for that.
|
180
|
+
- 'spec/**/*_spec.rb'
|
181
|
+
- 'test/**/*_test.rb'
|
182
|
+
|
183
|
+
# Do we care?
|
184
|
+
Style/RegexpLiteral:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
# There are cases were the inline rescue is ok. We can either downgrade the severity,
|
188
|
+
# or rely on the developer judgement on a case-by-case basis.
|
189
|
+
Style/RescueModifier:
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
# We don't have a preference.
|
193
|
+
Style/SpecialGlobalVars:
|
194
|
+
Enabled: false
|
195
|
+
EnforcedStyle: use_perl_names
|
196
|
+
|
197
|
+
# We generally use double quotes, sometimes single quotes.
|
198
|
+
# Should we enforce it at code level?
|
199
|
+
Style/StringLiterals:
|
200
|
+
Enabled: false
|
201
|
+
EnforcedStyle: double_quotes
|
202
|
+
|
203
|
+
# It's nice to be consistent. The trailing comma also allows easy reordering,
|
204
|
+
# and doesn't cause a diff in Git when you add a line to the bottom.
|
205
|
+
Style/TrailingCommaInLiteral:
|
206
|
+
EnforcedStyleForMultiline: consistent_comma
|
207
|
+
|
208
|
+
Style/TrivialAccessors:
|
209
|
+
# IgnoreClassMethods because I want to be able to define class-level accessors
|
210
|
+
# that sets an instance variable on the metaclass, such as:
|
211
|
+
#
|
212
|
+
# def self.default=(value)
|
213
|
+
# @default = value
|
214
|
+
# end
|
215
|
+
#
|
216
|
+
IgnoreClassMethods: true
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2016-03-27 01:01:12 +0100 using RuboCop version 0.38.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
Style/Documentation:
|
10
|
+
# Silence this check for now until we fix it.
|
11
|
+
Enabled: false
|
12
|
+
Exclude:
|
13
|
+
- 'spec/**/*'
|
14
|
+
- 'test/**/*'
|
data/CHANGELOG.md
CHANGED
@@ -3,7 +3,22 @@
|
|
3
3
|
This project uses [Semantic Versioning 2.0.0](http://semver.org/).
|
4
4
|
|
5
5
|
|
6
|
-
#### 3.0
|
6
|
+
#### 3.0.0
|
7
|
+
|
8
|
+
##### stable
|
9
|
+
|
10
|
+
- FIXED: The client was using the wrong key to store the ContactsService which could cause conflicts with the DomainsService.
|
11
|
+
|
12
|
+
- FIXED: `renewDomain` used a wrong path (GH-96).
|
13
|
+
|
14
|
+
- NEW: Added registrar delegation support (GH-98).
|
15
|
+
|
16
|
+
- NEW: Added template support (GH-99).
|
17
|
+
|
18
|
+
- NEW: Added service support (GH-101).
|
19
|
+
|
20
|
+
- CHANGED: Error detection is now smarter. If the error is deserializable and contains a message, the message is attached to the exception (GH-94, GH-95, GH-100).
|
21
|
+
|
7
22
|
|
8
23
|
##### beta2
|
9
24
|
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -1,16 +1,21 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
|
3
|
-
#
|
4
|
-
task :
|
3
|
+
# By default, run tests and linter.
|
4
|
+
task default: [:spec, :rubocop]
|
5
5
|
|
6
6
|
|
7
7
|
require 'rspec/core/rake_task'
|
8
8
|
|
9
9
|
RSpec::Core::RakeTask.new do |t|
|
10
|
-
t.verbose =
|
10
|
+
t.verbose = !ENV["VERBOSE"].nil?
|
11
11
|
end
|
12
12
|
|
13
13
|
|
14
|
+
require 'rubocop/rake_task'
|
15
|
+
|
16
|
+
RuboCop::RakeTask.new
|
17
|
+
|
18
|
+
|
14
19
|
require 'yard'
|
15
20
|
|
16
21
|
YARD::Rake::YardocTask.new(:yardoc) do |y|
|
data/lib/dnsimple/client.rb
CHANGED
@@ -11,13 +11,12 @@ module Dnsimple
|
|
11
11
|
# @see https://developer.dnsimple.com/
|
12
12
|
class Client
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
WILDCARD_ACCOUNT = "_"
|
14
|
+
HEADER_AUTHORIZATION = "Authorization".freeze
|
15
|
+
WILDCARD_ACCOUNT = "_".freeze
|
17
16
|
|
18
17
|
|
19
18
|
# @return [String] The current API version.
|
20
|
-
API_VERSION = "v2"
|
19
|
+
API_VERSION = "v2".freeze
|
21
20
|
|
22
21
|
|
23
22
|
# Prepends the correct API version to +path+.
|
@@ -83,7 +82,7 @@ module Dnsimple
|
|
83
82
|
# @param [Hash] data The body for the request
|
84
83
|
# @param [Hash] options The query and header params for the request
|
85
84
|
# @return [HTTParty::Response]
|
86
|
-
def post(path, data = nil, options= {})
|
85
|
+
def post(path, data = nil, options = {})
|
87
86
|
execute :post, path, data, options
|
88
87
|
end
|
89
88
|
|
@@ -134,11 +133,11 @@ module Dnsimple
|
|
134
133
|
when 200..299
|
135
134
|
response
|
136
135
|
when 401
|
137
|
-
raise AuthenticationFailed
|
136
|
+
raise AuthenticationFailed, response["message"]
|
138
137
|
when 404
|
139
|
-
raise NotFoundError
|
138
|
+
raise NotFoundError, response
|
140
139
|
else
|
141
|
-
raise RequestError
|
140
|
+
raise RequestError, response
|
142
141
|
end
|
143
142
|
end
|
144
143
|
|
@@ -173,8 +172,8 @@ module Dnsimple
|
|
173
172
|
options = {
|
174
173
|
format: :json,
|
175
174
|
headers: {
|
176
|
-
|
177
|
-
|
175
|
+
'Accept' => 'application/json',
|
176
|
+
'User-Agent' => user_agent,
|
178
177
|
},
|
179
178
|
}
|
180
179
|
|
@@ -185,8 +184,6 @@ module Dnsimple
|
|
185
184
|
|
186
185
|
if password
|
187
186
|
options[:basic_auth] = { username: username, password: password }
|
188
|
-
elsif domain_api_token
|
189
|
-
options[:headers][HEADER_DOMAIN_API_TOKEN] = domain_api_token
|
190
187
|
elsif access_token
|
191
188
|
options[:headers][HEADER_AUTHORIZATION] = "Bearer #{access_token}"
|
192
189
|
else
|
@@ -3,7 +3,7 @@ module Dnsimple
|
|
3
3
|
|
4
4
|
# @return [Dnsimple::Client::ContactsService] The contact-related API proxy.
|
5
5
|
def contacts
|
6
|
-
@services[:
|
6
|
+
@services[:contacts] ||= Client::ContactsService.new(self)
|
7
7
|
end
|
8
8
|
|
9
9
|
# @return [Dnsimple::Client::DomainsService] The domain-related API proxy.
|
@@ -26,6 +26,16 @@ module Dnsimple
|
|
26
26
|
@services[:registrar] ||= Client::RegistrarService.new(self)
|
27
27
|
end
|
28
28
|
|
29
|
+
# @return [Dnsimple::Client::ServicesService] The one-click-service-related API proxy.
|
30
|
+
def services
|
31
|
+
@services[:services] ||= Client::ServicesService.new(self)
|
32
|
+
end
|
33
|
+
|
34
|
+
# @return [Dnsimple::Client::TemplatesService] The templates-related API proxy.
|
35
|
+
def templates
|
36
|
+
@services[:templates] ||= Client::TemplatesService.new(self)
|
37
|
+
end
|
38
|
+
|
29
39
|
# @return [Dnsimple::Client::TldsService] The tld-related API proxy.
|
30
40
|
def tlds
|
31
41
|
@services[:tlds] ||= Client::TldsService.new(self)
|
@@ -43,7 +53,14 @@ module Dnsimple
|
|
43
53
|
|
44
54
|
|
45
55
|
# @!class Struct
|
46
|
-
class ClientService
|
56
|
+
class ClientService
|
57
|
+
|
58
|
+
# @return [Dnsimple::Client]
|
59
|
+
attr_reader :client
|
60
|
+
|
61
|
+
def initialize(client)
|
62
|
+
@client = client
|
63
|
+
end
|
47
64
|
|
48
65
|
# Internal helper that loops over a paginated response and returns all the records in the collection.
|
49
66
|
#
|
@@ -107,11 +124,27 @@ module Dnsimple
|
|
107
124
|
require_relative 'registrar'
|
108
125
|
require_relative 'registrar_auto_renewal'
|
109
126
|
require_relative 'registrar_whois_privacy'
|
127
|
+
require_relative 'registrar_delegation'
|
110
128
|
|
111
129
|
class RegistrarService < ClientService
|
112
130
|
include Client::Registrar
|
113
131
|
include Client::RegistrarAutoRenewal
|
114
132
|
include Client::RegistrarWhoisPrivacy
|
133
|
+
include Client::RegistrarDelegation
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
require_relative 'services'
|
138
|
+
|
139
|
+
class ServicesService < ClientService
|
140
|
+
include Client::Services
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
require_relative 'templates'
|
145
|
+
|
146
|
+
class TemplatesService < ClientService
|
147
|
+
include Client::Templates
|
115
148
|
end
|
116
149
|
|
117
150
|
|
@@ -130,6 +163,7 @@ module Dnsimple
|
|
130
163
|
include Client::ZonesRecords
|
131
164
|
end
|
132
165
|
|
166
|
+
|
133
167
|
require_relative 'webhooks'
|
134
168
|
|
135
169
|
class WebhooksService < ClientService
|