spearly-sdk-ruby 0.11.2 → 0.12.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75a9e6386c323a5458cb906cd00ff6a002c2a297a7387568993310f8872f87d9
4
- data.tar.gz: 8e026bdca9deb727cb19d7bf1b7e6740d285399045ddd8eedb88cebe616fc1fd
3
+ metadata.gz: d3842737e7bee7ccaaaa0c32da5d6aeba113af62bc09bf6dfa86883ff59a80db
4
+ data.tar.gz: 30cdd958e2709f1efe60e52c2d884909a4461dc468efd5f8641501594540cb0c
5
5
  SHA512:
6
- metadata.gz: 795005cf261edd8e4996cc8e3b7f91e25bac67eeef073209dd62ea8954d0ac5d4655713782bff4108930c9e67c146a3158eda2683db8576140b2e0ae71c9d824
7
- data.tar.gz: 121a7d7d68b43a71c9549ab7222232b85bde4c319e03326dd6feddd421cce36135e94205e9a17b70f443f404c6b96af53a9f4cd35a0e8ed808902b8443cbbcda
6
+ metadata.gz: edb6e7f0d2242128b7f817bb5614206975494d145682876fac05440a97a289d73ce64876bf4569d9f896c0af9d084b1372c18cbafc22120a73c1bc761b3fb428
7
+ data.tar.gz: c0b77eec47a7d65367ce96e56fcbb4d81b797157360f7ddaa1baa05fdf0b4ab8a0a322aa0f0cda2a86a8517c9f1e5c4e4c5f005fab49545fc1154c794fce2fd6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.12.3] - 2024-02-01
2
+
3
+ - `Spearly::Auth::Token#get_tokens()` [#20](https://github.com/unimal-jp/spearly-sdk-ruby/pull/20)
4
+
1
5
  ## [0.11.2] - 2023-10-20
2
6
 
3
7
  - Fix `POST /teams/:team_id/regenerate_api_access_token` [#19](https://github.com/unimal-jp/spearly-sdk-ruby/pull/19)
data/README.md CHANGED
@@ -44,7 +44,7 @@ git commit -m "v$new_version"
44
44
  git tag -a v$new_version -m "Release $new_version"
45
45
 
46
46
  git push origin main
47
- git push origin --tags
47
+ git push origin v$new_version
48
48
  ```
49
49
 
50
50
  ## Publish
@@ -25,6 +25,17 @@ module Spearly
25
25
 
26
26
  process_response(response)
27
27
  end
28
+
29
+ # GET /oauth/tokens
30
+ def get_tokens(params)
31
+ response = run_request(
32
+ :method => :get,
33
+ path: '/oauth/tokens',
34
+ params: params
35
+ )
36
+
37
+ process_response(response)
38
+ end
28
39
  end
29
40
  end
30
41
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spearly
4
- VERSION = '0.11.2'
4
+ VERSION = '0.12.3'
5
5
  end
@@ -31,7 +31,7 @@ RSpec.describe Spearly::Auth::Token do
31
31
  client.get_token_info
32
32
  end
33
33
 
34
- it 'returns data array if status is 200' do
34
+ it 'returns correct response if status is 200' do
35
35
  res = client.get_token_info
36
36
 
37
37
  expect(res).to eq('resource_owner_id' => 'token_1')
@@ -147,4 +147,96 @@ RSpec.describe Spearly::Auth::Token do
147
147
  end.to raise_error(Spearly::Auth::ServiceUnavailableError)
148
148
  end
149
149
  end
150
+
151
+ describe '.get_tokens()' do
152
+ let!(:client) { Spearly::Auth::Client.new('token') }
153
+
154
+ let!(:params) do
155
+ {
156
+ user_id: 'user_1'
157
+ }
158
+ end
159
+
160
+ let!(:response_double) do
161
+ instance_double(Faraday::Response,
162
+ status: 200,
163
+ body: {
164
+ 'data' => [
165
+ {
166
+ 'id' => 'token_1',
167
+ 'type' => 'access_token'
168
+ }
169
+ ]
170
+ }.to_json)
171
+ end
172
+
173
+ before do
174
+ allow(connection_double).to receive(:run_request).and_return(response_double)
175
+ end
176
+
177
+ it 'makes GET request to /oauth/tokens' do
178
+ uri_parsed = Addressable::URI.parse('/oauth/tokens').normalize.to_s
179
+
180
+ expect(connection_double).to receive(:run_request).with(:get,
181
+ uri_parsed,
182
+ params,
183
+ 'Accept' => 'application/vnd.spearly.v2+json',
184
+ 'Authorization' => 'token')
185
+
186
+ client.get_tokens(params)
187
+ end
188
+
189
+ it 'returns correct response if status is 200' do
190
+ res = client.get_tokens(params)
191
+
192
+ expect(res).to eq(
193
+ 'data' => [
194
+ {
195
+ 'id' => 'token_1',
196
+ 'type' => 'access_token'
197
+ }
198
+ ]
199
+ )
200
+ end
201
+
202
+ it 'throws AuthorizationError if 401' do
203
+ response_double = instance_double(Faraday::Response, status: 401)
204
+
205
+ allow(connection_double).to receive(:run_request).and_return(response_double)
206
+
207
+ expect do
208
+ client.get_tokens(params)
209
+ end.to raise_error(Spearly::Auth::AuthorizationError)
210
+ end
211
+
212
+ it 'throws NotFoundError if 404' do
213
+ response_double = instance_double(Faraday::Response, status: 404)
214
+
215
+ allow(connection_double).to receive(:run_request).and_return(response_double)
216
+
217
+ expect do
218
+ client.get_tokens(params)
219
+ end.to raise_error(Spearly::Auth::NotFoundError)
220
+ end
221
+
222
+ it 'throws ServerError if 500' do
223
+ response_double = instance_double(Faraday::Response, status: 500)
224
+
225
+ allow(connection_double).to receive(:run_request).and_return(response_double)
226
+
227
+ expect do
228
+ client.get_tokens(params)
229
+ end.to raise_error(Spearly::Auth::ServerError)
230
+ end
231
+
232
+ it 'throws ServiceUnavailableError if 503' do
233
+ response_double = instance_double(Faraday::Response, status: 503)
234
+
235
+ allow(connection_double).to receive(:run_request).and_return(response_double)
236
+
237
+ expect do
238
+ client.get_tokens(params)
239
+ end.to raise_error(Spearly::Auth::ServiceUnavailableError)
240
+ end
241
+ end
150
242
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spearly-sdk-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spearly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-20 00:00:00.000000000 Z
11
+ date: 2024-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -117,7 +117,7 @@ licenses: []
117
117
  metadata:
118
118
  homepage_uri: https://github.com/unimal-jp/spearly-sdk-ruby
119
119
  source_code_uri: https://github.com/unimal-jp/spearly-sdk-ruby
120
- changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.11.2/CHANGELOG.md
120
+ changelog_uri: https://github.com/unimal-jp/spearly-sdk-ruby/blob/v0.12.3/CHANGELOG.md
121
121
  rubygems_mfa_required: 'true'
122
122
  post_install_message:
123
123
  rdoc_options: []