Sha256: 7e156357156cf2437123609347787e91c6215301a2a80c407c2a44bc3cebe6fd

Contents?: true

Size: 902 Bytes

Versions: 5

Compression:

Stored size: 902 Bytes

Contents

module CodewarsApi
  class Client
    attr_reader :api_key

    def initialize(options = nil)
      @api_key = options[:api_key] if options
    end

    def user(username)
      User.new(username)
    end

    def kata_info(id_or_slug)
      KataInfo.new(id_or_slug)
    end

    def train_next_kata(options)
      add_api_key(options)
      TrainNextKata.new(options)
    end

    def train_specific_kata(options)
      add_api_key(options)
      TrainSpecificKata.new(options)
    end

    def attempt_solution(options)
      add_api_key(options)
      AttemptSolution.new(options)
    end

    def finalize_solution(options)
      add_api_key(options)
      FinalizeSolution.new(options)
    end

    def deferred_response(options)
      add_api_key(options)
      DeferredResponse.new(options)
    end

    private

    def add_api_key(options)
      options[:api_key] = @api_key
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
codewars_api-0.4.2 lib/codewars_api/client.rb
codewars_api-0.4.1 lib/codewars_api/client.rb
codewars_api-0.4.0 lib/codewars_api/client.rb
codewars_api-0.3.0 lib/codewars_api/client.rb
codewars_api-0.2.1 lib/codewars_api/client.rb