Module: Exercises
Instance Method Summary collapse
-
#get_exercise(id) ⇒ HTTParty::Response
Get an exercise.
-
#get_exercises ⇒ HTTParty::Response
Get all exercises.
-
#update_exercise(id, options = {}) ⇒ Exercise
Update an exercise.
Methods included from BaseAtlasClient
#auth_header, #convert_keys, #convert_response, #handle_timeouts, #success?, #whitelist_params
Instance Method Details
#get_exercise(id) ⇒ HTTParty::Response
Get an exercise
24 25 26 27 28 29 30 |
# File 'lib/client/exercises.rb', line 24 def get_exercise(id) url = "#{@api_base_path}/exercises/" + id.to_s handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "exercise") end end |
#get_exercises ⇒ HTTParty::Response
Get all exercises
11 12 13 14 15 16 17 |
# File 'lib/client/exercises.rb', line 11 def get_exercises url = "#{@api_base_path}/exercises" handle_timeouts do response = self.class.get(url, headers: auth_header) convert_response(response, "exercises") end end |
#update_exercise(id, options = {}) ⇒ Exercise
Update an exercise
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/client/exercises.rb', line 47 def update_exercise(id, ={}) whitelist = [ 'name', 'description', 'body', 'status', 'slug', 'specs', 'starting_code', 'canonical_solution', 'language', 'run_strategy_attributes', 'starting_code', 'canonical_solution', 'instructions' ] = convert_keys() params = whitelist_params(, whitelist) url = "#{@api_base_path}/exercises/#{id}" handle_timeouts do response = self.class.put(url, headers: auth_header, body: { exercise: params }) convert_response(response, "exercise") end end |