Sha256: 655ac2d631bcddd2a9347e96047ecb11e5b24573960a7be532b3866088793f2c

Contents?: true

Size: 1.13 KB

Versions: 16

Compression:

Stored size: 1.13 KB

Contents

module QuizApiClient::Services
  class QuizEntriesService < BaseApiService
    def create(params:, token: nil)
      raise 'Quiz Id Required' unless params && params[:id]

      post_to_quiz_api(params: params, token: token)
    end

    def list(params:, token: nil, all: false)
      raise 'Quiz Id Required' unless params && params[:id]

      get_from_quiz_api(params: params, token: token, all: all)
    end

    def destroy(params:, token: nil)
      raise 'Quiz Id Required' unless params && params[:quiz_id]
      raise 'Item Id Required' unless params && params[:id]

      delete_from_quiz_api(params, token)
    end

    private

    def post_to_quiz_api(params:, token:)
      client(token: token).post(
        "/api/quizzes/#{params[:id]}/quiz_entries",
        quiz_entry: params
      )
    end

    def get_from_quiz_api(params:, token:, all:)
      client(token: token).get(
        "/api/quizzes/#{params[:id]}/quiz_entries",
        all: all
      )
    end

    def delete_from_quiz_api(params, token)
      client(token: token).delete(
        "/api/quizzes/#{params[:quiz_id]}/quiz_entries/#{params[:id]}"
      )
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
quiz_api_client-4.6.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.5.5 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.5.4 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.5.3 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.5.2 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.5.1 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.5.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.4.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.3.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.2.1 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.2.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.1.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-4.0.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-3.2.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-3.1.0 lib/quiz_api_client/services/quiz_entries_service.rb
quiz_api_client-3.0.0 lib/quiz_api_client/services/quiz_entries_service.rb