dnsimple 7.1.1 → 8.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 186f6faf074afa519d67b5397e0e1568ed6745948239a14fb8f72f39dccea390
4
- data.tar.gz: 605cf70471182fc26fb96cb99eadc204040040bee4481ff1de4837a8084940c8
3
+ metadata.gz: 926c26b50cdc2958b19e86a45cd6eb0394f5d884bcc12e45e8fda88b194c8fac
4
+ data.tar.gz: 930e5d25b213d496faa3268b3af1a0a1a407e0b632ad9a4a7f16fc8cb2a72256
5
5
  SHA512:
6
- metadata.gz: 76a9bdea4ba0618262230bea5daa1d5fe66a23e414ce7c5eae0115b343bb9355e277ef492d6f4f8ce8579609e3c511075dfed7080dfac3a34260c499faea1375
7
- data.tar.gz: 5c07656ba50cdd66cba4c51ea7085229c05f0140127061a0c567ec3940c9ab6e779aae9ff8627f4531fc9bdb2bdb150683f63e792a051c55be81d3e26f0f906e
6
+ metadata.gz: 94cb5d1a3c141069d239d26a95e097b016b008acca7dcb2c14ff7040ed325a896e0ceaea4139344e22de6fb72360c7709df016de5aba668eab5b9afba17db8fc
7
+ data.tar.gz: 0c975b2a65075d1df91923e26d1604600d6fa595634fd3b1ec85aa31fedef28627774340cca6b2d63b09bae96731d4895745a4a040943a835cab4387cb94acb4
@@ -10,4 +10,13 @@ updates:
10
10
  labels:
11
11
  - task
12
12
  - dependencies
13
- - backlog-dependencies
13
+
14
+ - package-ecosystem: "github-actions"
15
+ directory: "/"
16
+ schedule:
17
+ interval: "daily"
18
+ time: '12:00'
19
+ open-pull-requests-limit: 10
20
+ labels:
21
+ - task
22
+ - dependencies
@@ -1,47 +1,51 @@
1
- ---
2
- name: ci
1
+ name: CI
3
2
 
4
3
  on:
5
4
  push:
5
+ branches: [ main ]
6
6
  pull_request:
7
- # Allows you to run this workflow manually from the Actions tab
8
7
  workflow_dispatch:
9
8
 
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
10
13
  jobs:
11
14
  markdownlint-cli:
15
+ name: Lint markdown
12
16
  runs-on: ubuntu-latest
13
17
  steps:
14
18
  - name: Checkout Code
15
- uses: actions/checkout@v2
19
+ uses: actions/checkout@v3
16
20
  - name: Run markdownlint-cli
17
- uses: nosborn/github-action-markdown-cli@v2.0.0
21
+ uses: nosborn/github-action-markdown-cli@v3.1.0
18
22
  with:
19
23
  files: .
20
24
  config_file: ".markdownlint.yaml"
21
25
 
22
26
  yamllint:
27
+ name: Lint YAML
23
28
  runs-on: ubuntu-latest
24
29
  steps:
25
30
  - name: Checkout Code
26
- uses: actions/checkout@v2
31
+ uses: actions/checkout@v3
27
32
  - name: Run YAML Lint
28
33
  uses: actionshub/yamllint@main
29
34
 
30
- build:
35
+ test:
31
36
  needs: [markdownlint-cli, yamllint]
32
37
  runs-on: ubuntu-latest
33
38
  name: Ruby ${{ matrix.ruby-version }}
34
39
  strategy:
35
40
  matrix:
36
41
  ruby-version:
37
- - '2.6'
38
42
  - '2.7'
39
43
  - '3.0'
40
44
  - '3.1'
41
45
  - 'ruby-head'
42
46
  - 'truffleruby-head'
43
47
  steps:
44
- - uses: actions/checkout@v2
48
+ - uses: actions/checkout@v3
45
49
  - name: Set up Ruby
46
50
  uses: ruby/setup-ruby@v1
47
51
  with:
@@ -53,7 +57,7 @@ jobs:
53
57
  if: always()
54
58
  name: Post Workflow Status To Slack
55
59
  needs:
56
- - build
60
+ - test
57
61
  runs-on: ubuntu-latest
58
62
  steps:
59
63
  - name: Slack Workflow Notification
@@ -1,5 +1,4 @@
1
- ---
2
- name: release
1
+ name: Release
3
2
 
4
3
  on:
5
4
  push:
@@ -7,10 +6,20 @@ on:
7
6
  - v*.*.*
8
7
  jobs:
9
8
  publish:
9
+ name: Release to RubyGems
10
10
  runs-on: ubuntu-latest
11
11
 
12
12
  steps:
13
- - uses: actions/checkout@v2
13
+ - name: Wait for tests to succeed
14
+ uses: lewagon/wait-on-check-action@v1.1.2
15
+ with:
16
+ ref: 'refs/heads/main'
17
+ running-workflow-name: 'Release to RubyGems'
18
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
19
+ wait-interval: 10
20
+ allowed-conclusions: success
21
+
22
+ - uses: actions/checkout@v3
14
23
 
15
24
  - name: Release Gem
16
25
  uses: cadwallion/publish-rubygems-action@8f9e0538302643309e4e43bf48cd34173ca48cfc # yamllint disable-line
data/.gitignore CHANGED
@@ -1,3 +1,6 @@
1
+ # ASDF
2
+ .tool-versions
3
+
1
4
  # Bundler
2
5
  .bundle
