Sha256: 4b754b28f5a161febde309347e076a8e5c5f3ec4fc1ef7722a3af3dceb1241b8

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

module CodewarsApi
  class TrainSpecificKata
    include Common

    def initialize(options)
      api_key = options.delete!(:api_key)
      language = options.delete!(:language)
      id_or_slug = options.delete!(:id_or_slug)

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

      @response = RequestHelper.post(
        "#{CodewarsApi::API_URL}/code-challenges/#{id_or_slug}/#{language}/train",
        request_options
      )
      ResponseChecker.check_errors(@response)
    end

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

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

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

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

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

    def average_completion
      @response.to_h['averageCompletion']
    end

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

    def project_id
      @response.to_h['session'].andand['projectId']
    end

    def solution_id
      @response.to_h['session'].andand['solutionId']
    end

    def code_setup
      @response.to_h['session'].andand['setup']
    end

    def tests_setup
      @response.to_h['session'].andand['exampleFixture']
    end

    def code
      @response.to_h['session'].andand['code']
    end

    def recently_attempted
      @response.to_h['session'].andand['recentlyAttempted']
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
codewars_api-0.4.2 lib/codewars_api/train_specific_kata.rb
codewars_api-0.4.1 lib/codewars_api/train_specific_kata.rb
codewars_api-0.4.0 lib/codewars_api/train_specific_kata.rb