Class: Inbox::Thread
Instance Method Summary
collapse
time_attr_accessor
#==, collection_name, #destroy, #initialize, #save!, #update, #url
Methods included from Parameters
included, #parameters
Instance Method Details
#archive! ⇒ Object
62
63
64
|
# File 'lib/api_thread.rb', line 62
def archive!
update_tags!(['archive'], ['inbox'])
end
|
#as_json(options = {}) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/api_thread.rb', line 78
def as_json(options = {})
hash = {}
if not @labels.nil? and @labels != []
hash["labels"] = @labels.map do |label|
label.id
end
end
if not @folder.nil?
hash["folder"] = @folder.id
end
hash
end
|
#inflate(json) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/api_thread.rb', line 19
def inflate(json)
super
@labels ||= []
@folder ||= nil
@labels.map! do |label_json|
label = Label.new(@_api)
label.inflate(label_json)
label
end
if not folder.nil?
folder = Folder.new(@_api)
folder.inflate(@folder)
@folder = folder
end
end
|
#mark_as_read! ⇒ Object
54
55
56
|
# File 'lib/api_thread.rb', line 54
def mark_as_read!
update_tags!([], ['unread'])
end
|
#mark_as_seen! ⇒ Object
58
59
60
|
# File 'lib/api_thread.rb', line 58
def mark_as_seen!
update_tags!([], ['unseen'])
end
|
#star! ⇒ Object
70
71
72
|
# File 'lib/api_thread.rb', line 70
def star!
update_tags!(['starred'], [''])
end
|
#unarchive! ⇒ Object
66
67
68
|
# File 'lib/api_thread.rb', line 66
def unarchive!
update_tags!(['inbox'], ['archive'])
end
|
#unstar! ⇒ Object
74
75
76
|
# File 'lib/api_thread.rb', line 74
def unstar!
update_tags!([], ['starred'])
end
|
47
48
49
50
51
52
|
# File 'lib/api_thread.rb', line 47
def update_tags!(tags_to_add = [], tags_to_remove = [])
update('PUT', '', {
:add_tags => tags_to_add,
:remove_tags => tags_to_remove
})
end
|