quiz_api_client 4.13.4 → 4.14.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9c4a3c5a1a9c2363d383f497b8aaccfc1ba1fbde99e6481e911b46f69ff6972
4
- data.tar.gz: 4edb45c0ced2efcb9f32c3d7ec1b0376f891dc8d5b9ec336ef61b5a992e30cc5
3
+ metadata.gz: 450aa47af30bde7b962ac76248bde2fa992b4168875f1e8847c48539813576e5
4
+ data.tar.gz: 73da155fb2da7763ec9a07f557250842e62bd38ddfe570418df8a7eeee7608aa
5
5
  SHA512:
6
- metadata.gz: 637eb311b402f08c22e4109be5e092366b08ae0fb9d5db049b8e186ad92bb965bb0ef0bff73e97b88096976e2d28148eb94d107d9c8ca9e5cdf1aed17f9bb3c5
7
- data.tar.gz: 4bc454f39df1137b2f289bfd7e99217c0c2eff58c43981b26be2bf3802f2d3a1e03ebd0da015ba48a4b8f6858e3a52f450c3b28d8ef255df1686c5965fc0fbae
6
+ metadata.gz: bd2bf29f5d1a2b3d512e8cb75b40479789138551d7fce2438e3a215158b423f174bb19bb5f854f48373f6ea685815ca73dfa0431cbde2e0839c8ae191aeff1f0
7
+ data.tar.gz: 3a95461f774db17ccb8ed636d6a552c3ea4c50291d648989d44d2f621434c196ef21468de4c8e81d0f3ccf215e6dff132dcd8cfd5c404bceba484316319062a7
@@ -138,7 +138,8 @@ module QuizApiClient
138
138
  end
139
139
 
140
140
  def next_page_link(response, options)
141
- return if response.headers['link'].blank?
141
+ return if response.headers['link'].nil?
142
+ return if response.headers['link'].empty?
142
143
 
143
144
  links = LinkHeader.parse(response.headers['link']).links
144
145
  next_link = links.find { |link| link['rel'] == 'next' }
@@ -148,7 +149,9 @@ module QuizApiClient
148
149
  def next_page_dynamo(response, url, options)
149
150
  hash_key = response.headers['x-last-evaluated-hash-key']
150
151
  range_key = response.headers['x-last-evaluated-range-key']
151
- return unless hash_key.present? && range_key.present?
152
+
153
+ return if hash_key.nil? || hash_key.empty?
154
+ return if range_key.nil? || range_key.empty?
152
155
 
153
156
  query = (options[:query] || {}).merge(
154
157
  last_evaluated_hash_key: hash_key,
@@ -4,6 +4,10 @@ module QuizApiClient::Services
4
4
  post_to_quiz_api(body: body, params: params, token: token)
5
5
  end
6
6
 
7
+ def update(body: {}, params:, token: nil)
8
+ put_to_quiz_api(body: body, params: params, token: token)
9
+ end
10
+
7
11
  def create_batch(body:, token: nil)
8
12
  batch_post_to_quiz_api(body: body, token: token)
9
13
  end
@@ -17,6 +21,13 @@ module QuizApiClient::Services
17
21
  )
18
22
  end
19
23
 
24
+ def put_to_quiz_api(body:, params:, token:)
25
+ client(token: token).put(
26
+ "/api/quiz_clone_jobs/#{params.fetch(:id)}",
27
+ body
28
+ )
29
+ end
30
+
20
31
  def batch_post_to_quiz_api(body:, token:)
21
32
  client(token: token).post(
22
33
  '/api/quiz_clone_jobs/create_batch',
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.13.4'.freeze
2
+ VERSION = '4.14.0'.freeze
3
3
  end
@@ -40,6 +40,43 @@ describe QuizApiClient::Services::QuizCloneJobsService do
40
40
  end
41
41
  end
42
42
 
43
+ describe '#update' do
44
+ let(:body) { { resource_map_url: 'http://foo.bar/123' } }
45
+ let(:params) { { id: 1 } }
46
+ let(:expected_url) { "https://#{host}/api/quiz_clone_jobs/#{params.fetch(:id)}" }
47
+ let(:stubbed_response) { { 'id' => '1' } }
48
+
49
+ context 'on success' do
50
+ before do
51
+ stub_request(:put, expected_url)
52
+ .to_return(
53
+ status: 200,
54
+ body: stubbed_response.to_json,
55
+ headers: { 'Content-Type' => 'application/json' }
56
+ )
57
+ end
58
+
59
+ it 'puts to /api/quiz_clone_jobs/:id' do
60
+ result = subject.update(body: body, params: params, token: 'token')
61
+ expect(result.parsed_response).to eql(stubbed_response)
62
+ end
63
+ end
64
+
65
+ context 'on failure' do
66
+ let(:status_code) { 401 }
67
+
68
+ before do
69
+ stub_request(:put, expected_url)
70
+ .to_return(status: status_code)
71
+ end
72
+
73
+ it 'returns a response with the correct code' do
74
+ response = subject.update(body: body, params: params, token: 'token')
75
+ expect(response.code).to eq(status_code)
76
+ end
77
+ end
78
+ end
79
+
43
80
  describe '#create_batch' do
44
81
  let(:expected_url) { "https://#{host}/api/quiz_clone_jobs/create_batch" }
45
82
  let(:body) { { quiz_ids: [1, 2] } }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quiz_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.13.4
4
+ version: 4.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Slaughter
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: exe
17
17
  cert_chain: []
18
- date: 2023-09-29 00:00:00.000000000 Z
18
+ date: 2023-10-23 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty