Sha256: c558da16c66ae87ff108cc471eafafbf033c1454ff9683b5d0ab55d0edd7e458
Contents?: true
Size: 1005 Bytes
Versions: 2
Compression:
Stored size: 1005 Bytes
Contents
class Exercism class Api def self.conn conn = Faraday.new(:url => Exercism.url) do |c| c.use Faraday::Adapter::NetHttp end end def self.fetch_for(user) response = conn.get do |req| req.url '/api/v1/user/assignments/current' req.headers['User-Agent'] = "exercism-CLI v#{Exercism::VERSION}" req.params['key'] = user.key end assignment = Assignment.new(JSON.parse(response.body)) assignment.save end def self.submit(filename, options) user = options[:for] path = File.join(FileUtils.pwd, filename) contents = File.read path response = conn.post do |req| req.url '/api/v1/user/assignments' req.headers['Accept'] = 'application/json' req.headers['Content-Type'] = 'application/json' req.headers['User-Agent'] = "exercism-CLI v#{Exercism::VERSION}" req.body = {code: contents, key: user.key, path: path}.to_json end response end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
exercism-0.0.3 | lib/exercism/api.rb |
exercism-0.0.2 | lib/exercism/api.rb |