Class: Inbox::Message
Direct Known Subclasses
Draft
Instance Method Summary
collapse
#==, collection_name, #destroy, #initialize, #save!, #update, #url
#time_attr_accessor
Methods included from Parameters
included, #parameters
Instance Method Details
#as_json(options = {}) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/message.rb', line 45
def as_json(options = {})
hash = {}
if not @unread.nil?
hash["unread"] = @unread
end
if not @starred.nil?
hash["starred"] = @starred
end
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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/message.rb', line 22
def inflate(json)
super
@to ||= []
@cc ||= []
@bcc ||= []
@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
|
#raw ⇒ Object
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/message.rb', line 75
def raw
model = nil
collection = RestfulModelCollection.new(Message, @_api, @namespace_id, {:message_id=>@id})
RestClient.get("#{collection.url}/#{id}/rfc2822"){ |response,request,result|
json = Inbox.interpret_response(result, response, {:expected_class => Object})
model = Rfc2822.new(@_api)
model.inflate(json)
}
model
end
|