quiz_api_client 4.8.0 → 4.9.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: 057d0dea94cbf0a0781d3c8144906a8ea7b29790f278f4d4a55891aaf6c3a12b
4
- data.tar.gz: c5241135784c367e250fe0fb0a1e6012fc391c2a9d09c1225173f1acfbb3a595
3
+ metadata.gz: 505c41cc94d0ac7bb263ce3951d11de97c6c614b424de4db4f9f6ab54c35ff60
4
+ data.tar.gz: 1b444571e9db200d6dd3ddeb2d34531b1823e3ddb16fbced3c31121c00a8c6ff
5
5
  SHA512:
6
- metadata.gz: 89212f479d1081e38ad2005e5f7b84a4c3c5088b1620c6673cc2538fa719ed73f9eba1df31c5bca786c0efa4c3755d9e5bcd37e2508e7aaec73ee8ad41b1bdc4
7
- data.tar.gz: b2be42851612a9fae066ff5dcfdd322e6d66d821ddd03fa53083e8713e90c8d4ad780de177c4f13752919897ffc0e720e8b8aa2db98f27e159c73e3f64e9cd2f
6
+ metadata.gz: 91cc0b90020b44e09f16051de5e39dbf7c5c2e95ebaa5e5afec64b7061a495c04c64c912f8eb6cb78c4d52df8038ed3e8446d255239569921aa88ccf4294b69c
7
+ data.tar.gz: 34e1785c1e890cb4c13c1988f03254c98242f8419cc3ce7a48f48036e756d8117266891d7837bcbc75818638bdc177ad11570c3ecb063a8f9cbbad5f61a1be51
@@ -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
@@ -23,7 +23,8 @@ module QuizApiClient::Services
23
23
  def list(params:, token: nil, all: false)
24
24
  raise 'Quiz Id Required' unless params && params[:id]
25
25
 
26
- get_from_quiz_api(params: params, token: token, all: all)
26
+ pagination_params = { page: params.delete(:page), per_page: params.delete(:per_page) }
27
+ get_from_quiz_api(params: params, token: token, pagination_params: pagination_params, all: all)
27
28
  end
28
29
 
29
30
  def destroy(params:, token: nil)
@@ -55,9 +56,10 @@ module QuizApiClient::Services
55
56
  )
56
57
  end
57
58
 
58
- def get_from_quiz_api(params:, token:, all:)
59
+ def get_from_quiz_api(params:, token:, pagination_params:, all:)
59
60
  client(token: token).get(
60
61
  "/api/quizzes/#{params[:id]}/quiz_entries",
62
+ query: pagination_params,
61
63
  all: all
62
64
  )
63
65
  end
@@ -1,3 +1,3 @@
1
1
  module QuizApiClient
2
- VERSION = '4.8.0'.freeze
2
+ VERSION = '4.9.0'.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
@@ -6,7 +6,7 @@ describe QuizApiClient::Services::QuizEntriesService do
6
6
  describe '#list' do
7
7
  let(:params) { { id: 1 } }
8
8
  let(:stubbed_response) { { 'id' => 1, 'entry' => { 'id' => 1 } } }
9
- let(:expected_url) { "https://#{host}/api/quizzes/#{params[:id]}/quiz_entries" }
9
+ let(:expected_url) { "https://#{host}/api/quizzes/#{params[:id]}/quiz_entries?page=&per_page=" }
10
10
  let(:status_code) { 200 }
11
11
 
12
12
  before do
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.0
4
+ version: 4.9.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-02-24 00:00:00.000000000 Z
18
+ date: 2023-03-15 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httparty