Sha256: f750f19bb1f87582d316e018002d31c1436c7aa71b6f6bedbd199b925917fc82

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

module CodewarsApi
  class DeferredResponse
    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)
    end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    def to_h
      @response.to_h
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codewars_api-0.1.1 lib/codewars_api/deferred_response.rb
codewars_api-0.1.0 lib/codewars_api/deferred_response.rb