Sha256: ddf8cfd9b93558399b268b88e8172493b492f582ae415399707f4facf5daa678

Contents?: true

Size: 920 Bytes

Versions: 25

Compression:

Stored size: 920 Bytes

Contents

require 'restful_model'
require 'file'
require 'rfc2882'

module Inbox
  class Message < RestfulModel

    parameter :subject
    parameter :snippet
    parameter :from
    parameter :to
    parameter :cc
    parameter :bcc
    parameter :date
    parameter :thread_id
    parameter :body
    parameter :unread

    def inflate(json)
      super
      @to ||= []
      @cc ||= []
      @bcc ||= []
    end

    def files
      @files ||= RestfulModelCollection.new(File, @_api, @namespace_id, {:message_id=>@id})
    end

    def raw
      model = nil
      collection = RestfulModelCollection.new(Message, @_api, @namespace_id, {:message_id=>@id})
      RestClient.get("#{collection.url}/#{id}/rfc2822"){ |response,request,result|
        json = Inbox.interpret_response(result, response, {:expected_class => Object})
        model = Rfc2822.new(@_api)
        model.inflate(json)
      }
      model
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
inbox-0.15.4 lib/message.rb
inbox-0.15.3 lib/message.rb
inbox-0.15.2 lib/message.rb
inbox-0.15.1 lib/message.rb
inbox-0.15.0 lib/message.rb