lib/api_thread.rb in nylas-1.2.1 vs lib/api_thread.rb in nylas-1.3.0
- old
+ new
@@ -1,23 +1,28 @@
require 'restful_model'
require 'time_attr_accessor'
+require 'mixins'
module Inbox
class Thread < RestfulModel
extend TimeAttrAccessor
parameter :subject
parameter :participants
parameter :snippet
- parameter :tags
parameter :message_ids
parameter :draft_ids
parameter :labels
parameter :folder
+ parameter :starred
+ parameter :unread
+ parameter :has_attachments
time_attr_accessor :last_message_timestamp
time_attr_accessor :first_message_timestamp
+ include ReadUnreadMethods
+
def inflate(json)
super
@labels ||= []
@folder ||= nil
@@ -40,40 +45,9 @@
@messages ||= RestfulModelCollection.new(Message, @_api, {:thread_id=>@id})
end
def drafts
@drafts ||= RestfulModelCollection.new(Draft, @_api, {:thread_id=>@id})
- end
-
- def update_tags!(tags_to_add = [], tags_to_remove = [])
- update('PUT', '', {
- :add_tags => tags_to_add,
- :remove_tags => tags_to_remove
- })
- end
-
- def mark_as_read!
- update_tags!([], ['unread'])
- end
-
- def mark_as_seen!
- update_tags!([], ['unseen'])
- end
-
- def archive!
- update_tags!(['archive'], ['inbox'])
- end
-
- def unarchive!
- update_tags!(['inbox'], ['archive'])
- end
-
- def star!
- update_tags!(['starred'], [''])
- end
-
- def unstar!
- update_tags!([], ['starred'])
end
def as_json(options = {})
hash = {}