Sha256: 4829f0463b078060779b88d0534dd67da21144ca8d51273865bf2163ae05381e

Contents?: true

Size: 641 Bytes

Versions: 2

Compression:

Stored size: 641 Bytes

Contents

require File.expand_path("exceptions", File.dirname(__FILE__))
require 'rest-client'
require 'json'
require 'delegate'

module Heracles
  module Wrapper
    class RequestSuccess < DelegateClass(RestClient::Response)
      attr_reader(
        :job_id,
        :location,
        :errors,
        :code
      )
      def initialize(http_response)
        super(http_response)
        @json = JSON.parse(http_response.body)
        @job_id = @json.fetch('job').fetch('id').to_i
        @errors = @json.fetch('errors',{})
        @location = http_response.headers.fetch(:location)
        @code = http_response.code
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
heracles-wrapper-0.0.3 lib/heracles-wrapper/request_success.rb
heracles-wrapper-0.0.2 lib/heracles-wrapper/request_success.rb