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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16d6c0eba9178b85d9b63c138e630b6d7ac9075b4ea5aeb757e2e55851cb1071
4
- data.tar.gz: e37743ac296c9e361a61a45d37f8cff1f1f2473d885ee552ad374ee74c65b76e
3
+ metadata.gz: 0ea587fbe14cca4cebc1b12a299ee8ddaa5c64df3c50f51ff4989b1d18094990
4
+ data.tar.gz: 14e9537659004b0e52c193a4f0708407b31d2d9f77909352326351fb8f87329c
5
5
  SHA512:
6
- metadata.gz: c13568331964dc5761788b1eaace9793d2f1d8a1784dfc87bcd5bae1fe478990406408172cdc2c5950169a23ad52cc3e340872b64a5fc83eb6938e8e1885d371
7
- data.tar.gz: 451b44aa43c50ba805fedd69c2d84a64f10877bf682a77d2a2f616a5bbad6800c4a6e327e9cfaab27fe3f3e9c9cfc2d3f6f2e92cb2d7acb30103b73d4c456c2c
6
+ metadata.gz: 60dae3572451b45f445cd4ee7487ddeec830bc274e9dead7264a007babc6491732fb4bd1cac5e11e5caa2c2a8a5a8e5fca7f7086bd729dbe356e918113e3b16c
7
+ data.tar.gz: 94a932fdc203d988badf93296cef0fd808d08abe0856903ffc85aca5210d58f28e1d5de6bbc1cb19447696cbebca0e9c10ef3f91462684fc2d99854ca18498ce
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.10.0] - 2022-12-05
2
+
3
+ - `Spearly::Auth::Client#get_team_subscriptions()`
4
+
1
5
  ## [0.9.0] - 2022-12-05
2
6
 
3
7
  - Return `errors` object on `Spearly::Auth::Client#create_team()`'s 422 responses
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spearly
4
- VERSION = '0.9.0'
4
+ VERSION = '0.10.0'
5
5
  end
@@ -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.9.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.9.0/CHANGELOG.md
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: []