Sha256: 53aac969107615a11ddeccb6a9ee3ef4d2c2bafbbf19f48a2df57f5465797251

Contents?: true

Size: 578 Bytes

Versions: 3

Compression:

Stored size: 578 Bytes

Contents

module Zencoder
  class Response

    attr_accessor :request, :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

3 entries across 3 versions & 1 rubygems

Version Path
zencoder-2.5.1 lib/zencoder/response.rb
zencoder-2.5.0 lib/zencoder/response.rb
zencoder-2.4.6 lib/zencoder/response.rb