3
6
  pkg/*
@@ -7,6 +10,3 @@ Gemfile.lock
7
10
  .yardoc
8
11
  yardoc/
9
12
  doc/
10
-
11
- #ASDF
12
- .tool-versions
@@ -140,7 +140,7 @@ Style/BarePercentLiterals:
140
140
  # braces_for_chaining seems a good fit of what we've been doing so far.
141
141
  Style/BlockDelimiters:
142
142
  EnforcedStyle: braces_for_chaining
143
- IgnoredMethods:
143
+ AllowedMethods:
144
144
  - expect
145
145
 
146
146
  # Warn on empty else.
data/.rubocop_todo.yml CHANGED
@@ -1,12 +1,12 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-12-31 12:20:10 UTC using RuboCop version 1.24.1.
3
+ # on 2022-09-01 12:27:48 UTC using RuboCop version 1.36.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 71
9
+ # Offense count: 70
10
10
  # Configuration parameters: CountAsOne.
11
11
  RSpec/ExampleLength:
12
12
  Max: 17
@@ -22,11 +22,11 @@ RSpec/LeakyConstantDeclaration:
22
22
  RSpec/MessageSpies:
23
23
  EnforcedStyle: receive
24
24
 
25
- # Offense count: 112
25
+ # Offense count: 111
26
26
  RSpec/MultipleExpectations:
27
27
  Max: 15
28
28
 
29
- # Offense count: 375
29
+ # Offense count: 371
30
30
  # Configuration parameters: IgnoreSharedExamples.
31
31
  RSpec/NamedSubject:
32
32
  Enabled: false
data/.yamllint.yml ADDED
@@ -0,0 +1,29 @@
1
+ ---
2
+
3
+ extends: default
4
+
5
+ rules:
6
+ braces:
7
+ level: warning
8
+ max-spaces-inside: 1
9
+ brackets:
10
+ level: warning
11
+ max-spaces-inside: 1
12
+ colons:
13
+ level: warning
14
+ commas:
15
+ level: warning
16
+ comments: disable
17
+ comments-indentation: disable
18
+ document-start: disable
19
+ empty-lines:
20
+ level: warning
21
+ hyphens:
22
+ level: warning
23
+ indentation:
24
+ level: warning
25
+ indent-sequences: consistent
26
+ line-length:
27
+ level: warning
28
+ allow-non-breakable-inline-mappings: true
29
+ truthy: disable
data/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ This project uses [Semantic Versioning 2.0.0](http://semver.org/).
4
4
 
5
5
  ## main
6
6
 
7
+ ## 8.1.0
8
+
9
+ - CHANGED: Fixed and updated documentation for domain endpoints (dnsimple/dnsimple-ruby#300)
10
+ - CHANGED: Expose all information available in error responses (dnsimple/dnsimple-ruby#298)
11
+
12
+ ## 8.0.0
13
+
14
+ - CHANGED: Minimum Ruby version is now 2.7
15
+ - REMOVED: `registrar.getDomainPremiumPrice` in favour of `registrar.getDomainPrices`
16
+ - CHANGED: Deprecate Certificate's `contact_id` (dnsimple/dnsimple-ruby#276)
17
+ - FIXED: Remove stale reference to Client::DomainServicesService (dnsimple/dnsimple-ruby#267)
18
+
7
19
  ## 7.1.1
8
20
 
9
21
  - CHANGED: Bumped up dependencies
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  gem 'coveralls', require: false
8
- gem 'rubocop', '1.24.1', require: false
9
- gem 'rubocop-performance', require: false
10
- gem 'rubocop-rake', require: false
11
- gem 'rubocop-rspec', require: false
8
+ gem 'rubocop', '1.36.0', require: false
9
+ gem 'rubocop-performance', '1.15.0', require: false
10
+ gem 'rubocop-rake', '0.6.0', require: false
11
+ gem 'rubocop-rspec', '2.13.1', require: false
data/README.md CHANGED
@@ -8,6 +8,10 @@ A Ruby client for the [DNSimple API v2](https://developer.dnsimple.com/v2/).
8
8
  [DNSimple](https://dnsimple.com/) provides DNS hosting and domain registration that is simple and friendly.
9
9
  We provide a full API and an easy-to-use web interface so you can get your domain registered and set up with a minimal amount of effort.
10
10
 
11
+ ## Requirements
12
+
13
+ - Ruby: MRI > 2.7+
14
+
11
15
  ## Installation
12
16
 
13
17
  You can install the gem manually:
@@ -22,13 +26,50 @@ Or use Bundler and define it as a dependency in your Gemfile:
22
26
  gem 'dnsimple', '~> 6.0'
23
27
  ```
24
28
 
25
- ## Usage
29
+ ## Documentation
30
+
31
+ ### Relevant links
32
+
33
+ - [`dnsimple-ruby` RDocs](https://www.rubydoc.info/gems/dnsimple/).
34
+ - [DNSimple API documentation](https://developer.dnsimple.com).
35
+ - [DNSimple API examples repository](https://github.com/dnsimple/dnsimple-api-examples).
36
+ - [DNSimple support documentation](https://support.dnsimple.com).
26
37
 
27
- This library is a Ruby client you can use to interact with the [DNSimple API v2](https://developer.dnsimple.com/v2/). Here are some examples.
38
+ ### Sandbox Environment
39
+
40
+ We highly recommend testing against our [sandbox environment](https://developer.dnsimple.com/sandbox/) before using our production environment. This will allow you to avoid real purchases, live charges on your credit card, and reduce the chance of your running up against rate limits.
41
+
42
+ The client supports both the production and sandbox environment. To switch to sandbox pass the sandbox API host using the `base_url` option when you construct the client:
43
+
44
+ ```ruby
45
+ client = Dnsimple::Client.new(base_url: "https://api.sandbox.dnsimple.com", access_token: "a1b2c3")
46
+ ```
47
+
48
+ You will need to ensure that you are using an access token created in the sandbox environment. Production tokens will *not* work in the sandbox environment.
49
+
50
+ ### Examples
51
+
52
+ Be sure to require the gem before trying any of the examples:
28
53
 
29
54
  ```ruby
30
55
  require 'dnsimple'
56
+ ```
57
+
58
+ #### Setting a custom `User-Agent` header
59
+
60
+ You can customize the `User-Agent` header for the calls made to the DNSimple API:
61
+
62
+ ```ruby
63
+ client = Dnsimple::Client.new(user_agent: "my-app/1.0")
64
+ ```
65
+
66
+ The value you provide will be prepended to the default `User-Agent` the client uses. For example, if you use `my-app/1.0`, the final header value will be `my-app/1.0 dnsimple-ruby/0.14.0` (note that it will vary depending on the client version).
67
+
68
+ We recommend to customize the user agent. If you are building a library or integration on top of the official client, customizing the client will help us to understand what is this client used for, and allow to contribute back or get in touch.
69
+
70
+ #### Authentication
31
71
 
72
+ ```ruby
32
73
  client = Dnsimple::Client.new(access_token: "a1b2c3")
33
74
 
34
75
  # Fetch your details
@@ -43,47 +84,30 @@ account_id = 1010
43
84
  # as long as you authenticate with an Account access token
44
85
  whoami = client.identity.whoami.data
45
86
  account_id = whoami.account.id
87
+ ```
46
88
 
47
- # List your domains
89
+ #### Listing your domains
90
+
91
+ ```ruby
48
92
  puts client.domains.list_domains(account_id).data # => domains from the account 1234, first page
49
93
  puts client.domains.list_domains(account_id, query: { page: 3 }).data # => domains from the account 1234, third page
50
94
  puts client.domains.all_domains(account_id).data # => all domains from the account 1234 (use carefully)
51
-
52
- # Create a domain
53
- response = client.domains.create_domain(account_id, name: "example.com")
54
- puts response.data
55
-
56
- # Get a domain
57
- response = client.domains.domain(account_id, "example.com")
58
- puts response.data
59
95
  ```
60
96
 
61
- For the full library documentation visit <http://rubydoc.info/gems/dnsimple>
62
-
63
- ## Sandbox Environment
64
-
65
- We highly recommend testing against our [sandbox environment](https://developer.dnsimple.com/sandbox/) before using our production environment. This will allow you to avoid real purchases, live charges on your credit card, and reduce the chance of your running up against rate limits.
66
-
67
- The client supports both the production and sandbox environment. To switch to sandbox pass the sandbox API host using the `base_url` option when you construct the client:
97
+ #### Create a domain
68
98
 
69
99
  ```ruby
70
- client = Dnsimple::Client.new(base_url: "https://api.sandbox.dnsimple.com", access_token: "a1b2c3")
100
+ response = client.domains.create_domain(account_id, name: "example.com")
101
+ puts response.data
71
102
  ```
72
103
 
73
- You will need to ensure that you are using an access token created in the sandbox environment. Production tokens will *not* work in the sandbox environment.
74
-
75
- ## Setting a custom `User-Agent` header
76
-
77
- You can customize the `User-Agent` header for the calls made to the DNSimple API:
104
+ #### Get a domain
78
105
 
79
106
  ```ruby
80
- client = Dnsimple::Client.new(user_agent: "my-app/1.0")
107
+ response = client.domains.domain(account_id, "example.com")
108
+ puts response.data
81
109
  ```
82
110
 
83
- The value you provide will be prepended to the default `User-Agent` the client uses. For example, if you use `my-app/1.0`, the final header value will be `my-app/1.0 dnsimple-ruby/0.14.0` (note that it will vary depending on the client version).
84
-
85
- We recommend to customize the user agent. If you are building a library or integration on top of the official client, customizing the client will help us to understand what is this client used for, and allow to contribute back or get in touch.
86
-
87
111
  ## License
88
112
 
89
113
  Copyright (c) 2010-2022 DNSimple Corporation. This is Free Software distributed under the MIT license.
data/Rakefile CHANGED
@@ -33,5 +33,5 @@ task :clobber => "yardoc:clobber"
33
33
 
34
34
  desc "Open an irb session preloaded with this library"
35
35
  task :console do
36
- sh "irb -rubygems -I lib -r dnsimple.rb"
36
+ sh "irb -r rubygems -I lib -r dnsimple.rb"
37
37
  end
data/dnsimple.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.summary = 'The DNSimple API client for Ruby'
12
12
  s.description = 'The DNSimple API client for Ruby.'
13
13
 
14
- s.required_ruby_version = ">= 2.6"
14
+ s.required_ruby_version = ">= 2.7"
15
15
 
16
16
  s.require_paths = ['lib']
17
17
  s.files = `git ls-files`.split("\n")
@@ -121,7 +121,6 @@ module Dnsimple
121
121
  # @param account_id [Integer] the account ID
122
122
  # @param domain_id [#to_s] the domain ID or domain name
123
123
  # @param attributes [Hash]
124
- # @option attributes [Integer] :contact_id the contact ID (mandatory)
125
124
  # @option attributes [String] :name the certificate name (optional)
126
125
  # @option attributes [Array<String>] :alternate_names the certificate alternate names (optional)
127
126
  # @option attributes [TrueClass,FalseClass] :auto_renew enable certificate auto renew (optional)
@@ -133,7 +132,7 @@ module Dnsimple
133
132
  # @raise [Dnsimple::RequestError]
134
133
  #
135
134
  # @example Basic usage
136
- # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com", contact_id: 1)
135
+ # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com")
137
136
  # certificate = response.data
138
137
  #
139
138
  # certificate.id # => 100
@@ -142,7 +141,7 @@ module Dnsimple
142
141
  # certificate.auto_renew # => false
143
142
  #
144
143
  # @example Custom name
145
- # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com", contact_id: 1, name: "docs")
144
+ # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com", name: "docs")
146
145
  # certificate = response.data
147
146
  #
148
147
  # certificate.id # => 100
@@ -151,7 +150,7 @@ module Dnsimple
151
150
  # certificate.auto_renew # => false
152
151
  #
153
152
  # @example SAN names
154
- # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com", contact_id: 1, alternate_names: ["api.example.com", "status.example.com"])
153
+ # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com", alternate_names: ["api.example.com", "status.example.com"])
155
154
  # certificate = response.data
156
155
  #
157
156
  # certificate.id # => 100
@@ -160,15 +159,14 @@ module Dnsimple
160
159
  # certificate.auto_renew # => false
161
160
  #
162
161
  # @example Auto renew
163
- # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com", contact_id: 1, auto_renew: true)
162
+ # response = client.certificates.purchase_letsencrypt_certificate(1010, "example.com", auto_renew: true)
164
163
  # certificate = response.data
165
164
  #
166
165
  # certificate.id # => 100
167
166
  # certificate.common_name # => "www.example.com"
168
167
  # certificate.alternate_names # => []
169
168
  # certificate.auto_renew # => true
170
- def purchase_letsencrypt_certificate(account_id, domain_id, attributes, options = {})
171
- Extra.validate_mandatory_attributes(attributes, [:contact_id])
169
+ def purchase_letsencrypt_certificate(account_id, domain_id, attributes = {}, options = {})
172
170
  response = client.post(Client.versioned("/%s/domains/%s/certificates/letsencrypt" % [account_id, domain_id]), attributes, options)
173
171
 
174
172
  Dnsimple::Response.new(response, Struct::CertificatePurchase.new(response["data"]))
@@ -23,11 +23,6 @@ module Dnsimple
23
23
  @services[:domains] ||= Client::DomainsService.new(self)
24
24
  end
25
25
 
26
- # @return [Dnsimple::Client::DomainServicesService] The domain-services-related API proxy.
27
- def domain_services
28
- @services[:domains] ||= Client::DomainServicesService.new(self)
29
- end
30
-
31
26
  # @return [Dnsimple::Client::IdentityService] The identity-related API proxy.
32
27
  def identity
33
28
  @services[:auth] ||= Client::IdentityService.new(self)
@@ -6,20 +6,20 @@ module Dnsimple
6
6
 
7
7
  # Lists the domains in the account.
8
8
  #
9
- # @see https://developer.dnsimple.com/v2/domains/#list
9
+ # @see https://developer.dnsimple.com/v2/domains/#listDomains
10
10
  # @see #all_domains
11
11
  #
12
12
  # @example List domains in the first page
13
- # client.domains.list(1010)
13
+ # client.domains.domains(1010)
14
14
  #
15
15
  # @example List domains, provide a specific page
16
- # client.domains.list(1010, page: 2)
16
+ # client.domains.domains(1010, page: 2)
17
17
  #
18
18
  # @example List domains, provide a sorting policy
19
- # client.domains.list(1010, sort: "expiration:asc")
19
+ # client.domains.domains(1010, sort: "expiration:asc")
20
20
  #
21
21
  # @example List domains, provide a filtering policy
22
- # client.domains.list(1010, filter: { name_like: "example" })
22
+ # client.domains.domains(1010, filter: { name_like: "example" })
23
23
  #
24
24
  # @param [Integer] account_id the account ID
25
25
  # @param [Hash] options the filtering and sorting options
@@ -45,7 +45,7 @@ module Dnsimple
45
45
  # Please use this method carefully, as fetching the entire collection will increase the number of requests
46
46
  # you send to the API server and you may eventually risk to hit the throttle limit.
47
47
  #
48
- # @see https://developer.dnsimple.com/v2/domains/#list
48
+ # @see https://developer.dnsimple.com/v2/domains/#listDomains
49
49
  # @see #domains
50
50
  #
51
51
  # @param [Integer] account_id the account ID
@@ -63,7 +63,10 @@ module Dnsimple
63
63
 
64
64
  # Creates a domain in the account.
65
65
  #
66
- # @see https://developer.dnsimple.com/v2/domains/#create
66
+ # @see https://developer.dnsimple.com/v2/domains/#createDomain
67
+ #
68
+ # @example Creating a domain in a specific account. Does not register the domain
69
+ # client.domains.create_domain(1010, name: "example.com")
67
70
  #
68
71
  # @param [Integer] account_id the account ID
69
72
  # @param [Hash] attributes
@@ -81,7 +84,13 @@ module Dnsimple
81
84
 
82
85
  # Gets a domain from the account.
83
86
  #
84
- # @see https://developer.dnsimple.com/v2/domains/#get
87
+ # @see https://developer.dnsimple.com/v2/domains/#getDomain
88
+ #
89
+ #
90
+ # @example Getting a domain in a specific account, by domain id
91
+ # client.domains.domain(1010, 12345)
92
+ # @example Getting a domain in a specific account, by domain name
93
+ # client.domains.domain(1010, "example.com")
85
94
  #
86
95
  # @param [Integer] account_id the account ID
87
96
  # @param [#to_s] domain_id The domain ID or domain name
@@ -100,7 +109,12 @@ module Dnsimple
100
109
  #
101
110
  # WARNING: this cannot be undone.
102
111
  #
103
- # @see https://developer.dnsimple.com/v2/domains/#delete
112
+ # @see https://developer.dnsimple.com/v2/domains/#deleteDomain
113
+ #
114
+ # @example Deleting a domain in a specific account, by domain id
115
+ # client.domains.delete_domain(1010, 12345)
116
+ # @example Deleting a domain in a specific account, by domain name
117
+ # client.domains.delete_domain(1010, "example.com")
104
118
  #
105
119
  # @param [Integer] account_id the account ID
106
120
  # @param [#to_s] domain_id The domain ID or domain name
@@ -24,35 +24,6 @@ module Dnsimple
24
24
  Dnsimple::Response.new(response, Struct::DomainCheck.new(response["data"]))
25
25
  end
26
26
 
27
- # Checks the premium price for a domain
28
- #
29
- # @see https://developer.dnsimple.com/v2/registrar/#premium-price
30
- #
31
- # @example Check the ruby.codes premium price:
32
- # client.registrar.domain_premium_price(1010, "ruby.codes")
33
- #
34
- # @example Check the ruby.codes premium price for transfer:
35
- # client.registrar.domain_premium_price(1010, "ruby.codes", action: "transfer")
36
- #
37
- # @param [Integer] account_id the account ID
38
- # @param [#to_s] domain_name the domain name to check
39
- # @param [Hash] options
40
- # @option options [String] :action Optional action between "registration",
41
- # "renewal", and "transfer". If omitted, it defaults to "registration".
42
- # @return [Struct::DomainPremiumPrice]
43
- #
44
- # @raise [RequestError] When the request fails.
45
- #
46
- # @deprecated Use {#get_domain_prices} instead of this one as it will soon be removed from the API.
47
- def domain_premium_price(account_id, domain_name, options = {})
48
- Dnsimple.deprecate("Use {#get_domain_prices} instead of this one as it will soon be removed from the API.")
49
- endpoint = Client.versioned("/%s/registrar/domains/%s/premium_price" % [account_id, domain_name])
50
- options[:query] = { action: options.delete(:action) } if options.key?(:action)
51
- response = client.get(endpoint, options)
52
-
53
- Dnsimple::Response.new(response, Struct::DomainPremiumPrice.new(response["data"]))
54
- end
55
-
56
27
  # Get prices for a domain.
57
28
  # @see https://developer.dnsimple.com/v2/registrar/#getDomainPrices
58
29
  #
@@ -36,43 +36,43 @@ module Dnsimple
36
36
  # Default API endpoint from ENV or {BASE_URL}
37
37
  # @return [String]
38
38
  def base_url
39
- ENV['DNSIMPLE_BASE_URL'] || BASE_URL
39
+ ENV.fetch('DNSIMPLE_BASE_URL', BASE_URL)
40
40
  end
41
41
 
42
42
  # Default DNSimple username for Basic Auth from ENV
43
43
  # @return [String]
44
44
  def username
45
- ENV['DNSIMPLE_USERNAME']
45
+ ENV.fetch('DNSIMPLE_USERNAME', nil)
46
46
  end
47
47
 
48
48
  # Default DNSimple password for Basic Auth from ENV
49
49
  # @return [String]
50
50
  def password
51
- ENV['DNSIMPLE_PASSWORD']
51
+ ENV.fetch('DNSIMPLE_PASSWORD', nil)
52
52
  end
53
53
 
54
54
  # Default DNSimple access token for OAuth authentication from ENV
55
55
  # @return [String]
56
56
  def access_token
57
- ENV['DNSIMPLE_ACCESS_TOKEN']
57
+ ENV.fetch('DNSIMPLE_ACCESS_TOKEN', nil)
58
58
  end
59
59
 
60
60
  # Default DNSimple Domain API Token for Token Auth from ENV
61
61
  # @return [String]
62
62
  def domain_api_token
63
- ENV['DNSIMPLE_API_DOMAIN_TOKEN']
63
+ ENV.fetch('DNSIMPLE_API_DOMAIN_TOKEN', nil)
64
64
  end
65
65
 
66
66
  # Default User-Agent header string from ENV
67
67
  # @return [String]
68
68
  def user_agent
69
- ENV['DNSIMPLE_USER_AGENT']
69
+ ENV.fetch('DNSIMPLE_USER_AGENT', nil)
70
70
  end
71
71
 
72
72
  # Default Proxy address:port from ENV
73
73
  # @return [String]
74
74
  def proxy
75
- ENV['DNSIMPLE_PROXY']
75
+ ENV.fetch('DNSIMPLE_PROXY', nil)
76
76
  end
77
77
 
78
78
  end
@@ -7,18 +7,24 @@ module Dnsimple
7
7
 
8
8
  # RequestError is raised when an API request fails for an client, a server error or invalid request information.
9
9
  class RequestError < Error
10
- attr_reader :http_response
10
+ attr_reader :http_response, :attribute_errors
11
11
 
12
12
  def initialize(http_response)
13
13
  @http_response = http_response
14
+ @attribute_errors = attribute_errors_from(http_response)
14
15
  super(message_from(http_response))
15
16
  end
16
17
 
17
18
  private
18
19
 
20
+ def attribute_errors_from(http_response)
21
+ return unless is_json_response?(http_response)
22
+
23
+ http_response.parsed_response["errors"]
24
+ end
25
+
19
26
  def message_from(http_response)
20
- content_type = http_response.headers["Content-Type"]
21
- if content_type&.start_with?("application/json")
27
+ if is_json_response?(http_response)
22
28
  http_response.parsed_response["message"]
23
29
  else
24
30
  net_http_response = http_response.response
@@ -26,6 +32,11 @@ module Dnsimple
26
32
  end
27
33
  end
28
34
 
35
+ def is_json_response?(http_response)
36
+ content_type = http_response.headers["Content-Type"]
37
+ content_type&.start_with?("application/json")
38
+ end
39
+
29
40
  end
30
41
 
31
42
  class NotFoundError < RequestError
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dnsimple
4
- VERSION = "7.1.1"
4
+ VERSION = "8.1.0"
5
5
  end
@@ -68,8 +68,8 @@ describe Dnsimple::Client, ".certificates" do
68
68
  let(:domain_id) { "dnsimple.us" }
69
69
 
70
70
  it "delegates to client.paginate" do
71
- expect(subject).to receive(:paginate).with(:certificates, account_id, domain_id, foo: "bar")
72
- subject.all_certificates(account_id, domain_id, foo: "bar")
71
+ expect(subject).to receive(:paginate).with(:certificates, account_id, domain_id, { foo: "bar" })
72
+ subject.all_certificates(account_id, domain_id, { foo: "bar" })
73
73
  end
74
74
 
75
75
  it "supports sorting" do
@@ -232,7 +232,6 @@ describe Dnsimple::Client, ".certificates" do
232
232
  describe "#purchase_letsencrypt_certificate" do
233
233
  let(:account_id) { 1010 }
234
234
  let(:domain_id) { "bingo.pizza" }
235
- let(:contact_id) { 100 }
236
235
 
237
236
  before do
238
237
  stub_request(:post, %r{/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt})
@@ -240,7 +239,7 @@ describe Dnsimple::Client, ".certificates" do
240
239
  end
241
240
 
242
241
  it "builds the correct request" do
243
- attributes = { contact_id: contact_id }
242
+ attributes = {}
244
243
  subject.purchase_letsencrypt_certificate(account_id, domain_id, attributes)
245
244
 
246
245
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt")
@@ -249,7 +248,7 @@ describe Dnsimple::Client, ".certificates" do
249
248
  end
250
249
 
251
250
  it "passes extra attributes" do
252
- attributes = { contact_id: contact_id, name: "www", auto_renew: true, alternate_names: ["api.example.com"] }
251
+ attributes = { name: "www", auto_renew: true, alternate_names: ["api.example.com"] }
253
252
  subject.purchase_letsencrypt_certificate(account_id, domain_id, attributes)
254
253
 
255
254
  expect(WebMock).to have_requested(:post, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/certificates/letsencrypt")
@@ -258,7 +257,7 @@ describe Dnsimple::Client, ".certificates" do
258
257
  end
259
258
 
260
259
  it "returns the certificate purchase" do
261
- response = subject.purchase_letsencrypt_certificate(account_id, domain_id, contact_id: contact_id)
260
+ response = subject.purchase_letsencrypt_certificate(account_id, domain_id)
262
261
  expect(response).to be_a(Dnsimple::Response)
263
262
 
264
263
  result = response.data
@@ -276,7 +275,7 @@ describe Dnsimple::Client, ".certificates" do
276
275
  .to_return(read_http_fixture("notfound-domain.http"))
277
276
 
278
277
  expect {
279
- subject.purchase_letsencrypt_certificate(account_id, domain_id, contact_id: contact_id)
278
+ subject.purchase_letsencrypt_certificate(account_id, domain_id)
280
279
  }.to raise_error(Dnsimple::NotFoundError)
281
280
  end
282
281
  end
@@ -311,7 +310,7 @@ describe Dnsimple::Client, ".certificates" do
311
310
  expect(result.common_name).to eq("www.bingo.pizza")
312
311
  expect(result.alternate_names).to eq([])
313
312
  expect(result.years).to eq(1)
314
- expect(result.csr).to be(nil)
313
+ expect(result.csr).to be_nil
315
314
  expect(result.state).to eq("requesting")
316
315
  expect(result.authority_identifier).to eq("letsencrypt")
317
316
  expect(result.auto_renew).to be(false)
@@ -421,7 +420,7 @@ describe Dnsimple::Client, ".certificates" do
421
420
  expect(result.common_name).to eq("www.bingo.pizza")
422
421
  expect(result.alternate_names).to eq([])
423
422
  expect(result.years).to eq(1)
424
- expect(result.csr).to be(nil)
423
+ expect(result.csr).to be_nil
425
424
  expect(result.state).to eq("requesting")
426
425
  expect(result.authority_identifier).to eq("letsencrypt")
427
426
  expect(result.auto_renew).to be(false)
@@ -73,8 +73,8 @@ describe Dnsimple::Client, ".contacts" do
73
73
  let(:account_id) { 1010 }
74
74
 
75
75
  it "delegates to client.paginate" do
76
- expect(subject).to receive(:paginate).with(:contacts, account_id, foo: "bar")
77
- subject.all_contacts(account_id, foo: "bar")
76
+ expect(subject).to receive(:paginate).with(:contacts, account_id, { foo: "bar" })
77
+ subject.all_contacts(account_id, { foo: "bar" })
78
78
  end
79
79
 
80
80
  it "supports sorting" do
@@ -116,8 +116,8 @@ describe Dnsimple::Client, ".domains" do
116
116
  result = response.data
117
117
  expect(result).to be_a(Dnsimple::Struct::Collaborator)
118
118
  expect(result.id).to be_a(Integer)
119
- expect(result.user_id).to be(nil)
120
- expect(result.accepted_at).to be(nil)
119
+ expect(result.user_id).to be_nil
120
+ expect(result.accepted_at).to be_nil
121
121
  expect(result.user_email).to eq(attributes.fetch(:email))
122
122
  expect(result.invitation).to be(true)
123
123
  end
@@ -86,8 +86,8 @@ describe Dnsimple::Client, ".domains" do
86
86
  let(:domain_id) { "example.com" }
87
87
 
88
88
  it "delegates to client.paginate" do
89
- expect(subject).to receive(:paginate).with(:delegation_signer_records, account_id, domain_id, foo: "bar")
90
- subject.all_delegation_signer_records(account_id, domain_id, foo: "bar")
89
+ expect(subject).to receive(:paginate).with(:delegation_signer_records, account_id, domain_id, { foo: "bar" })
90
+ subject.all_delegation_signer_records(account_id, domain_id, { foo: "bar" })
91
91
  end
92
92
 
93
93
  it "supports sorting" do
@@ -86,8 +86,8 @@ describe Dnsimple::Client, ".domains" do
86
86
  let(:domain_id) { "example.com" }
87
87
 
88
88
  it "delegates to client.paginate" do
89
- expect(subject).to receive(:paginate).with(:email_forwards, account_id, domain_id, foo: "bar")
90
- subject.all_email_forwards(account_id, domain_id, foo: "bar")
89
+ expect(subject).to receive(:paginate).with(:email_forwards, account_id, domain_id, { foo: "bar" })
90
+ subject.all_email_forwards(account_id, domain_id, { foo: "bar" })
91
91
  end
92
92
 
93
93
  it "supports sorting" do
@@ -79,8 +79,8 @@ describe Dnsimple::Client, ".domains" do
79
79
  let(:account_id) { 1010 }
80
80
 
81
81
  it "delegates to client.paginate" do
82
- expect(subject).to receive(:paginate).with(:domains, account_id, foo: "bar")
83
- subject.all_domains(account_id, foo: "bar")
82
+ expect(subject).to receive(:paginate).with(:domains, account_id, { foo: "bar" })
83
+ subject.all_domains(account_id, { foo: "bar" })
84
84
  end
85
85
 
86
86
  it "supports sorting" do
@@ -34,54 +34,6 @@ describe Dnsimple::Client, ".registrar" do
34
34
  end
35
35
  end
36
36
 
37
- describe "#domain_premium_price" do
38
- let(:account_id) { 1010 }
39
-
40
- context "when premium price" do
41
- before do
42
- stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/premium_price[?action]*})
43
- .to_return(read_http_fixture("getDomainPremiumPrice/success.http"))
44
- end
45
-
46
- it "builds the correct request" do
47
- subject.domain_premium_price(account_id, domain_name = "ruby.codes")
48
-
49
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/premium_price")
50
- .with(headers: { "Accept" => "application/json" })
51
- end
52
-
53
- it "returns the premium price" do
54
- response = subject.domain_premium_price(account_id, "ruby.codes")
55
- expect(response).to be_a(Dnsimple::Response)
56
-
57
- result = response.data
58
- expect(result).to be_a(Dnsimple::Struct::DomainPremiumPrice)
59
- expect(result.premium_price).to eq("109.00")
60
- expect(result.action).to eq("registration")
61
- end
62
-
63
- it "builds the correct request when action is passed" do
64
- subject.domain_premium_price(account_id, domain_name = "ruby.codes", action: "registration")
65
-
66
- expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/registrar/domains/#{domain_name}/premium_price?action=registration")
67
- .with(headers: { "Accept" => "application/json" })
68
- end
69
- end
70
-
71
- context "when not premium price" do
72
- before do
73
- stub_request(:get, %r{/v2/#{account_id}/registrar/domains/.+/premium_price$})
74
- .to_return(read_http_fixture("getDomainPremiumPrice/failure.http"))
75
- end
76
-
77
- it "raises error" do
78
- expect {
79
- subject.domain_premium_price(account_id, "example.com")
80
- }.to raise_error(Dnsimple::RequestError, "`example.com` is not a premium domain for registration")
81
- end
82
- end
83
- end
84
-
85
37
  describe "#get_domain_prices" do
86
38
  let(:account_id) { 1010 }
87
39
 
@@ -317,7 +269,7 @@ describe Dnsimple::Client, ".registrar" do
317
269
  expect(result.state).to eq("transferring")
318
270
  expect(result.auto_renew).to be(false)
319
271
  expect(result.whois_privacy).to be(false)
320
- expect(result.status_description).to eq(nil)
272
+ expect(result.status_description).to be_nil
321
273
  expect(result.created_at).to eq("2020-06-05T18:08:00Z")
322
274
  expect(result.updated_at).to eq("2020-06-05T18:08:04Z")
323
275
  end
@@ -28,9 +28,9 @@ describe Dnsimple::Client, ".registrar" do
28
28
 
29
29
  result = response.data
30
30
  expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
31
- expect(result.domain_id).to be_kind_of(Integer)
31
+ expect(result.domain_id).to be_a(Integer)
32
32
  expect(result.enabled).to be(true)
33
- expect(result.expires_on).to be_kind_of(String)
33
+ expect(result.expires_on).to be_a(String)
34
34
  end
35
35
  end
36
36
 
@@ -57,9 +57,9 @@ describe Dnsimple::Client, ".registrar" do
57
57
 
58
58
  result = response.data
59
59
  expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
60
- expect(result.domain_id).to be_kind_of(Integer)
60
+ expect(result.domain_id).to be_a(Integer)
61
61
  expect(result.enabled).to be(true)
62
- expect(result.expires_on).to be_kind_of(String)
62
+ expect(result.expires_on).to be_a(String)
63
63
  end
64
64
  end
65
65
 
@@ -83,7 +83,7 @@ describe Dnsimple::Client, ".registrar" do
83
83
 
84
84
  result = response.data
85
85
  expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
86
- expect(result.domain_id).to be_kind_of(Integer)
86
+ expect(result.domain_id).to be_a(Integer)
87
87
  expect(result.enabled).to be_nil
88
88
  expect(result.expires_on).to be_nil
89
89
  end
@@ -112,9 +112,9 @@ describe Dnsimple::Client, ".registrar" do
112
112
 
113
113
  result = response.data
114
114
  expect(result).to be_a(Dnsimple::Struct::WhoisPrivacy)
115
- expect(result.domain_id).to be_kind_of(Integer)
115
+ expect(result.domain_id).to be_a(Integer)
116
116
  expect(result.enabled).to be(false)
117
- expect(result.expires_on).to be_kind_of(String)
117
+ expect(result.expires_on).to be_a(String)
118
118
  end
119
119
  end
120
120
 
@@ -140,10 +140,10 @@ describe Dnsimple::Client, ".registrar" do
140
140
 
141
141
  result = response.data
142
142
  expect(result).to be_a(Dnsimple::Struct::WhoisPrivacyRenewal)
143
- expect(result.domain_id).to be_kind_of(Integer)
144
- expect(result.whois_privacy_id).to be_kind_of(Integer)
143
+ expect(result.domain_id).to be_a(Integer)
144
+ expect(result.whois_privacy_id).to be_a(Integer)
145
145
  expect(result.enabled).to be(true)
146
- expect(result.expires_on).to be_kind_of(String)
146
+ expect(result.expires_on).to be_a(String)
147
147
  end
148
148
 
149
149
  context "when whois privacy was't previously purchased" do
@@ -61,7 +61,7 @@ describe Dnsimple::Client, ".services" do
61
61
  end
62
62
 
63
63
  it "delegates to client.paginate" do
64
- expect(subject).to receive(:paginate).with(:services, foo: "bar")
64
+ expect(subject).to receive(:paginate).with(:services, { foo: "bar" })
65
65
  subject.all_services(foo: "bar")
66
66
  end
67
67
 
@@ -65,7 +65,7 @@ describe Dnsimple::Client, ".templates" do
65
65
  let(:template_id) { "alpha" }
66
66
 
67
67
  it "delegates to client.paginate" do
68
- expect(subject).to receive(:paginate).with(:records, account_id, template_id, option: "value")
68
+ expect(subject).to receive(:paginate).with(:records, account_id, template_id, { option: "value" })
69
69
  subject.all_records(account_id, template_id, option: "value")
70
70
  end
71
71
 
@@ -64,8 +64,8 @@ describe Dnsimple::Client, ".templates" do
64
64
  let(:account_id) { 1010 }
65
65
 
66
66
  it "delegates to client.paginate" do
67
- expect(subject).to receive(:paginate).with(:templates, account_id, foo: "bar")
68
- subject.all_templates(account_id, foo: "bar")
67
+ expect(subject).to receive(:paginate).with(:templates, account_id, { foo: "bar" })
68
+ subject.all_templates(account_id, { foo: "bar" })
69
69
  end
70
70
 
71
71
  it "supports sorting" do
@@ -68,7 +68,7 @@ describe Dnsimple::Client, ".tlds" do
68
68
  end
69
69
 
70
70
  it "delegates to client.paginate" do
71
- expect(subject).to receive(:paginate).with(:list_tlds, foo: "bar")
71
+ expect(subject).to receive(:paginate).with(:list_tlds, { foo: "bar" })
72
72
  subject.all_tlds(foo: "bar")
73
73
  end
74
74
 
@@ -93,8 +93,8 @@ describe Dnsimple::Client, ".zones" do
93
93
  let(:zone_id) { "example.com" }
94
94
 
95
95
  it "delegates to client.paginate" do
96
- expect(subject).to receive(:paginate).with(:list_zone_records, account_id, zone_id, foo: "bar")
97
- subject.all_zone_records(account_id, zone_id, foo: "bar")
96
+ expect(subject).to receive(:paginate).with(:list_zone_records, account_id, zone_id, { foo: "bar" })
97
+ subject.all_zone_records(account_id, zone_id, { foo: "bar" })
98
98
  end
99
99
 
100
100
  it "supports sorting" do
@@ -179,7 +179,7 @@ describe Dnsimple::Client, ".zones" do
179
179
  expect(result).to be_a(Dnsimple::Struct::ZoneRecord)
180
180
  expect(result.id).to eq(record_id)
181
181
  expect(result.zone_id).to eq("example.com")
182
- expect(result.parent_id).to eq(nil)
182
+ expect(result.parent_id).to be_nil
183
183
  expect(result.type).to eq("MX")
184
184
  expect(result.name).to eq("")
185
185
  expect(result.content).to eq("mxa.example.com")
@@ -79,8 +79,8 @@ describe Dnsimple::Client, ".zones" do
79
79
  let(:account_id) { 1010 }
80
80
 
81
81
  it "delegates to client.paginate" do
82
- expect(subject).to receive(:paginate).with(:zones, account_id, foo: "bar")
83
- subject.all_zones(account_id, foo: "bar")
82
+ expect(subject).to receive(:paginate).with(:zones, account_id, { foo: "bar" })
83
+ subject.all_zones(account_id, { foo: "bar" })
84
84
  end
85
85
 
86
86
  it "supports sorting" do
@@ -49,36 +49,36 @@ describe Dnsimple::Client do
49
49
 
50
50
  describe "#get" do
51
51
  it "delegates to #request" do
52
- allow(subject).to receive(:execute).with(:get, "path", nil, foo: "bar").and_return(:returned)
53
- expect(subject.get("path", foo: "bar")).to eq(:returned)
52
+ allow(subject).to receive(:execute).with(:get, "path", nil, { foo: "bar" }).and_return(:returned)
53
+ expect(subject.get("path", { foo: "bar" })).to eq(:returned)
54
54
  end
55
55
  end
56
56
 
57
57
  describe "#post" do
58
58
  it "delegates to #request" do
59
59
  allow(subject).to receive(:execute).with(:post, "path", { foo: "bar" }, {}).and_return(:returned)
60
- expect(subject.post("path", foo: "bar")).to eq(:returned)
60
+ expect(subject.post("path", { foo: "bar" })).to eq(:returned)
61
61
  end
62
62
  end
63
63
 
64
64
  describe "#put" do
65
65
  it "delegates to #request" do
66
66
  allow(subject).to receive(:execute).with(:put, "path", { foo: "bar" }, {}).and_return(:returned)
67
- expect(subject.put("path", foo: "bar")).to eq(:returned)
67
+ expect(subject.put("path", { foo: "bar" })).to eq(:returned)
68
68
  end
69
69
  end
70
70
 
71
71
  describe "#patch" do
72
72
  it "delegates to #request" do
73
73
  allow(subject).to receive(:execute).with(:patch, "path", { foo: "bar" }, {}).and_return(:returned)
74
- expect(subject.patch("path", foo: "bar")).to eq(:returned)
74
+ expect(subject.patch("path", { foo: "bar" })).to eq(:returned)
75
75
  end
76
76
  end
77
77
 
78
78
  describe "#delete" do
79
79
  it "delegates to #request" do
80
80
  allow(subject).to receive(:execute).with(:delete, "path", { foo: "bar" }, {}).and_return(:returned)
81
- expect(subject.delete("path", foo: "bar")).to eq(:returned)
81
+ expect(subject.delete("path", { foo: "bar" })).to eq(:returned)
82
82
  end
83
83
  end
84
84
 
@@ -90,7 +90,22 @@ describe Dnsimple::Client do
90
90
 
91
91
  expect {
92
92
  subject.execute(:post, "foo", {})
93
- }.to raise_error(Dnsimple::RequestError, "The domain google.com is already in DNSimple and cannot be added")
93
+ }.to raise_error(Dnsimple::RequestError, "The domain google.com is already in DNSimple and cannot be added") do |exception|
94
+ expect(exception.attribute_errors).to be_nil
95
+ end
96
+ end
97
+
98
+ it "raises a Request error in case of an error with a JSON response with attribute errors" do
99
+ stub_request(:post, %r{/foo}).to_return(read_http_fixture("validation-error.http"))
100
+
101
+ expect {
102
+ subject.execute(:post, "foo", {})
103
+ }.to raise_error(Dnsimple::RequestError, "Validation failed") do |exception|
104
+ expect(exception).to respond_to(:attribute_errors)
105
+ expect(exception.attribute_errors).to be_a(Hash)
106
+ expect(exception.attribute_errors["email"]).to eq(["can't be blank", "is an invalid email address"])
107
+ expect(exception.attribute_errors["address1"]).to eq(["can't be blank"])
108
+ end
94
109
  end
95
110
 
96
111
  it "raises RequestError in case of error with an HTML response" do
@@ -98,7 +113,9 @@ describe Dnsimple::Client do
98
113
 
99
114
  expect {
100
115
  subject.execute(:get, "foo", {})
101
- }.to raise_error(Dnsimple::RequestError, "502 Bad Gateway")
116
+ }.to raise_error(Dnsimple::RequestError, "502 Bad Gateway") do |exception|
117
+ expect(exception.attribute_errors).to be_nil
118
+ end
102
119
  end
103
120
 
104
121
  it "raises RequestError in absence of content types" do
@@ -106,7 +123,9 @@ describe Dnsimple::Client do
106
123
 
107
124
  expect {
108
125
  subject.execute(:put, "foo", {})
109
- }.to raise_error(Dnsimple::RequestError, "405 Method Not Allowed")
126
+ }.to raise_error(Dnsimple::RequestError, "405 Method Not Allowed") do |exception|
127
+ expect(exception.attribute_errors).to be_nil
128
+ end
110
129
  end
111
130
  end
112
131
 
@@ -126,14 +145,14 @@ describe Dnsimple::Client do
126
145
  it "delegates to HTTParty" do
127
146
  stub_request(:get, %r{/foo})
128
147
 
129
- allow(HTTParty).to receive(:get)
148
+ expect(HTTParty).to receive(:get)
130
149
  .with(
131
- "#{subject.base_url}foo",
132
- format: :json,
133
- basic_auth: { username: "user", password: "pass" },
134
- headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT }
150
+ "#{subject.base_url}foo", {
151
+ format: :json,
152
+ basic_auth: { username: "user", password: "pass" },
153
+ headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT },
154
+ }
135
155
  )
136
- .and_return(instance_double('response', code: 200))
137
156
 
138
157
  subject.request(:get, 'foo')
139
158
  end
@@ -141,58 +160,65 @@ describe Dnsimple::Client do
141
160
  it "properly extracts processes options and encodes data" do
142
161
  allow(HTTParty).to receive(:put)
143
162
  .with(
144
- "#{subject.base_url}foo",
145
- format: :json,
146
- body: JSON.dump(something: "else"),
147
- query: { foo: "bar" },
148
- basic_auth: { username: "user", password: "pass" },
149
- headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT, "Custom" => "Header" }
163
+ "#{subject.base_url}foo", {
164
+ format: :json,
165
+ body: JSON.dump(something: "else"),
166
+ query: { foo: "bar" },
167
+ basic_auth: { username: "user", password: "pass" },
168
+ headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT, "Custom" => "Header" },
169
+ }
150
170
  )
151
- .and_return(instance_double('response', code: 200))
152
171
 
153
- subject.request(:put, 'foo', { something: "else" }, { query: { foo: "bar" }, headers: { "Custom" => "Header" } })
172
+ expect {
173
+ subject.request(:put, 'foo', { something: "else" }, { query: { foo: "bar" }, headers: { "Custom" => "Header" } })
174
+ }.not_to raise_error
154
175
  end
155
176
 
156
177
  it "handles non application/json content types" do
157
178
  allow(HTTParty).to receive(:post)
158
179
  .with(
159
- "#{subject.base_url}foo",
160
- format: :json,
161
- body: { something: "else" },
162
- basic_auth: { username: "user", password: "pass" },
163
- headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => Dnsimple::Default::USER_AGENT }
180
+ "#{subject.base_url}foo", {
181
+ format: :json,
182
+ body: { something: "else" },
183
+ basic_auth: { username: "user", password: "pass" },
184
+ headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', 'User-Agent' => Dnsimple::Default::USER_AGENT },
185
+ }
164
186
  )
165
- .and_return(instance_double('response', code: 200))
166
187
 
167
- subject.request(:post, 'foo', { something: "else" }, { headers: { "Content-Type" => "application/x-www-form-urlencoded" } })
188
+ expect {
189
+ subject.request(:post, 'foo', { something: "else" }, { headers: { "Content-Type" => "application/x-www-form-urlencoded" } })
190
+ }.not_to raise_error
168
191
  end
169
192
 
170
193
  it "includes options for proxy support" do
171
194
  allow(HTTParty).to receive(:get)
172
195
  .with(
173
- "#{subject.base_url}test",
174
- format: :json,
175
- http_proxyaddr: "example-proxy.com",
176
- http_proxyport: "4321",
177
- headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT }
196
+ "#{subject.base_url}test", {
197
+ format: :json,
198
+ http_proxyaddr: "example-proxy.com",
199
+ http_proxyport: "4321",
200
+ headers: { 'Accept' => 'application/json', 'User-Agent' => Dnsimple::Default::USER_AGENT },
201
+ }
178
202
  )
179
- .and_return(instance_double('response', code: 200))
180
203
 
181
- subject = described_class.new(proxy: "example-proxy.com:4321")
182
- subject.request(:get, "test", nil, {})
204
+ expect {
205
+ subject = described_class.new(proxy: "example-proxy.com:4321")
206
+ subject.request(:get, "test", nil, {})
207
+ }.not_to raise_error
183
208
  end
184
209
 
185
210
  it "supports custom user agent" do
186
211
  allow(HTTParty).to receive(:get)
187
212
  .with(
188
213
  "#{subject.base_url}test",
189
- format: :json,
190
- headers: hash_including("User-Agent" => "customAgent #{Dnsimple::Default::USER_AGENT}")
214
+ { format: :json,
215
+ headers: hash_including("User-Agent" => "customAgent #{Dnsimple::Default::USER_AGENT}"), }
191
216
  )
192
- .and_return(instance_double("response", code: 200))
193
217
 
194
- subject = described_class.new(user_agent: "customAgent")
195
- subject.request(:get, "test", nil)
218
+ expect {
219
+ subject = described_class.new(user_agent: "customAgent")
220
+ subject.request(:get, "test", nil)
221
+ }.not_to raise_error
196
222
  end
197
223
  end
198
224
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DNSimple
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-20 00:00:00.000000000 Z
11
+ date: 2022-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -98,6 +98,7 @@ files:
98
98
  - ".rubocop.yml"
99
99
  - ".rubocop_dnsimple.yml"
100
100
  - ".rubocop_todo.yml"
101
+ - ".yamllint.yml"
101
102
  - CHANGELOG.md
102
103
  - CONTRIBUTING.md
103
104
  - Gemfile
@@ -367,14 +368,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
367
368
  requirements:
368
369
  - - ">="
369
370
  - !ruby/object:Gem::Version
370
- version: '2.6'
371
+ version: '2.7'
371
372
  required_rubygems_version: !ruby/object:Gem::Requirement
372
373
  requirements:
373
374
  - - ">="
374
375
  - !ruby/object:Gem::Version
375
376
  version: '0'
376
377
  requirements: []
377
- rubygems_version: 3.3.3
378
+ rubygems_version: 3.3.7
378
379
  signing_key:
379
380
  specification_version: 4
380
381
  summary: The DNSimple API client for Ruby