Sha256: 681fa2d875fb03064383437f22c446000ccec192d95cbc44a30c43e90484e4d0

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module ThinkificRuby
  class CourseReview

    extend ThinkificRuby::Connection
    extend ThinkificRuby::ResourceHelper

    class << self
      def index(course_id, options = {})
        raise_input_error_if_not_natural_number(course_id)

        response = connection.get('/api/public/v1/course_reviews') do |req|
                     req.params['course_id'] = course_id
                     
                     options.each {|key, value| req.params[key.to_s] = value }
                   end

        parsed_response = JSON.parse(response.body)

        raise_error_if_response_status_not_200_or_return_parsed_response(response.status, parsed_response)
      end

      def show(id)
        raise_input_error_if_not_natural_number(id)

        response = connection.get("/api/public/v1/course_reviews/#{ id }")

        JSON.parse(response.body)
      end

      def create(options = {})
        
        response = connection.post('/api/public/v1/course_reviews') do |req|
                     options.each {|key, value| req.params[key.to_s] = value }
                   end

        JSON.parse(response.body)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinkific_ruby_test-0.1.0 lib/thinkific_ruby/course_review.rb