Sha256: 7d67b4dca67e62f1c98acbd2e334b51cecd4bc7262df720d3bdf6edc38f77874

Contents?: true

Size: 568 Bytes

Versions: 6

Compression:

Stored size: 568 Bytes

Contents

module Zencoder
  class Response

    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

6 entries across 6 versions & 1 rubygems

Version Path
zencoder-2.4.5 lib/zencoder/response.rb
zencoder-2.4.4 lib/zencoder/response.rb
zencoder-2.4.3 lib/zencoder/response.rb
zencoder-2.4.2 lib/zencoder/response.rb
zencoder-2.4.1 lib/zencoder/response.rb
zencoder-2.4.0 lib/zencoder/response.rb