Class: CodewarsApi::DeferredResponse

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
lib/codewars_api/deferred_response.rb

Instance Method Summary collapse

Methods included from Common

#reason, #success, #to_h

Constructor Details

#initialize(options) ⇒ DeferredResponse

Returns a new instance of DeferredResponse.



5
6
7
8
9
10
11
12
13
14
# File 'lib/codewars_api/deferred_response.rb', line 5

def initialize(options)
  api_key = options.delete!(:api_key)
  dmid = options.delete!(:dmid)

  request_options = {}
  request_options = RequestHelper.add_api_key(request_options, api_key)

  @response = RequestHelper.get("#{CodewarsApi::API_URL}/deferred/#{dmid}", request_options)
  ResponseChecker.check_errors(@response)
end

Instance Method Details

#dmidObject



16
17
18
# File 'lib/codewars_api/deferred_response.rb', line 16

def dmid
  @response.to_h['dmid']
end

#errorsObject



36
37
38
# File 'lib/codewars_api/deferred_response.rb', line 36

def errors
  @response.to_h['errors']
end

#failedObject



40
41
42
# File 'lib/codewars_api/deferred_response.rb', line 40

def failed
  @response.to_h['failed']
end

#outputObject



60
61
62
# File 'lib/codewars_api/deferred_response.rb', line 60

def output
  @response.to_h['output']
end

#passedObject



32
33
34
# File 'lib/codewars_api/deferred_response.rb', line 32

def passed
  @response.to_h['passed']
end

#server_errorObject



28
29
30
# File 'lib/codewars_api/deferred_response.rb', line 28

def server_error
  @response.to_h['server_error']
end

#solution_idObject



20
21
22
# File 'lib/codewars_api/deferred_response.rb', line 20

def solution_id
  @response.to_h['solution_id']
end

#status_codeObject



68
69
70
# File 'lib/codewars_api/deferred_response.rb', line 68

def status_code
  @response.to_h['status_code']
end

#summary_errorsObject



56
57
58
# File 'lib/codewars_api/deferred_response.rb', line 56

def summary_errors
  @response.to_h['summary'].andand['errors']
end

#summary_failedObject



52
53
54
# File 'lib/codewars_api/deferred_response.rb', line 52

def summary_failed
  @response.to_h['summary'].andand['failed']
end

#summary_passedObject



48
49
50
# File 'lib/codewars_api/deferred_response.rb', line 48

def summary_passed
  @response.to_h['summary'].andand['passed']
end

#timed_outObject



44
45
46
# File 'lib/codewars_api/deferred_response.rb', line 44

def timed_out
  @response.to_h['timed_out']
end

#validObject



24
25
26
# File 'lib/codewars_api/deferred_response.rb', line 24

def valid
  @response.to_h['valid']
end

#wall_timeObject



64
65
66
# File 'lib/codewars_api/deferred_response.rb', line 64

def wall_time
  @response.to_h['wall_time']
end