quiz_api_client 4.14.1 → 4.16.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 +4 -4
- data/lib/quiz_api_client/services/account_service.rb +16 -0
- data/lib/quiz_api_client/services/items_service.rb +15 -0
- data/lib/quiz_api_client/version.rb +1 -1
- data/lib/quiz_api_client.rb +5 -0
- data/spec/services/account_service_spec.rb +38 -0
- data/spec/services/items_service_spec.rb +28 -0
- metadata +5 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8956ccc8a8479d5daeeb2522f42581495c2e39934d221df99fbc4e697e6d13ca
         | 
| 4 | 
            +
              data.tar.gz: 8399e28b565d2f608d1315e78220fa49d6bade8c06483c88f396ebb802f850c3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 5eaeeec5e0452e1c71aa4f3a9ea86228e73ab1fc7b9d82aa7eee73d94154dfb65af0d76468cb9d826c2bd22ff8b71ec6b39767dc0de1119fff6fa1b7b2be744b
         | 
| 7 | 
            +
              data.tar.gz: b045527ab2f0cc7114124d950bbcd4811cee1014fe93db94fe12e33beff083e986c0be38b67ec6a68cea334cdbc3e6e4c08738bc6b43bb1e65660d5abf731151
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            module QuizApiClient::Services
         | 
| 2 | 
            +
              class AccountService < BaseApiService
         | 
| 3 | 
            +
                def update(params, token: nil)
         | 
| 4 | 
            +
                  patch_to_quiz_api(params: params, token: token)
         | 
| 5 | 
            +
                end
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                private
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def patch_to_quiz_api(params:, token:)
         | 
| 10 | 
            +
                  client(token: token).patch(
         | 
| 11 | 
            +
                    '/api/account',
         | 
| 12 | 
            +
                    course: params
         | 
| 13 | 
            +
                  )
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -25,6 +25,12 @@ module QuizApiClient::Services | |
| 25 25 | 
             
                  get_media_upload_url_from_quiz_api(params: params, token: token)
         | 
| 26 26 | 
             
                end
         | 
| 27 27 |  | 
| 28 | 
            +
                def bulk_update_item_alignments(params:, token:)
         | 
| 29 | 
            +
                  raise 'Quiz Id Required' unless params && params[:quiz_id]
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  put_bulk_item_outcome_alignments_update(params: params, token: token)
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 28 34 | 
             
                private
         | 
| 29 35 |  | 
| 30 36 | 
             
                def list_from_quiz_api(params:, token:)
         | 
| @@ -55,5 +61,14 @@ module QuizApiClient::Services | |
| 55 61 | 
             
                  quiz_id = params.delete(:quiz_id)
         | 
| 56 62 | 
             
                  client(token: token).get("/api/quizzes/#{quiz_id}/items/media_upload_url")
         | 
| 57 63 | 
             
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                def put_bulk_item_outcome_alignments_update(params:, token:)
         | 
| 66 | 
            +
                  quiz_id = params.delete(:quiz_id)
         | 
| 67 | 
            +
                  client(token: token).put(
         | 
| 68 | 
            +
                    "/api/quizzes/#{quiz_id}/items/update_outcome_alignments",
         | 
| 69 | 
            +
                    quiz_id: quiz_id,
         | 
| 70 | 
            +
                    items: params
         | 
| 71 | 
            +
                  )
         | 
| 72 | 
            +
                end
         | 
| 58 73 | 
             
              end
         | 
| 59 74 | 
             
            end
         | 
    
        data/lib/quiz_api_client.rb
    CHANGED
    
    | @@ -18,6 +18,10 @@ module QuizApiClient | |
| 18 18 | 
             
                  yield(config) if block_given?
         | 
| 19 19 | 
             
                end
         | 
| 20 20 |  | 
| 21 | 
            +
                def account_service
         | 
| 22 | 
            +
                  @_account_service ||= Services::AccountService.new(config)
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 21 25 | 
             
                def bank_service
         | 
| 22 26 | 
             
                  @_bank_service ||= Services::BankService.new(config)
         | 
| 23 27 | 
             
                end
         | 
| @@ -134,6 +138,7 @@ require 'quiz_api_client/http_request/metrics' | |
| 134 138 | 
             
            require 'quiz_api_client/services/jwt_service'
         | 
| 135 139 | 
             
            require 'quiz_api_client/services/base_api_service'
         | 
| 136 140 |  | 
| 141 | 
            +
            require 'quiz_api_client/services/account_service'
         | 
| 137 142 | 
             
            require 'quiz_api_client/services/bank_service'
         | 
| 138 143 | 
             
            require 'quiz_api_client/services/bank_entries_service'
         | 
| 139 144 | 
             
            require 'quiz_api_client/services/content_exports_service'
         | 
| @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            RSpec.describe QuizApiClient::Services::AccountService do
         | 
| 2 | 
            +
              let(:host) { 'api.host' }
         | 
| 3 | 
            +
              let(:config) { QuizApiClient::Config.new { |c| c.host = host } }
         | 
| 4 | 
            +
              let(:subject) { described_class.new(config) }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              describe '#update' do
         | 
| 7 | 
            +
                let(:params) do
         | 
| 8 | 
            +
                  {
         | 
| 9 | 
            +
                    account: { tenant_domain: 'foo.instructure.com' }
         | 
| 10 | 
            +
                  }
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                let(:response) do
         | 
