Module: CodewarsClient
- Extended by:
- Client, Configuration
- Defined in:
- lib/codewars_client.rb,
lib/codewars_client/user.rb,
lib/codewars_client/client.rb,
lib/codewars_client/version.rb,
lib/codewars_client/finalize.rb,
lib/codewars_client/next_kata.rb,
lib/codewars_client/configuration.rb,
lib/codewars_client/object_builder.rb,
lib/codewars_client/attempt_solution.rb,
lib/codewars_client/deferred_response.rb
Defined Under Namespace
Modules: Client, Configuration, ObjectBuilder
Classes: AttemptSolution, DeferredResponse, Finalize, InvalidLanguageSelection, NextKata, User
Constant Summary
collapse
- VALID_LANGUAGES =
[
:clojure, :coffescript, :c, :haskell, :java, :javascript, :python, :ruby
]
- VERSION =
"0.1.0"
Configuration::API_KEY_DEFAULT, Configuration::API_VERSION, Configuration::DEFAULT_ENDPOINT, Configuration::PUBLIC_METHODS
Constants included
from Client
Client::PUBLIC_METHODS
Class Method Summary
collapse
configure
Class Method Details
.attemp_solution(kata:, code:) ⇒ Object
32
33
34
35
36
37
38
|
# File 'lib/codewars_client.rb', line 32
def attemp_solution(kata:, code:)
status, response = post(path: NextKata::PATH,
params: ['projects', kata.project_id, 'solutions', kata.solution_id, 'attempt'],
body: code
)
AttemptSolution.new(data: _parse_response(status, response))
end
|
.deferred_response(dmid:) ⇒ Object
40
41
42
43
|
# File 'lib/codewars_client.rb', line 40
def deferred_response(dmid:)
status, response = get(path: DeferredResponse::PATH, params: dmid)
DeferredResponse.new(data: _parse_response(status, response))
end
|
.finalize(kata:) ⇒ Object
46
47
48
49
50
51
|
# File 'lib/codewars_client.rb', line 46
def finalize(kata:)
status, response = post(path: NextKata::PATH,
params: ['projects', kata.project_id, 'solutions', kata.solution_id, 'finalize']
)
Finalize.new(data: _parse_response(status, response))
end
|
.next_kata(language:) ⇒ Object
26
27
28
29
30
|
# File 'lib/codewars_client.rb', line 26
def next_kata(language:)
fail InvalidLanguageSelection unless VALID_LANGUAGES.include?(language.to_sym)
status, response = post(path: NextKata::PATH, params: [language.to_s, 'train'])
NextKata.new(data: _parse_response(status, response))
end
|
.user(username_or_id:) ⇒ Object
21
22
23
24
|
# File 'lib/codewars_client.rb', line 21
def user(username_or_id:)
status, response = get(path: User::PATH, params: username_or_id)
User.new(data: _parse_response(status, response))
end
|