class SphereEngine::SphereEngineClient
Attributes
access_token[RW]
Public Class Methods
new(token)
click to toggle source
# File lib/sphereengine-ruby/client.rb, line 7 def initialize(token) @access_token = token end
Public Instance Methods
fetch_submission(id, with_source = true, with_input = true, with_output = true, with_stderr = true, with_cmpinfo = true)
click to toggle source
# File lib/sphereengine-ruby/client.rb, line 30 def fetch_submission(id, with_source = true, with_input = true, with_output = true, with_stderr = true, with_cmpinfo = true) uri = URI(SphereEngine::Request::BASE_URL + SphereEngine::Request::FETCH_SUBMISSION_ENDPOINT.sub(':id', id.to_s)) uri.query = URI.encode_www_form({"access_token" => access_token, "withSource" => with_source, "withInput" => with_input, "withOutput" => with_output, "withStderr" => with_stderr, "withCmpinfo" => with_cmpinfo}) JSON.parse Net::HTTP.get_response(uri).body end
languages()
click to toggle source
# File lib/sphereengine-ruby/client.rb, line 17 def languages uri = URI(SphereEngine::Request::BASE_URL + SphereEngine::Request::LANGUAGES_ENDPOINT) uri.query = URI.encode_www_form({"access_token" => access_token}) JSON.parse Net::HTTP.get_response(uri).body end
send_submission(source_code, language, input)
click to toggle source
# File lib/sphereengine-ruby/client.rb, line 23 def send_submission(source_code, language, input) uri = URI(SphereEngine::Request::BASE_URL + SphereEngine::Request::SUBMISSIONS_ENDPOINT) uri.query = URI.encode_www_form({"access_token" => access_token}) response = Net::HTTP.post_form(uri, {'sourceCode' => source_code, 'language' => language, 'input' => input}) JSON.parse response.body end
test_connection()
click to toggle source
# File lib/sphereengine-ruby/client.rb, line 11 def test_connection uri = URI(SphereEngine::Request::BASE_URL + SphereEngine::Request::TEST_ENDPOINT) uri.query = URI.encode_www_form({"access_token" => access_token}) JSON.parse Net::HTTP.get_response(uri).body end