Sha256: fb107c5b3caf7ffb53700961644565dd7a3403f13f770bd339efacc122118a83

Contents?: true

Size: 967 Bytes

Versions: 7

Compression:

Stored size: 967 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 :file_ids
    parameter :body
    parameter :unread

    def inflate(json)
      super
      @file_ids ||= []
      @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

7 entries across 7 versions & 1 rubygems

Version Path
inbox-0.14.1 lib/message.rb
inbox-0.14.0 lib/message.rb
inbox-0.13.0 lib/message.rb
inbox-0.12.0 lib/message.rb
inbox-0.11.0 lib/message.rb
inbox-0.10.1 lib/message.rb
inbox-0.10.0 lib/message.rb