| 14 | 
            +
                  {
         | 
| 15 | 
            +
                    'id' => '1',
         | 
| 16 | 
            +
                    'uuid' => '5862e3c7-b598-40c8-996f-cd0cd1778358',
         | 
| 17 | 
            +
                    'tenant_domain' => params[:tenant_domain]
         | 
| 18 | 
            +
                  }
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                let(:expected_url) { "https://#{host}/api/account" }
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                before do
         | 
| 24 | 
            +
                  stub_request(:patch, 'https://api.host/api/account')
         | 
| 25 | 
            +
                    .to_return(
         | 
| 26 | 
            +
                      status: 200,
         | 
| 27 | 
            +
                      body: response.to_json,
         | 
| 28 | 
            +
                      headers: { 'Content-Type' => 'application/json' }
         | 
| 29 | 
            +
                    )
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                it 'pathces to the correct endpoint and returns the response' do
         | 
| 33 | 
            +
                  expect(
         | 
| 34 | 
            +
                    subject.update(params: params, token: 'token').parsed_response
         | 
| 35 | 
            +
                  ).to eq(response)
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
            end
         | 
| @@ -100,4 +100,32 @@ describe QuizApiClient::Services::ItemsService do | |
| 100 100 | 
             
                  expect(result.parsed_response).to eql(stubbed_response)
         | 
| 101 101 | 
             
                end
         | 
| 102 102 | 
             
              end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
              describe '#update_outcome_alignments' do
         | 
| 105 | 
            +
                let(:put_url) { "https://#{host}/api/quizzes/1/items/update_outcome_alignments" }
         | 
| 106 | 
            +
                let(:params) do
         | 
| 107 | 
            +
                  {
         | 
| 108 | 
            +
                    items: [
         | 
| 109 | 
            +
                      { item_id: 1, outcome_alignment_set_guid: '29d04bab-e499-498b-ae47-bcc6a80ed924' },
         | 
| 110 | 
            +
                      { item_id: 2, outcome_alignment_set_guid: 'f9d5002d-7ef5-4341-bf16-471a83a32add' }
         | 
| 111 | 
            +
                    ],
         | 
| 112 | 
            +
                    quiz_id: 1
         | 
| 113 | 
            +
                  }
         | 
| 114 | 
            +
                end
         | 
| 115 | 
            +
                it 'returns status ok' do
         | 
| 116 | 
            +
                  stub_request(:put, put_url)
         | 
| 117 | 
            +
                    .to_return(
         | 
| 118 | 
            +
                      status: 200,
         | 
| 119 | 
            +
                      headers: { 'Content-Type' => 'application/json' }
         | 
| 120 | 
            +
                    )
         | 
| 121 | 
            +
                  result = subject.bulk_update_item_alignments(params: params, token: 'token')
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                  expect(result.code).to eql(200)
         | 
| 124 | 
            +
                end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                it 'raise error for missing quiz_id parameter' do
         | 
| 127 | 
            +
                  params.delete(:quiz_id)
         | 
| 128 | 
            +
                  expect { subject.bulk_update_item_alignments(params: p, token: 'token') }.to raise_error('Quiz Id Required')
         | 
| 129 | 
            +
                end
         | 
| 130 | 
            +
              end
         | 
| 103 131 | 
             
            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. | 
| 4 | 
            +
              version: 4.16.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: 2024- | 
| 18 | 
            +
            date: 2024-06-04 00:00:00.000000000 Z
         | 
| 19 19 | 
             
            dependencies:
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 21 21 | 
             
              name: httparty
         | 
| @@ -179,6 +179,7 @@ files: | |
| 179 179 | 
             
            - lib/quiz_api_client/http_request/failure.rb
         | 
| 180 180 | 
             
            - lib/quiz_api_client/http_request/metrics.rb
         | 
| 181 181 | 
             
            - lib/quiz_api_client/json_formatter.rb
         | 
| 182 | 
            +
            - lib/quiz_api_client/services/account_service.rb
         | 
| 182 183 | 
             
            - lib/quiz_api_client/services/analyses_service.rb
         | 
| 183 184 | 
             
            - lib/quiz_api_client/services/bank_entries_service.rb
         | 
| 184 185 | 
             
            - lib/quiz_api_client/services/bank_service.rb
         | 
| @@ -212,6 +213,7 @@ files: | |
| 212 213 | 
             
            - spec/quiz_api_client/http_request/failure_spec.rb
         | 
| 213 214 | 
             
            - spec/quiz_api_client/http_request/metrics_spec.rb
         | 
| 214 215 | 
             
            - spec/quiz_api_client_spec.rb
         | 
| 216 | 
            +
            - spec/services/account_service_spec.rb
         | 
| 215 217 | 
             
            - spec/services/analyses_service_spec.rb
         | 
| 216 218 | 
             
            - spec/services/bank_entries_service_spec.rb
         | 
| 217 219 | 
             
            - spec/services/bank_service_spec.rb
         | 
| @@ -267,6 +269,7 @@ test_files: | |
| 267 269 | 
             
            - spec/quiz_api_client/http_request/failure_spec.rb
         | 
| 268 270 | 
             
            - spec/quiz_api_client/http_request/metrics_spec.rb
         | 
| 269 271 | 
             
            - spec/quiz_api_client_spec.rb
         | 
| 272 | 
            +
            - spec/services/account_service_spec.rb
         | 
| 270 273 | 
             
            - spec/services/analyses_service_spec.rb
         | 
| 271 274 | 
             
            - spec/services/bank_entries_service_spec.rb
         | 
| 272 275 | 
             
            - spec/services/bank_service_spec.rb
         |