Sha256: fe16a39685de8b77cf0366cab7082f71bfaad047dbe0921f564cca2dfe3ed2a6

Contents?: true

Size: 664 Bytes

Versions: 7

Compression:

Stored size: 664 Bytes

Contents

require 'restful_model'

module Inbox
  class File < RestfulModel

    attr_accessor :size
    attr_accessor :filename
    attr_accessor :content_type
    attr_accessor :is_embedded
    attr_accessor :message_id

    # For uploading the file
    attr_accessor :file

    def inflate(json)
      super
      content_type = json["content-type"] if json["content-type"]
    end

    def save!
      ::RestClient.post(url, {:file => @file}) do |response, request, result|
        json = Inbox.interpret_response(result, response, :expected_class => Object)
        json = json[0] if (json.class == Array)
        inflate(json)
      end
      self
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
inbox-0.7.0 lib/file.rb
inbox-0.5.0 lib/file.rb
inbox-0.4.4 lib/file.rb
inbox-0.4.3 lib/file.rb
inbox-0.4.2 lib/file.rb
inbox-0.4.1 lib/file.rb
inbox-0.4.0 lib/file.rb