Class: Inbox::Thread

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

Instance Attribute Summary collapse

Attributes inherited from RestfulModel

#created_at, #id, #namespace

Instance Method Summary collapse

Methods inherited from RestfulModel

#==, #as_json, collection_name, #destroy, #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



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

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

#draftsObject



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

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

#inflate(json) ⇒ Object



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

def inflate(json)
  super
  message_ids = json[:messages]
  draft_ids = json[:drafts]
end

#mark_as_read!Object



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

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

#mark_as_seen!Object



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

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

#messagesObject



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

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

#star!Object



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

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

#unarchive!Object



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

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

#unstar!Object



56
57
58
# File 'lib/thread.rb', line 56

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

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



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

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