Class: Inbox::Thread

Inherits:
RestfulModel show all
Extended by:
TimeAttrAccessor
Defined in:
lib/thread.rb

Instance Method Summary collapse

Methods included from TimeAttrAccessor

time_attr_accessor

Methods inherited from RestfulModel

#==, #as_json, collection_name, #destroy, #inflate, #initialize, #save!, #update, #url

Methods included from Parameters

included, #parameters

Constructor Details

This class inherits a constructor from Inbox::RestfulModel

Instance Method Details

#archive!Object



40
41
42
# File 'lib/thread.rb', line 40

def archive!
  update_tags!(['archive'], ['inbox'])
end

#draftsObject



21
22
23
# File 'lib/thread.rb', line 21

def drafts
  @drafts ||= RestfulModelCollection.new(Draft, @_api, @namespace_id, {:thread_id=>@id})
end

#mark_as_read!Object



32
33
34
# File 'lib/thread.rb', line 32

def mark_as_read!
  update_tags!([], ['unread'])
end

#mark_as_seen!Object



36
37
38
# File 'lib/thread.rb', line 36

def mark_as_seen!
  update_tags!([], ['unseen'])
end

#messagesObject



17
18
19
# File 'lib/thread.rb', line 17

def messages
  @messages ||= RestfulModelCollection.new(Message, @_api, @namespace_id, {:thread_id=>@id})
end

#star!Object



48
49
50
# File 'lib/thread.rb', line 48

def star!
  update_tags!(['starred'], [''])
end

#unarchive!Object



44
45
46
# File 'lib/thread.rb', line 44

def unarchive!
  update_tags!(['inbox'], ['archive'])
end

#unstar!Object



52
53
54
# File 'lib/thread.rb', line 52

def unstar!
  update_tags!([], ['starred'])
end

#update_tags!(tags_to_add = [], tags_to_remove = []) ⇒ Object



25
26
27
28
29
30
# File 'lib/thread.rb', line 25

def update_tags!(tags_to_add = [], tags_to_remove = [])
  update('PUT', '', {
    :add_tags => tags_to_add,
    :remove_tags => tags_to_remove
  })
end