dnsimple 3.0.0 → 3.1.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/CHANGELOG.md +20 -2
- data/README.md +5 -4
- data/dnsimple.gemspec +3 -3
- data/lib/dnsimple.rb +1 -0
- data/lib/dnsimple/client.rb +37 -11
- data/lib/dnsimple/client/accounts.rb +26 -0
- data/lib/dnsimple/client/clients.rb +15 -1
- data/lib/dnsimple/client/contacts.rb +16 -7
- data/lib/dnsimple/client/domains.rb +20 -6
- data/lib/dnsimple/client/domains_email_forwards.rb +17 -8
- data/lib/dnsimple/client/identity.rb +2 -5
- data/lib/dnsimple/client/registrar.rb +1 -1
- data/lib/dnsimple/client/registrar_auto_renewal.rb +2 -2
- data/lib/dnsimple/client/services.rb +15 -3
- data/lib/dnsimple/client/templates.rb +16 -4
- data/lib/dnsimple/client/templates_records.rb +135 -0
- data/lib/dnsimple/client/tlds.rb +13 -4
- data/lib/dnsimple/client/webhooks.rb +11 -2
- data/lib/dnsimple/client/zones.rb +19 -5
- data/lib/dnsimple/client/zones_records.rb +48 -11
- data/lib/dnsimple/default.rb +2 -2
- data/lib/dnsimple/extra.rb +3 -3
- data/lib/dnsimple/options.rb +53 -0
- data/lib/dnsimple/struct.rb +2 -0
- data/lib/dnsimple/struct/account.rb +3 -0
- data/lib/dnsimple/struct/contact.rb +0 -3
- data/lib/dnsimple/struct/record.rb +2 -2
- data/lib/dnsimple/struct/template_record.rb +34 -0
- data/lib/dnsimple/struct/whoami.rb +30 -0
- data/lib/dnsimple/version.rb +1 -1
- data/spec/dnsimple/client/accounts_spec.rb +31 -0
- data/spec/dnsimple/client/contacts_spec.rb +19 -2
- data/spec/dnsimple/client/domains_email_forwards_spec.rb +18 -1
- data/spec/dnsimple/client/domains_spec.rb +30 -1
- data/spec/dnsimple/client/identity_spec.rb +6 -6
- data/spec/dnsimple/client/services_spec.rb +30 -1
- data/spec/dnsimple/client/templates_records_spec.rb +226 -0
- data/spec/dnsimple/client/templates_spec.rb +30 -1
- data/spec/dnsimple/client/tlds_spec.rb +18 -1
- data/spec/dnsimple/client/webhooks_spec.rb +6 -0
- data/spec/dnsimple/client/zones_records_spec.rb +30 -1
- data/spec/dnsimple/client/zones_spec.rb +30 -1
- data/spec/dnsimple/client_spec.rb +35 -14
- data/spec/dnsimple/options/base_spec.rb +22 -0
- data/spec/dnsimple/options/list_options_spec.rb +100 -0
- data/spec/fixtures.http/accounts/success-account.http +21 -0
- data/spec/fixtures.http/accounts/success-user.http +21 -0
- data/spec/fixtures.http/createContact/created.http +1 -1
- data/spec/fixtures.http/createTemplateRecord/created.http +17 -0
- data/spec/fixtures.http/deleteTemplateRecord/success.http +13 -0
- data/spec/fixtures.http/getContact/success.http +1 -1
- data/spec/fixtures.http/getTemplateRecord/success.http +17 -0
- data/spec/fixtures.http/listContacts/success.http +1 -1
- data/spec/fixtures.http/listTemplateRecords/success.http +17 -0
- data/spec/fixtures.http/notfound-template.http +12 -0
- data/spec/fixtures.http/updateContact/success.http +1 -1
- data/spec/spec_helper.rb +0 -11
- metadata +35 -2
data/lib/dnsimple/default.rb
CHANGED
@@ -61,10 +61,10 @@ module Dnsimple
|
|
61
61
|
ENV['DNSIMPLE_API_DOMAIN_TOKEN']
|
62
62
|
end
|
63
63
|
|
64
|
-
# Default User-Agent header string from ENV
|
64
|
+
# Default User-Agent header string from ENV
|
65
65
|
# @return [String]
|
66
66
|
def user_agent
|
67
|
-
ENV['DNSIMPLE_USER_AGENT']
|
67
|
+
ENV['DNSIMPLE_USER_AGENT']
|
68
68
|
end
|
69
69
|
|
70
70
|
# Default Proxy address:port from ENV
|
data/lib/dnsimple/extra.rb
CHANGED
@@ -13,20 +13,20 @@ module Dnsimple
|
|
13
13
|
# h1 = { a: true, b: { c: [1, 2, 3] } }
|
14
14
|
# h2 = { a: false, b: { x: [3, 4, 5] } }
|
15
15
|
#
|
16
|
-
#
|
16
|
+
# Extra.deep_merge(h1, h2) #=> { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }
|
17
17
|
#
|
18
18
|
# Like with Hash#merge in the standard library, a block can be provided
|
19
19
|
# to merge values:
|
20
20
|
#
|
21
21
|
# h1 = { a: 100, b: 200, c: { c1: 100 } }
|
22
22
|
# h2 = { b: 250, c: { c1: 200 } }
|
23
|
-
#
|
23
|
+
# Extra.deep_merge(h1, h2) { |key, this_val, other_val| this_val + other_val }
|
24
24
|
# # => { a: 100, b: 450, c: { c1: 300 } }
|
25
25
|
def self.deep_merge(this, other, &block)
|
26
26
|
deep_merge!(this.dup, other, &block)
|
27
27
|
end
|
28
28
|
|
29
|
-
# Same as +deep_merge+, but modifies +
|
29
|
+
# Same as +deep_merge+, but modifies +this+ instead of returning a new hash.
|
30
30
|
def self.deep_merge!(this, other, &block)
|
31
31
|
other.each_pair do |current_key, other_value|
|
32
32
|
this_value = this[current_key]
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
module Options
|
3
|
+
|
4
|
+
class Base
|
5
|
+
def initialize(options)
|
6
|
+
@options = (options || {}).dup
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_h
|
10
|
+
@options
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class ListOptions < Base
|
15
|
+
def initialize(options)
|
16
|
+
super
|
17
|
+
_prepare_query
|
18
|
+
_prepare_pagination
|
19
|
+
_prepare_sort
|
20
|
+
_prepare_filter
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def _prepare_query
|
26
|
+
@options[:query] ||= {} if @options.any?
|
27
|
+
end
|
28
|
+
|
29
|
+
def _prepare_pagination
|
30
|
+
@page = @options.delete(:page)
|
31
|
+
_merge(page: @page) unless @page.nil?
|
32
|
+
|
33
|
+
@per_page = @options.delete(:per_page)
|
34
|
+
_merge(per_page: @per_page) unless @per_page.nil?
|
35
|
+
end
|
36
|
+
|
37
|
+
def _prepare_sort
|
38
|
+
@sort = @options.delete(:sort)
|
39
|
+
_merge(sort: @sort) unless @sort.nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
def _prepare_filter
|
43
|
+
@filter = @options.delete(:filter)
|
44
|
+
_merge(@filter) unless @filter.nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
def _merge(hash)
|
48
|
+
@options[:query].merge!(hash)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
data/lib/dnsimple/struct.rb
CHANGED
@@ -23,8 +23,10 @@ require_relative 'struct/oauth_token'
|
|
23
23
|
require_relative 'struct/record'
|
24
24
|
require_relative 'struct/service'
|
25
25
|
require_relative 'struct/template'
|
26
|
+
require_relative 'struct/template_record'
|
26
27
|
require_relative 'struct/tld'
|
27
28
|
require_relative 'struct/user'
|
28
29
|
require_relative 'struct/whois_privacy'
|
29
30
|
require_relative 'struct/zone'
|
30
31
|
require_relative 'struct/webhook'
|
32
|
+
require_relative 'struct/whoami'
|
@@ -29,10 +29,10 @@ module Dnsimple
|
|
29
29
|
# @return [Bool] True if this is a system record created by DNSimple. System records are read-only.
|
30
30
|
attr_accessor :system_record
|
31
31
|
|
32
|
-
# @return [String] When the
|
32
|
+
# @return [String] When the record was created in DNSimple.
|
33
33
|
attr_accessor :created_at
|
34
34
|
|
35
|
-
# @return [String] When the
|
35
|
+
# @return [String] When the record was last updated in DNSimple.
|
36
36
|
attr_accessor :updated_at
|
37
37
|
end
|
38
38
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
module Struct
|
3
|
+
|
4
|
+
class TemplateRecord < Base
|
5
|
+
# @return [Fixnum] The template record ID in DNSimple.
|
6
|
+
attr_accessor :id
|
7
|
+
|
8
|
+
# @return [Fixnum] The template ID in DNSimple.
|
9
|
+
attr_accessor :template_id
|
10
|
+
|
11
|
+
# @return [String] The type of template record, in uppercase.
|
12
|
+
attr_accessor :type
|
13
|
+
|
14
|
+
# @return [String] The template record name (without the domain name).
|
15
|
+
attr_accessor :name
|
16
|
+
|
17
|
+
# @return [String] The plain-text template record content.
|
18
|
+
attr_accessor :content
|
19
|
+
|
20
|
+
# @return [Fixnum] The template record TTL value.
|
21
|
+
attr_accessor :ttl
|
22
|
+
|
23
|
+
# @return [Fixnum] The priority value, if the type of template record accepts a priority.
|
24
|
+
attr_accessor :priority
|
25
|
+
|
26
|
+
# @return [String] When the template record was created in DNSimple.
|
27
|
+
attr_accessor :created_at
|
28
|
+
|
29
|
+
# @return [String] When the template record was last updated in DNSimple.
|
30
|
+
attr_accessor :updated_at
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Dnsimple
|
2
|
+
module Struct
|
3
|
+
|
4
|
+
class Whoami < Base
|
5
|
+
# @return [Account] The account, if present.
|
6
|
+
attr_accessor :account
|
7
|
+
|
8
|
+
# @return [String] The user, if present.
|
9
|
+
attr_accessor :user
|
10
|
+
|
11
|
+
|
12
|
+
# Converts account to a Struct::Account and sets it.
|
13
|
+
#
|
14
|
+
# @param [Hash, nil] account
|
15
|
+
# @return [void]
|
16
|
+
def account=(account)
|
17
|
+
@account = account ? Struct::Account.new(account) : account
|
18
|
+
end
|
19
|
+
|
20
|
+
# Converts user to a Struct::User and sets it.
|
21
|
+
#
|
22
|
+
# @param [Hash, nil] user
|
23
|
+
# @return [void]
|
24
|
+
def user=(user)
|
25
|
+
@user = user ? Struct::User.new(user) : user
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/lib/dnsimple/version.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dnsimple::Client, ".accounts" do
|
4
|
+
|
5
|
+
subject { described_class.new(base_url: "https://api.dnsimple.test", access_token: "a1b2c3").accounts }
|
6
|
+
|
7
|
+
|
8
|
+
describe "#accounts" do
|
9
|
+
before do
|
10
|
+
stub_request(:get, %r{/v2/accounts$}).
|
11
|
+
to_return(read_http_fixture("accounts/success-user.http"))
|
12
|
+
end
|
13
|
+
|
14
|
+
it "builds the correct request" do
|
15
|
+
subject.accounts
|
16
|
+
|
17
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/accounts").
|
18
|
+
with(headers: { 'Accept' => 'application/json' })
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns the accounts" do
|
22
|
+
response = subject.accounts
|
23
|
+
expect(response).to be_a(Dnsimple::Response)
|
24
|
+
|
25
|
+
result = response.data
|
26
|
+
expect(result.first).to be_a(Dnsimple::Struct::Account)
|
27
|
+
expect(result.last).to be_a(Dnsimple::Struct::Account)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -21,7 +21,7 @@ describe Dnsimple::Client, ".contacts" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "supports pagination" do
|
24
|
-
subject.contacts(account_id,
|
24
|
+
subject.contacts(account_id, page: 2)
|
25
25
|
|
26
26
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/contacts?page=2")
|
27
27
|
end
|
@@ -32,6 +32,12 @@ describe Dnsimple::Client, ".contacts" do
|
|
32
32
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/contacts?foo=bar")
|
33
33
|
end
|
34
34
|
|
35
|
+
it "supports sorting" do
|
36
|
+
subject.contacts(account_id, sort: "label:desc")
|
37
|
+
|
38
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/contacts?sort=label:desc")
|
39
|
+
end
|
40
|
+
|
35
41
|
it "returns the contacts" do
|
36
42
|
response = subject.contacts(account_id)
|
37
43
|
|
@@ -57,12 +63,23 @@ describe Dnsimple::Client, ".contacts" do
|
|
57
63
|
end
|
58
64
|
|
59
65
|
describe "#all_contacts" do
|
66
|
+
before do
|
67
|
+
stub_request(:get, %r{/v2/#{account_id}/contacts}).
|
68
|
+
to_return(read_http_fixture("listContacts/success.http"))
|
69
|
+
end
|
70
|
+
|
60
71
|
let(:account_id) { 1010 }
|
61
72
|
|
62
73
|
it "delegates to client.paginate" do
|
63
74
|
expect(subject).to receive(:paginate).with(:contacts, account_id, foo: "bar")
|
64
75
|
subject.all_contacts(account_id, foo: "bar")
|
65
76
|
end
|
77
|
+
|
78
|
+
it "supports sorting" do
|
79
|
+
subject.all_contacts(account_id, sort: "label:desc")
|
80
|
+
|
81
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/contacts?page=1&per_page=100&sort=label:desc")
|
82
|
+
end
|
66
83
|
end
|
67
84
|
|
68
85
|
describe "#create_contact" do
|
@@ -73,7 +90,7 @@ describe Dnsimple::Client, ".contacts" do
|
|
73
90
|
to_return(read_http_fixture("createContact/created.http"))
|
74
91
|
end
|
75
92
|
|
76
|
-
let(:attributes) { { first_name: "Simone", last_name: "Carletti", address1: "Italian Street", city: "Rome", state_province: "RM", postal_code: "00171", country: "IT",
|
93
|
+
let(:attributes) { { first_name: "Simone", last_name: "Carletti", address1: "Italian Street", city: "Rome", state_province: "RM", postal_code: "00171", country: "IT", email: "example@example.com", phone: "+393391234567" } }
|
77
94
|
|
78
95
|
it "builds the correct request" do
|
79
96
|
subject.create_contact(account_id, attributes)
|
@@ -22,7 +22,7 @@ describe Dnsimple::Client, ".domains" do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "supports pagination" do
|
25
|
-
subject.email_forwards(account_id, domain_id,
|
25
|
+
subject.email_forwards(account_id, domain_id, page: 2)
|
26
26
|
|
27
27
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/email_forwards?page=2")
|
28
28
|
end
|
@@ -33,6 +33,12 @@ describe Dnsimple::Client, ".domains" do
|
|
33
33
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/email_forwards?foo=bar")
|
34
34
|
end
|
35
35
|
|
36
|
+
it "supports sorting" do
|
37
|
+
subject.email_forwards(account_id, domain_id, sort: "id:asc,from:desc")
|
38
|
+
|
39
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/email_forwards?sort=id:asc,from:desc")
|
40
|
+
end
|
41
|
+
|
36
42
|
it "returns the email forwards" do
|
37
43
|
response = subject.email_forwards(account_id, domain_id)
|
38
44
|
|
@@ -69,6 +75,11 @@ describe Dnsimple::Client, ".domains" do
|
|
69
75
|
end
|
70
76
|
|
71
77
|
describe "#all_email_forwards" do
|
78
|
+
before do
|
79
|
+
stub_request(:get, %r{/v2/#{account_id}/domains/#{domain_id}/email_forwards}).
|
80
|
+
to_return(read_http_fixture("listEmailForwards/success.http"))
|
81
|
+
end
|
82
|
+
|
72
83
|
let(:account_id) { 1010 }
|
73
84
|
let(:domain_id) { "example.com" }
|
74
85
|
|
@@ -76,6 +87,12 @@ describe Dnsimple::Client, ".domains" do
|
|
76
87
|
expect(subject).to receive(:paginate).with(:email_forwards, account_id, domain_id, foo: "bar")
|
77
88
|
subject.all_email_forwards(account_id, domain_id, foo: "bar")
|
78
89
|
end
|
90
|
+
|
91
|
+
it "supports sorting" do
|
92
|
+
subject.all_email_forwards(account_id, domain_id, sort: "id:asc,from:desc")
|
93
|
+
|
94
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains/#{domain_id}/email_forwards?page=1&per_page=100&sort=id:asc,from:desc")
|
95
|
+
end
|
79
96
|
end
|
80
97
|
|
81
98
|
describe "#create_email_forward" do
|
@@ -21,7 +21,7 @@ describe Dnsimple::Client, ".domains" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "supports pagination" do
|
24
|
-
subject.domains(account_id,
|
24
|
+
subject.domains(account_id, page: 2)
|
25
25
|
|
26
26
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?page=2")
|
27
27
|
end
|
@@ -32,6 +32,18 @@ describe Dnsimple::Client, ".domains" do
|
|
32
32
|
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?foo=bar")
|
33
33
|
end
|
34
34
|
|
35
|
+
it "supports sorting" do
|
36
|
+
subject.domains(account_id, sort: "expires_on:asc")
|
37
|
+
|
38
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?sort=expires_on:asc")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "supports filtering" do
|
42
|
+
subject.domains(account_id, filter: { name_like: 'example' })
|
43
|
+
|
44
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?name_like=example")
|
45
|
+
end
|
46
|
+
|
35
47
|
it "returns the domains" do
|
36
48
|
response = subject.domains(account_id)
|
37
49
|
|
@@ -57,12 +69,29 @@ describe Dnsimple::Client, ".domains" do
|
|
57
69
|
end
|
58
70
|
|
59
71
|
describe "#all_domains" do
|
72
|
+
before do
|
73
|
+
stub_request(:get, %r{/v2/#{account_id}/domains}).
|
74
|
+
to_return(read_http_fixture("listDomains/success.http"))
|
75
|
+
end
|
76
|
+
|
60
77
|
let(:account_id) { 1010 }
|
61
78
|
|
62
79
|
it "delegates to client.paginate" do
|
63
80
|
expect(subject).to receive(:paginate).with(:domains, account_id, foo: "bar")
|
64
81
|
subject.all_domains(account_id, foo: "bar")
|
65
82
|
end
|
83
|
+
|
84
|
+
it "supports sorting" do
|
85
|
+
subject.all_domains(account_id, sort: "expires_on:asc")
|
86
|
+
|
87
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?page=1&per_page=100&sort=expires_on:asc")
|
88
|
+
end
|
89
|
+
|
90
|
+
it "supports filtering" do
|
91
|
+
subject.all_domains(account_id, filter: { registrant_id: 99 })
|
92
|
+
|
93
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/#{account_id}/domains?page=1&per_page=100®istrant_id=99")
|
94
|
+
end
|
66
95
|
end
|
67
96
|
|
68
97
|
describe "#create_domain" do
|
@@ -18,12 +18,12 @@ describe Dnsimple::Client, ".identity" do
|
|
18
18
|
with(headers: { 'Accept' => 'application/json' })
|
19
19
|
end
|
20
20
|
|
21
|
-
it "returns
|
21
|
+
it "returns the whoami" do
|
22
22
|
response = subject.whoami
|
23
23
|
expect(response).to be_a(Dnsimple::Response)
|
24
24
|
|
25
25
|
result = response.data
|
26
|
-
expect(result).to be_a(
|
26
|
+
expect(result).to be_a(Dnsimple::Struct::Whoami)
|
27
27
|
end
|
28
28
|
|
29
29
|
context "when authenticated as account" do
|
@@ -34,8 +34,8 @@ describe Dnsimple::Client, ".identity" do
|
|
34
34
|
|
35
35
|
it "sets the account" do
|
36
36
|
result = subject.whoami.data
|
37
|
-
expect(result
|
38
|
-
expect(result
|
37
|
+
expect(result.account).to be_a(Dnsimple::Struct::Account)
|
38
|
+
expect(result.user).to be_nil
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
@@ -47,8 +47,8 @@ describe Dnsimple::Client, ".identity" do
|
|
47
47
|
|
48
48
|
it "sets the user" do
|
49
49
|
result = subject.whoami.data
|
50
|
-
expect(result
|
51
|
-
expect(result
|
50
|
+
expect(result.account).to be_nil
|
51
|
+
expect(result.user).to be_a(Dnsimple::Struct::User)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -7,7 +7,7 @@ describe Dnsimple::Client, ".services" do
|
|
7
7
|
|
8
8
|
describe "#list_services" do
|
9
9
|
before do
|
10
|
-
stub_request(:get, %r{/v2/services
|
10
|
+
stub_request(:get, %r{/v2/services}).
|
11
11
|
to_return(read_http_fixture("listServices/success.http"))
|
12
12
|
end
|
13
13
|
|
@@ -18,6 +18,24 @@ describe Dnsimple::Client, ".services" do
|
|
18
18
|
with(headers: { "Accept" => "application/json" })
|
19
19
|
end
|
20
20
|
|
21
|
+
it "supports pagination" do
|
22
|
+
subject.services(page: 2)
|
23
|
+
|
24
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/services?page=2")
|
25
|
+
end
|
26
|
+
|
27
|
+
it "supports extra request options" do
|
28
|
+
subject.services(query: { foo: "bar" })
|
29
|
+
|
30
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/services?foo=bar")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "supports sorting" do
|
34
|
+
subject.services(sort: "short_name:asc")
|
35
|
+
|
36
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/services?sort=short_name:asc")
|
37
|
+
end
|
38
|
+
|
21
39
|
it "returns the list of available services" do
|
22
40
|
response = subject.list_services
|
23
41
|
expect(response).to be_a(Dnsimple::CollectionResponse)
|
@@ -37,10 +55,21 @@ describe Dnsimple::Client, ".services" do
|
|
37
55
|
end
|
38
56
|
|
39
57
|
describe "#all_services" do
|
58
|
+
before do
|
59
|
+
stub_request(:get, %r{/v2/services}).
|
60
|
+
to_return(read_http_fixture("listServices/success.http"))
|
61
|
+
end
|
62
|
+
|
40
63
|
it "delegates to client.paginate" do
|
41
64
|
expect(subject).to receive(:paginate).with(:services, foo: "bar")
|
42
65
|
subject.all_services(foo: "bar")
|
43
66
|
end
|
67
|
+
|
68
|
+
it "supports sorting" do
|
69
|
+
subject.all_services(sort: "short_name:asc")
|
70
|
+
|
71
|
+
expect(WebMock).to have_requested(:get, "https://api.dnsimple.test/v2/services?page=1&per_page=100&sort=short_name:asc")
|
72
|
+
end
|
44
73
|
end
|
45
74
|
|
46
75
|
describe "#service" do
|