Sha256: 0b616effae341bd5d42c225d4783755cc593ba601b1999300d07d4bead4e5bc7

Contents?: true

Size: 575 Bytes

Versions: 4

Compression:

Stored size: 575 Bytes

Contents

module Zencoder
  class Response < Base

    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

4 entries across 4 versions & 1 rubygems

Version Path
zencoder-2.3.3 lib/zencoder/response.rb
zencoder-2.3.2 lib/zencoder/response.rb
zencoder-2.3.1 lib/zencoder/response.rb
zencoder-2.3.0 lib/zencoder/response.rb