quiz_api_client 4.8.1 → 4.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7106b8bf0d1cc91d986ed54ea8b81d597813b2885d62dbde152aa4a6c55e0f42
4
- data.tar.gz: 2bcb83542296f0f8aaf4e861e726bc7e82162b79207c8be6aaf16e0be70e95fb
3
+ metadata.gz: 512285775df9e9cc2a4e382f25dcf87847f4bf7b73daa98f78681aa847ad3979
4
+ data.tar.gz: 9a8208b7abe38315baac2adfbf2e7b38ebc23e11d81d79b61b8360a65f5c9bde
5
5
  SHA512:
6
- metadata.gz: 16fb4f39928faeb5b0d5ead2511bee4c1720b6d29aecd898afe1d6406196b8aa28c3e8375d022c279318eee7bca38ee6b20dbda5ce89153bda46185187023502
7
- data.tar.gz: 3387a506254fd75537e1925419f0cc4a793accb5946a281e7539f5cf0dd5af5ded63c1ad03c7579c71abbdf7508f7e070974598e6db161b2d30f20025136b5f1
6
+ metadata.gz: 72acb2a511704dfccb3b205f12c0cfe5998b6c2c3bd9667955c5a3978856e5940df63d8387c18249a368637cda35005f20ada66bbdfede72db0457985f52957d
7
+ data.tar.gz: 532c4634204b44b0a672bf975ef6f7c7ad2fac7cef39116dc4fe9c46b44b5a68b7016618a987be9819bcbc2fc97a56596d841bf3db0711846a166af7b139267b
@@ -19,6 +19,12 @@ module QuizApiClient::Services
19
19
  put_to_quiz_api(params: params, token: token)
20
20
  end
21
21
 
22
+ def media_upload_url(params:, token: nil)
23
+ raise 'Quiz Id Required' unless params && params[:quiz_id]
24
+
25
+ get_media_upload_url_from_quiz_api(params: params, token: token)
26
+ end
27
+
22
28
  private
23
29
 
24
30
  def list_from_quiz_api(params:, token:)
@@ -44,5 +50,10 @@ module QuizApiClient::Services
44
50
  item: params
45
51
  )
46
52
  end
53
+
54
+ def get_media_upload_url_from_quiz_api(params:, token:)
55
+ quiz_id = params.delete(:quiz_id)
56
+ client(token: token).get("/api/quizzes/#{quiz_id}/items/media_upload_url")
57
+ end
47
58
  end
48
59
  end
@@ -15,7 +15,7 @@ module QuizApiClient::Services
15
15
 
16
16
  def update(params:, token: nil)
17
17
  raise 'Quiz Id Required' unless params && params[:quiz_id]
18
- raise 'Entry Id Required' unless params[:entry_id]
18
+ raise 'Entry Id Required' unless params[:id]
19
19
 
20
20
  put_to_quiz_api(params: params, token: token)
21
21
  end
@@ -51,7 +51,7 @@ module QuizApiClient::Services
51
51
 
52
52
  def put_to_quiz_api(params:, token:)
53
53
  client(token: token).put(
54
- "/api/quizzes/#{params[:quiz_id]}/quiz_entries/#{params[:entry_id]}",
54
+ "/api/quizzes/#{params[:quiz_id]}/quiz_entries/#{params[:id]}",
55
55
  quiz_entry: params
56
56
  )
57
57
  end
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.8.1'.freeze
2
+ VERSION = '4.9.1'.freeze
3
3
  end
@@ -79,4 +79,25 @@ describe QuizApiClient::Services::ItemsService do
79
79
  expect { subject.update(params: { quiz_id: 1 }, token: 'token') }.to raise_error('Item Id Required')
80
80
  end
81
81
  end
82
+
83
+ describe '#media_upload_url' do
84
+ let(:params) { { quiz_id: 1 } }
85
+ let(:stubbed_response) { { 'url' => 'awsuploadurl' } }
86
+ let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/items/media_upload_url" }
87
+ let(:status_code) { 200 }
88
+
89
+ before do
90
+ stub_request(:get, expected_url)
91
+ .to_return(
92
+ status: status_code,
93
+ body: stubbed_response.to_json,
94
+ headers: { 'Content-Type' => 'application/json' }
95
+ )
96
+ end
97
+
98
+ it 'gets from quiz_api/api/quizzes/{id}/items/media_upload_url and returns the response' do
99
+ result = subject.media_upload_url(params: params, token: 'token')
100
+ expect(result.parsed_response).to eql(stubbed_response)
101
+ end
102
+ end
82
103
  end
@@ -74,9 +74,9 @@ describe QuizApiClient::Services::QuizEntriesService do
74
74
  end
75
75
 
76
76
  describe '#update' do
77
- let(:params) { { quiz_id: 1, entry_id: 1, points_possible: 1 } }
77
+ let(:params) { { quiz_id: 1, id: 1, points_possible: 1 } }
78
78
  let(:stubbed_response) { { 'id' => 1, 'entry' => { 'id' => 1 } } }
79
- let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/quiz_entries/#{params[:entry_id]}" }
79
+ let(:expected_url) { "https://#{host}/api/quizzes/#{params[:quiz_id]}/quiz_entries/#{params[:id]}" }
80
80
  let(:status_code) { 200 }
81
81
  before do
82
82
  stub_request(:put, expected_url)
@@ -87,7 +87,7 @@ describe QuizApiClient::Services::QuizEntriesService do
87
87
  )
88
88
  end
89
89
 
90
- it 'puts to quiz_api/api/quizzes/{quiz_id}/quiz_entries/{entry_id} and returns the response' do
90
+ it 'puts to quiz_api/api/quizzes/{quiz_id}/quiz_entries/{id} and returns the response' do
91
91
  result = subject.update(params: params, token: 'token')
92
92
  expect(result.parsed_response).to eql(stubbed_response)
93
93
  end
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.8.1
4
+ version: 4.9.1
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-03-06 00:00:00.000000000 Z
18
+ date: 2023-03-16 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty