Sha256: 89737d78fbfdfc139afa6f389f332ebbb58537c408d44af5a33b89eb5f46f244

Contents?: true

Size: 578 Bytes

Versions: 9

Compression:

Stored size: 578 Bytes

Contents

class Zencoder
  class Response < Zencoder

    attr_accessor :code, :body, :raw_body, :raw_response

    def initialize(options={})
      options.each do |k, v|
        send("#{k}=", v) if respond_to?("#{k}=")
      end
    end

    def success?
      code.to_i > 199 && code.to_i < 300
    end

    def errors
      if body.is_a?(Hash)
        Array(body['errors']).compact
      else
        []
      end
    end

    def body_without_wrapper
      if body.is_a?(Hash) && body['api_response']
        body['api_response']
      else
        body
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
zencoder-2.2.2 lib/zencoder/response.rb
zencoder-2.2.1 lib/zencoder/response.rb
zencoder-2.2.0 lib/zencoder/response.rb
zencoder-2.1.15 lib/zencoder/response.rb
zencoder-2.1.14 lib/zencoder/response.rb
zencoder-2.1.13 lib/zencoder/response.rb
zencoder-2.1.12 lib/zencoder/response.rb
zencoder-2.1.11 lib/zencoder/response.rb
zencoder-2.1.10 lib/zencoder/response.rb