Sha256: 0cb8d121c8c7d6285d1977c9c1273418926664ec831bd4e27aaf1d7a134e7e52

Contents?: true

Size: 540 Bytes

Versions: 12

Compression:

Stored size: 540 Bytes

Contents

class FlixCloud::Response

  attr_accessor :code, :body, :errors, :body_as_hash

  def initialize(response)
    self.code = response.code
    self.body = response.to_s
    self.body_as_hash = Crack::XML.parse(response.to_s)
    self.errors = []
    process_response_xml
  end

  def success?
    201 == code.to_i
  end


protected

  def process_response_xml
    if body_as_hash['errors'] && body_as_hash['errors'].is_a?(Hash) && body_as_hash['errors']['error']
      self.errors = Array(body_as_hash['errors']['error'])
    end
  end

end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
flixcloud-flix_cloud-gem-0.5.3 lib/flix_cloud/response.rb
flixcloud-flix_cloud-gem-0.5.4 lib/flix_cloud/response.rb
flixcloud-flix_cloud-gem-0.5.5 lib/flix_cloud/response.rb
spob-flix_cloud-gem-0.5.3 lib/flix_cloud/response.rb
spob-flix_cloud-gem-0.5.4 lib/flix_cloud/response.rb
zencoder-flix_cloud-gem-0.5.0 lib/flix_cloud/response.rb
zencoder-flix_cloud-gem-0.5.1 lib/flix_cloud/response.rb
zencoder-flix_cloud-gem-0.5.2 lib/flix_cloud/response.rb
zencoder-flix_cloud-gem-0.5.3 lib/flix_cloud/response.rb
spob-flix_cloud-gem-0.6.2 lib/flix_cloud/response.rb
spob-flix_cloud-gem-0.6.1 lib/flix_cloud/response.rb
spob-flix_cloud-gem-0.6 lib/flix_cloud/response.rb