spearly-sdk-ruby 0.9.0 → 0.10.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 +4 -0
- data/lib/spearly/auth/client.rb +17 -0
- data/lib/spearly/version.rb +1 -1
- data/spec/spearly/auth/client_spec.rb +39 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ea587fbe14cca4cebc1b12a299ee8ddaa5c64df3c50f51ff4989b1d18094990
|
4
|
+
data.tar.gz: 14e9537659004b0e52c193a4f0708407b31d2d9f77909352326351fb8f87329c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60dae3572451b45f445cd4ee7487ddeec830bc274e9dead7264a007babc6491732fb4bd1cac5e11e5caa2c2a8a5a8e5fca7f7086bd729dbe356e918113e3b16c
|
7
|
+
data.tar.gz: 94a932fdc203d988badf93296cef0fd808d08abe0856903ffc85aca5210d58f28e1d5de6bbc1cb19447696cbebca0e9c10ef3f91462684fc2d99854ca18498ce
|
data/CHANGELOG.md
CHANGED
data/lib/spearly/auth/client.rb
CHANGED
@@ -156,6 +156,23 @@ module Spearly
|
|
156
156
|
{}
|
157
157
|
end
|
158
158
|
end
|
159
|
+
|
160
|
+
def get_team_subscriptions(team_id, params)
|
161
|
+
uri = "#{ENV.fetch('SPEARLY_API_URL', nil)}/teams/#{team_id}/subscriptions"
|
162
|
+
uri_parsed = Addressable::URI.parse(uri).normalize.to_s
|
163
|
+
client = Faraday.default_connection
|
164
|
+
|
165
|
+
res = client.get(uri_parsed,
|
166
|
+
params.as_json,
|
167
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
168
|
+
'Authorization' => @token)
|
169
|
+
|
170
|
+
if res.status == 200
|
171
|
+
JSON.parse(res.body)
|
172
|
+
else
|
173
|
+
[]
|
174
|
+
end
|
175
|
+
end
|
159
176
|
end
|
160
177
|
end
|
161
178
|
end
|
data/lib/spearly/version.rb
CHANGED
@@ -48,4 +48,43 @@ RSpec.describe Spearly::Auth::Client do
|
|
48
48
|
expect(res['errors']).to eq('owner' => ["can't own more than 2 free teams"])
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
describe '.get_team_subscriptions()' do
|
53
|
+
let!(:response_double) { instance_double(Faraday::Response, status: 200, body: { 'data' => [{ 'id' => 'sub_1' }] }.to_json) }
|
54
|
+
let!(:team_id) { '711' }
|
55
|
+
let!(:params) { { service_name: 'cms' } }
|
56
|
+
let!(:client) { described_class.new('token') }
|
57
|
+
|
58
|
+
before do
|
59
|
+
allow(connection_double).to receive(:get).and_return(response_double)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'makes GET request to /teams/{team_id}/subscriptions' do
|
63
|
+
uri_parsed = Addressable::URI.parse('https://api.spearly.test/teams/711/subscriptions').normalize.to_s
|
64
|
+
|
65
|
+
expect(connection_double).to receive(:get).with(uri_parsed,
|
66
|
+
params.as_json,
|
67
|
+
'Accept' => 'application/vnd.spearly.v2+json',
|
68
|
+
'Authorization' => 'token')
|
69
|
+
|
70
|
+
described_class.new('token')
|
71
|
+
.get_team_subscriptions(team_id, params)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'returns data object if status is 200' do
|
75
|
+
res = client.get_team_subscriptions(team_id, params)
|
76
|
+
|
77
|
+
expect(res).to eq('data' => [{ 'id' => 'sub_1' }])
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'returns empty array if status is not 200' do
|
81
|
+
response_double = instance_double(Faraday::Response, status: 404)
|
82
|
+
|
83
|
+
allow(connection_double).to receive(:get).and_return(response_double)
|
84
|
+
|
85
|
+
res = client.get_team_subscriptions(team_id, params)
|
86
|
+
|
87
|
+
expect(res).to eq []
|
88
|
+
end
|
89
|
+
end
|
51
90
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spearly-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spearly
|
@@ -197,7 +197,7 @@ licenses: []
|
|
197
197
|
metadata:
|
198
198
|
homepage_uri: https://github.com/unimal-jp/spearly-sdk-ruby
|
199
199
|
source_code_uri: https://github.com/unimal-jp/spearly-sdk-ruby
|
200
|
-
changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.
|
200
|
+
changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.10.0/CHANGELOG.md
|
201
201
|
rubygems_mfa_required: 'true'
|
202
202
|
post_install_message:
|
203
203
|
rdoc_options: []
|