qtc-sdk 0.4.0 → 0.4.1
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/.gitignore +18 -18
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Changelog.md +28 -23
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +42 -44
- data/Rakefile +1 -1
- data/bin/qtc-cli +13 -13
- data/lib/qtc-sdk.rb +1 -1
- data/lib/qtc/cli/commands.rb +15 -15
- data/lib/qtc/cli/common.rb +146 -146
- data/lib/qtc/cli/eds/base.rb +27 -27
- data/lib/qtc/cli/eds/commands.rb +20 -20
- data/lib/qtc/cli/eds/instances.rb +30 -30
- data/lib/qtc/cli/mar/apps.rb +116 -116
- data/lib/qtc/cli/mar/base.rb +60 -60
- data/lib/qtc/cli/mar/commands.rb +268 -266
- data/lib/qtc/cli/mar/debug.rb +94 -88
- data/lib/qtc/cli/mar/domains.rb +35 -35
- data/lib/qtc/cli/mar/env.rb +38 -38
- data/lib/qtc/cli/mar/repository.rb +24 -24
- data/lib/qtc/cli/mar/slugs.rb +80 -80
- data/lib/qtc/cli/mar/ssl_certificates.rb +40 -40
- data/lib/qtc/cli/mar/stack.rb +29 -29
- data/lib/qtc/cli/mdb/base.rb +47 -47
- data/lib/qtc/cli/mdb/commands.rb +43 -43
- data/lib/qtc/cli/mdb/instances.rb +79 -79
- data/lib/qtc/cli/platform/clouds.rb +33 -33
- data/lib/qtc/cli/platform/commands.rb +133 -132
- data/lib/qtc/cli/platform/datacenters.rb +23 -23
- data/lib/qtc/cli/platform/ssh_keys.rb +41 -41
- data/lib/qtc/cli/platform/user.rb +29 -25
- data/lib/qtc/cli/platform/vpn.rb +93 -93
- data/lib/qtc/client.rb +170 -170
- data/lib/qtc/eds/client.rb +116 -116
- data/lib/qtc/eds/collection.rb +124 -124
- data/lib/qtc/eds/user_collection.rb +13 -13
- data/lib/qtc/eds/usergroup_collection.rb +41 -41
- data/lib/qtc/errors.rb +13 -13
- data/lib/qtc/version.rb +3 -3
- data/qtc-sdk.gemspec +28 -28
- data/spec/spec_helper.rb +17 -0
- data/spec/unit/qtc/client_spec.rb +147 -147
- metadata +5 -3
@@ -1,14 +1,14 @@
|
|
1
|
-
module Qtc
|
2
|
-
module Eds
|
3
|
-
class UserCollection < Collection
|
4
|
-
|
5
|
-
##
|
6
|
-
# Initialize EDS user collection
|
7
|
-
#
|
8
|
-
# @param [Qtc::Client] client
|
9
|
-
def initialize(client)
|
10
|
-
super(client, '/users')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module Qtc
|
2
|
+
module Eds
|
3
|
+
class UserCollection < Collection
|
4
|
+
|
5
|
+
##
|
6
|
+
# Initialize EDS user collection
|
7
|
+
#
|
8
|
+
# @param [Qtc::Client] client
|
9
|
+
def initialize(client)
|
10
|
+
super(client, '/users')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|
@@ -1,42 +1,42 @@
|
|
1
|
-
module Qtc
|
2
|
-
module Eds
|
3
|
-
class UsergroupCollection < Collection
|
4
|
-
|
5
|
-
##
|
6
|
-
# Initialize EDS usergroup collection
|
7
|
-
#
|
8
|
-
# @param [Qtc::Client] client
|
9
|
-
def initialize(client)
|
10
|
-
super(client, '/usergroups')
|
11
|
-
end
|
12
|
-
|
13
|
-
##
|
14
|
-
# Add member to usergroup
|
15
|
-
#
|
16
|
-
# @param [String] id
|
17
|
-
# @param [Hash] user
|
18
|
-
def add_member(id, user)
|
19
|
-
client.post("#{path}/#{id}/members", user)
|
20
|
-
end
|
21
|
-
|
22
|
-
##
|
23
|
-
# Remove member from usergroup
|
24
|
-
#
|
25
|
-
# @param [String] id
|
26
|
-
# @param [Hash] user
|
27
|
-
def remove_member(id, user)
|
28
|
-
client.delete("#{path}/#{id}/members", user)
|
29
|
-
end
|
30
|
-
|
31
|
-
##
|
32
|
-
# Get usergroup members
|
33
|
-
#
|
34
|
-
# @param [String] id
|
35
|
-
# @return [Array<Hash>]
|
36
|
-
def members(id)
|
37
|
-
response = client.get("#{path}/#{id}/members")
|
38
|
-
response['results']
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
1
|
+
module Qtc
|
2
|
+
module Eds
|
3
|
+
class UsergroupCollection < Collection
|
4
|
+
|
5
|
+
##
|
6
|
+
# Initialize EDS usergroup collection
|
7
|
+
#
|
8
|
+
# @param [Qtc::Client] client
|
9
|
+
def initialize(client)
|
10
|
+
super(client, '/usergroups')
|
11
|
+
end
|
12
|
+
|
13
|
+
##
|
14
|
+
# Add member to usergroup
|
15
|
+
#
|
16
|
+
# @param [String] id
|
17
|
+
# @param [Hash] user
|
18
|
+
def add_member(id, user)
|
19
|
+
client.post("#{path}/#{id}/members", user)
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# Remove member from usergroup
|
24
|
+
#
|
25
|
+
# @param [String] id
|
26
|
+
# @param [Hash] user
|
27
|
+
def remove_member(id, user)
|
28
|
+
client.delete("#{path}/#{id}/members", user)
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Get usergroup members
|
33
|
+
#
|
34
|
+
# @param [String] id
|
35
|
+
# @return [Array<Hash>]
|
36
|
+
def members(id)
|
37
|
+
response = client.get("#{path}/#{id}/members")
|
38
|
+
response['results']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
42
|
end
|
data/lib/qtc/errors.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
module Qtc
|
2
|
-
module Errors
|
3
|
-
class StandardError < ::StandardError
|
4
|
-
|
5
|
-
attr_reader :status
|
6
|
-
|
7
|
-
def initialize(status, message)
|
8
|
-
@status = status
|
9
|
-
super(message)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module Qtc
|
2
|
+
module Errors
|
3
|
+
class StandardError < ::StandardError
|
4
|
+
|
5
|
+
attr_reader :status
|
6
|
+
|
7
|
+
def initialize(status, message)
|
8
|
+
@status = status
|
9
|
+
super(message)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/qtc/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Qtc
|
2
|
-
VERSION = '0.4.
|
3
|
-
end
|
1
|
+
module Qtc
|
2
|
+
VERSION = '0.4.1'
|
3
|
+
end
|
data/qtc-sdk.gemspec
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'qtc/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'qtc-sdk'
|
8
|
-
spec.version = Qtc::VERSION
|
9
|
-
spec.authors = ['Jari Kolehmainen']
|
10
|
-
spec.email = ['jari.kolehmainen@digia.com']
|
11
|
-
spec.summary = %q{Qt Cloud Services SDK for Ruby}
|
12
|
-
spec.description = %q{Qt Cloud Services SDK for Ruby}
|
13
|
-
spec.homepage = 'https://github.com/jakolehm/qtc-sdk-ruby'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
spec.required_ruby_version = '>= 1.9.3'
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0")
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
-
spec.require_paths = ['lib']
|
21
|
-
|
22
|
-
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
-
spec.add_development_dependency 'rake'
|
24
|
-
spec.add_development_dependency 'rspec', '~> 2.14.0'
|
25
|
-
spec.add_runtime_dependency 'httpclient', '~> 2.3'
|
26
|
-
spec.add_runtime_dependency 'commander'
|
27
|
-
spec.add_runtime_dependency 'inifile'
|
28
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'qtc/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'qtc-sdk'
|
8
|
+
spec.version = Qtc::VERSION
|
9
|
+
spec.authors = ['Jari Kolehmainen']
|
10
|
+
spec.email = ['jari.kolehmainen@digia.com']
|
11
|
+
spec.summary = %q{Qt Cloud Services SDK for Ruby}
|
12
|
+
spec.description = %q{Qt Cloud Services SDK for Ruby}
|
13
|
+
spec.homepage = 'https://github.com/jakolehm/qtc-sdk-ruby'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 1.9.3'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'rspec', '~> 2.14.0'
|
25
|
+
spec.add_runtime_dependency 'httpclient', '~> 2.3'
|
26
|
+
spec.add_runtime_dependency 'commander'
|
27
|
+
spec.add_runtime_dependency 'inifile'
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
@@ -1,148 +1,148 @@
|
|
1
|
-
require 'qtc-sdk'
|
2
|
-
|
3
|
-
|
4
|
-
describe Qtc::Client do
|
5
|
-
|
6
|
-
let(:test_client) do
|
7
|
-
Qtc::Client.new('https://api.qtc.io')
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '#initialize' do
|
11
|
-
it 'accepts single parameter (api_url)' do
|
12
|
-
expect {
|
13
|
-
Qtc::Client.new('https://api.qtc.io')
|
14
|
-
}.not_to raise_exception
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'accepts optional second parameter (headers)' do
|
18
|
-
expect {
|
19
|
-
client = Qtc::Client.new('https://api.qtc.io', {'Foo' => 'Bar'})
|
20
|
-
expect(client.default_headers['Foo']).to eq('Bar')
|
21
|
-
}.not_to raise_exception
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#get' do
|
26
|
-
it 'sends GET request with correct parameters' do
|
27
|
-
params = {test: 1}
|
28
|
-
headers = {'X-Test-Header' => 'some_value'}
|
29
|
-
test_client.http_client.
|
30
|
-
'https://api.qtc.io/v1/ping',
|
31
|
-
params,
|
32
|
-
hash_including(headers)
|
33
|
-
).and_return(double(:response, status: 200).as_null_object)
|
34
|
-
test_client.get('/v1/ping', params, headers)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'raises exception when response is an error' do
|
38
|
-
data = {name: 'Test'}
|
39
|
-
test_client.http_client.
|
40
|
-
expect {
|
41
|
-
test_client.get('/v1/instances', data)
|
42
|
-
}.to raise_error(Qtc::Errors::StandardError)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'returns parsed json responses' do
|
46
|
-
data = {'name' => 'Test'}
|
47
|
-
test_client.http_client.
|
48
|
-
resp = test_client.get('/v1/instances', data)
|
49
|
-
expect(resp).to eq(data)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#post' do
|
54
|
-
it 'sends POST request with correct parameters' do
|
55
|
-
data = {name: 'Test'}
|
56
|
-
params = {test: 1}
|
57
|
-
headers = {'Authorization' => 'Bearer token'}
|
58
|
-
test_client.http_client.
|
59
|
-
'https://api.qtc.io/v1/accounts',
|
60
|
-
{
|
61
|
-
header: hash_including(headers),
|
62
|
-
body: data.to_json,
|
63
|
-
query: params
|
64
|
-
}
|
65
|
-
).and_return(double(:response, status: 201).as_null_object)
|
66
|
-
test_client.post('/v1/accounts', data, params, headers)
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'raises exception when response is an error' do
|
70
|
-
data = {name: 'Test'}
|
71
|
-
test_client.http_client.
|
72
|
-
expect {
|
73
|
-
test_client.post('/v1/accounts', data)
|
74
|
-
}.to raise_error(Qtc::Errors::StandardError)
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'returns parsed json responses' do
|
78
|
-
data = {'name' => 'Test'}
|
79
|
-
test_client.http_client.
|
80
|
-
resp = test_client.post('/v1/accounts', data)
|
81
|
-
expect(resp).to eq(data)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
describe '#put' do
|
86
|
-
it 'sends PUT request with correct parameters' do
|
87
|
-
data = {name: 'Test'}
|
88
|
-
params = {test: 1}
|
89
|
-
headers = {'Authorization' => 'Bearer token'}
|
90
|
-
test_client.http_client.
|
91
|
-
'https://api.qtc.io/v1/accounts',
|
92
|
-
{
|
93
|
-
header: hash_including(headers),
|
94
|
-
body: data.to_json,
|
95
|
-
query: params
|
96
|
-
}
|
97
|
-
).and_return(double(:response, status: 201).as_null_object)
|
98
|
-
test_client.put('/v1/accounts', data, params, headers)
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'raises exception when response is an error' do
|
102
|
-
data = {name: 'Test'}
|
103
|
-
test_client.http_client.
|
104
|
-
expect {
|
105
|
-
test_client.put('/v1/accounts', data)
|
106
|
-
}.to raise_error(Qtc::Errors::StandardError)
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'returns parsed json responses' do
|
110
|
-
data = {'name' => 'Test'}
|
111
|
-
test_client.http_client.
|
112
|
-
resp = test_client.put('/v1/accounts', data)
|
113
|
-
expect(resp).to eq(data)
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe '#delete' do
|
118
|
-
it 'sends DELETE request with correct parameters' do
|
119
|
-
data = {name: 'Test'}
|
120
|
-
params = {test: 1}
|
121
|
-
headers = {'Authorization' => 'Bearer token'}
|
122
|
-
test_client.http_client.
|
123
|
-
'https://api.qtc.io/v1/accounts',
|
124
|
-
{
|
125
|
-
header: hash_including(headers),
|
126
|
-
body: data.to_json,
|
127
|
-
query: params
|
128
|
-
}
|
129
|
-
).and_return(double(:response, status: 200).as_null_object)
|
130
|
-
test_client.delete('/v1/accounts', data, params, headers)
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'raises exception when response is an error' do
|
134
|
-
data = {name: 'Test'}
|
135
|
-
test_client.http_client.
|
136
|
-
expect {
|
137
|
-
test_client.delete('/v1/accounts', data)
|
138
|
-
}.to raise_error(Qtc::Errors::StandardError)
|
139
|
-
end
|
140
|
-
|
141
|
-
it 'returns parsed json responses' do
|
142
|
-
data = {'name' => 'Test'}
|
143
|
-
test_client.http_client.
|
144
|
-
resp = test_client.delete('/v1/accounts', data)
|
145
|
-
expect(resp).to eq(data)
|
146
|
-
end
|
147
|
-
end
|
1
|
+
require 'qtc-sdk'
|
2
|
+
|
3
|
+
|
4
|
+
describe Qtc::Client do
|
5
|
+
|
6
|
+
let(:test_client) do
|
7
|
+
Qtc::Client.new('https://api.qtc.io')
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#initialize' do
|
11
|
+
it 'accepts single parameter (api_url)' do
|
12
|
+
expect {
|
13
|
+
Qtc::Client.new('https://api.qtc.io')
|
14
|
+
}.not_to raise_exception
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'accepts optional second parameter (headers)' do
|
18
|
+
expect {
|
19
|
+
client = Qtc::Client.new('https://api.qtc.io', {'Foo' => 'Bar'})
|
20
|
+
expect(client.default_headers['Foo']).to eq('Bar')
|
21
|
+
}.not_to raise_exception
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#get' do
|
26
|
+
it 'sends GET request with correct parameters' do
|
27
|
+
params = {test: 1}
|
28
|
+
headers = {'X-Test-Header' => 'some_value'}
|
29
|
+
expect(test_client.http_client).to receive(:get).with(
|
30
|
+
'https://api.qtc.io/v1/ping',
|
31
|
+
params,
|
32
|
+
hash_including(headers)
|
33
|
+
).and_return(double(:response, status: 200).as_null_object)
|
34
|
+
test_client.get('/v1/ping', params, headers)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'raises exception when response is an error' do
|
38
|
+
data = {name: 'Test'}
|
39
|
+
expect(test_client.http_client).to receive(:get).and_return(double(:response, status: 400).as_null_object)
|
40
|
+
expect {
|
41
|
+
test_client.get('/v1/instances', data)
|
42
|
+
}.to raise_error(Qtc::Errors::StandardError)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns parsed json responses' do
|
46
|
+
data = {'name' => 'Test'}
|
47
|
+
expect(test_client.http_client).to receive(:get).and_return(double(:response, status: 200, body: data.to_json).as_null_object)
|
48
|
+
resp = test_client.get('/v1/instances', data)
|
49
|
+
expect(resp).to eq(data)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '#post' do
|
54
|
+
it 'sends POST request with correct parameters' do
|
55
|
+
data = {name: 'Test'}
|
56
|
+
params = {test: 1}
|
57
|
+
headers = {'Authorization' => 'Bearer token'}
|
58
|
+
expect(test_client.http_client).to receive(:post).with(
|
59
|
+
'https://api.qtc.io/v1/accounts',
|
60
|
+
{
|
61
|
+
header: hash_including(headers),
|
62
|
+
body: data.to_json,
|
63
|
+
query: params
|
64
|
+
}
|
65
|
+
).and_return(double(:response, status: 201).as_null_object)
|
66
|
+
test_client.post('/v1/accounts', data, params, headers)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'raises exception when response is an error' do
|
70
|
+
data = {name: 'Test'}
|
71
|
+
expect(test_client.http_client).to receive(:post).and_return(double(:response, status: 400).as_null_object)
|
72
|
+
expect {
|
73
|
+
test_client.post('/v1/accounts', data)
|
74
|
+
}.to raise_error(Qtc::Errors::StandardError)
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns parsed json responses' do
|
78
|
+
data = {'name' => 'Test'}
|
79
|
+
expect(test_client.http_client).to receive(:post).and_return(double(:response, status: 201, body: data.to_json).as_null_object)
|
80
|
+
resp = test_client.post('/v1/accounts', data)
|
81
|
+
expect(resp).to eq(data)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#put' do
|
86
|
+
it 'sends PUT request with correct parameters' do
|
87
|
+
data = {name: 'Test'}
|
88
|
+
params = {test: 1}
|
89
|
+
headers = {'Authorization' => 'Bearer token'}
|
90
|
+
expect(test_client.http_client).to receive(:put).with(
|
91
|
+
'https://api.qtc.io/v1/accounts',
|
92
|
+
{
|
93
|
+
header: hash_including(headers),
|
94
|
+
body: data.to_json,
|
95
|
+
query: params
|
96
|
+
}
|
97
|
+
).and_return(double(:response, status: 201).as_null_object)
|
98
|
+
test_client.put('/v1/accounts', data, params, headers)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'raises exception when response is an error' do
|
102
|
+
data = {name: 'Test'}
|
103
|
+
expect(test_client.http_client).to receive(:put).and_return(double(:response, status: 400).as_null_object)
|
104
|
+
expect {
|
105
|
+
test_client.put('/v1/accounts', data)
|
106
|
+
}.to raise_error(Qtc::Errors::StandardError)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'returns parsed json responses' do
|
110
|
+
data = {'name' => 'Test'}
|
111
|
+
expect(test_client.http_client).to receive(:put).and_return(double(:response, status: 201, body: data.to_json).as_null_object)
|
112
|
+
resp = test_client.put('/v1/accounts', data)
|
113
|
+
expect(resp).to eq(data)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '#delete' do
|
118
|
+
it 'sends DELETE request with correct parameters' do
|
119
|
+
data = {name: 'Test'}
|
120
|
+
params = {test: 1}
|
121
|
+
headers = {'Authorization' => 'Bearer token'}
|
122
|
+
expect(test_client.http_client).to receive(:delete).with(
|
123
|
+
'https://api.qtc.io/v1/accounts',
|
124
|
+
{
|
125
|
+
header: hash_including(headers),
|
126
|
+
body: data.to_json,
|
127
|
+
query: params
|
128
|
+
}
|
129
|
+
).and_return(double(:response, status: 200).as_null_object)
|
130
|
+
test_client.delete('/v1/accounts', data, params, headers)
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'raises exception when response is an error' do
|
134
|
+
data = {name: 'Test'}
|
135
|
+
expect(test_client.http_client).to receive(:delete).and_return(double(:response, status: 400).as_null_object)
|
136
|
+
expect {
|
137
|
+
test_client.delete('/v1/accounts', data)
|
138
|
+
}.to raise_error(Qtc::Errors::StandardError)
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'returns parsed json responses' do
|
142
|
+
data = {'name' => 'Test'}
|
143
|
+
expect(test_client.http_client).to receive(:delete).and_return(double(:response, status: 200, body: data.to_json).as_null_object)
|
144
|
+
resp = test_client.delete('/v1/accounts', data)
|
145
|
+
expect(resp).to eq(data)
|
146
|
+
end
|
147
|
+
end
|
148
148
|
end
|