lib/exercism/api.rb in exercism-0.0.15 vs lib/exercism/api.rb in exercism-0.0.16

- old
+ new

@@ -13,23 +13,27 @@ c.use Faraday::Adapter::NetHttp c.headers['User-Agent'] = user_agent end end + def demo + get_and_save('assignments/demo') + end + def fetch - get_and_save('current') + get_and_save('user/assignments/current') end def peek - get_and_save('next') + get_and_save('user/assignments/next') end def submit(filename) path = File.join(filename) contents = File.read path response = conn.post do |req| - req.url endpoint + req.url endpoint('user/assignments') req.headers['Accept'] = 'application/json' req.headers['Content-Type'] = 'application/json' req.body = {code: contents, key: user.key, path: path}.to_json end response @@ -48,10 +52,10 @@ def user_agent "github.com/kytrinyx/exercism CLI v#{Exercism::VERSION}" end def endpoint(action = nil) - "/api/v1/user/assignments/#{action}".chomp('/') + "/api/v1/#{action}".chomp('/') end def save(body) Assignment.save(JSON.parse(body), project_dir) end