Class: Inbox::Thread

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

Instance Attribute Summary collapse

Attributes inherited from RestfulModel

#created_at, #id, #namespace_id

Instance Method Summary collapse

Methods inherited from RestfulModel

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

Constructor Details

This class inherits a constructor from Inbox::RestfulModel

Instance Attribute Details

#draft_idsObject

Returns the value of attribute draft_ids.



13
14
15
# File 'lib/thread.rb', line 13

def draft_ids
  @draft_ids
end

#first_message_timestampObject

Returns the value of attribute first_message_timestamp.



9
10
11
# File 'lib/thread.rb', line 9

def first_message_timestamp
  @first_message_timestamp
end

#last_message_timestampObject

Returns the value of attribute last_message_timestamp.



8
9
10
# File 'lib/thread.rb', line 8

def last_message_timestamp
  @last_message_timestamp
end

#message_idsObject

Returns the value of attribute message_ids.



12
13
14
# File 'lib/thread.rb', line 12

def message_ids
  @message_ids
end

#participantsObject

Returns the value of attribute participants.



7
8
9
# File 'lib/thread.rb', line 7

def participants
  @participants
end

#snippetObject

Returns the value of attribute snippet.



10
11
12
# File 'lib/thread.rb', line 10

def snippet
  @snippet
end

#subjectObject

Returns the value of attribute subject.



6
7
8
# File 'lib/thread.rb', line 6

def subject
  @subject
end

#tagsObject

Returns the value of attribute tags.



11
12
13
# File 'lib/thread.rb', line 11

def tags
  @tags
end

Instance Method Details

#archive!Object



38
39
40
# File 'lib/thread.rb', line 38

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

#draftsObject



19
20
21
# File 'lib/thread.rb', line 19

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

#mark_as_read!Object



30
31
32
# File 'lib/thread.rb', line 30

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

#mark_as_seen!Object



34
35
36
# File 'lib/thread.rb', line 34

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

#messagesObject



15
16
17
# File 'lib/thread.rb', line 15

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

#star!Object



46
47
48
# File 'lib/thread.rb', line 46

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

#unarchive!Object



42
43
44
# File 'lib/thread.rb', line 42

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

#unstar!Object



50
51
52
# File 'lib/thread.rb', line 50

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

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



23
24
25
26
27
28
# File 'lib/thread.rb', line 23

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