Class: Spartacus
Instance Method Summary collapse
-
#base_path ⇒ String
Set Base API Path.
-
#handle_timeouts ⇒ Object
Handle API timouts.
-
#initialize(api_jwt) ⇒ Spartacus
constructor
A new instance of Spartacus.
-
#update_checkpoint(id, options = {}) ⇒ HTTParty::Response
Update a checkpoint.
Constructor Details
#initialize(api_jwt) ⇒ Spartacus
Returns a new instance of Spartacus.
6 7 8 |
# File 'lib/spartacus.rb', line 6 def initialize(api_jwt) @api_jwt = api_jwt end |
Instance Method Details
#base_path ⇒ String
Set Base API Path
12 13 14 |
# File 'lib/spartacus.rb', line 12 def base_path "http://localhost:3000/api/v1" end |
#handle_timeouts ⇒ Object
Handle API timouts
17 18 19 20 21 22 23 |
# File 'lib/spartacus.rb', line 17 def handle_timeouts begin yield rescue Net::OpenTimeout, Net::ReadTimeout {} end end |
#update_checkpoint(id, options = {}) ⇒ HTTParty::Response
Update a checkpoint
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/spartacus.rb', line 38 def update_checkpoint(id, ={}) accepted_params = ['name', 'summary', 'body', 'assignment', 'points', 'body_and_assignment'] checkpoint_params = .select {|k, v| accepted_params.include?(k) } update_checkpoint_url = "#{base_path}/checkpoints/#{id}" handle_timeouts do self.class.put(update_checkpoint_url, headers: auth_header, query: { checkpoint: checkpoint_params }) end end |