Class: CodewarsApi::AttemptSolution

Inherits:
Object
  • Object
show all
Defined in:
lib/codewars_api/attempt_solution.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ AttemptSolution


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/codewars_api/attempt_solution.rb', line 3

def initialize(options)
  api_key = options.delete!(:api_key)
  project_id = options.delete!(:project_id)
  solution_id = options.delete!(:solution_id)

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

  @response = RequestHelper.post(
    "#{CodewarsApi::API_URL}"\
    "/code-challenges/projects/#{project_id}/solutions/#{solution_id}/attempt",
    request_options
  )
end

Instance Method Details

#dmidObject


23
24
25
# File 'lib/codewars_api/attempt_solution.rb', line 23

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

#successObject


19
20
21
# File 'lib/codewars_api/attempt_solution.rb', line 19

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

#to_hObject


27
28
29
# File 'lib/codewars_api/attempt_solution.rb', line 27

def to_h
  @response.to_h
end