Class: Gmail::Message
Instance Method Summary
collapse
included, #trash, #untrash
#archive, #archive!, #mark_as_read, #mark_as_read!, #mark_as_unread, #mark_as_unread!, #modify, #modify!, #star, #star!, #unarchive, #unarchive!, #unstar, #unstar!
Methods included from Base::Get
included
#delete, included
Methods included from Base::List
included
Methods inherited from APIResource
base_method, class_name
Methods inherited from GmailObject
#[], #[]=, #as_json, #detailed, #initialize, #inspect, #refresh, #to_hash, #to_json, #to_s, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Gmail::GmailObject
Instance Method Details
#create_draft ⇒ Object
16
17
18
|
# File 'lib/gmail/message.rb', line 16
def create_draft
Draft.create(message: msg_parameters)
end
|
#deliver ⇒ Object
26
27
28
29
|
# File 'lib/gmail/message.rb', line 26
def deliver
response = Gmail.request(self.class.base_method.to_h['gmail.users.messages.send'],{}, msg_parameters)
Message.get(response[:id])
end
|
#deliver! ⇒ Object
20
21
22
23
24
|
# File 'lib/gmail/message.rb', line 20
def deliver!
response = Gmail.request(self.class.base_method.to_h['gmail.users.messages.send'],{}, msg_parameters)
@values = Message.get(response[:id]).values
self
end
|
#forward_with(msg) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/gmail/message.rb', line 55
def forward_with msg
x_cc = msg.cc
x_to = msg.to
x_bcc = msg.bcc
x_subject = msg.subject || subject
msg = msg
msg = quote_in msg
msg.cc = x_cc
msg.to = x_to
msg.bcc = x_bcc
msg.subject = x_subject
msg
end
|
#inbox? ⇒ Boolean
87
88
89
|
# File 'lib/gmail/message.rb', line 87
def inbox?
labelIds.include?("INBOX")
end
|
#insert ⇒ Object
31
32
33
34
|
# File 'lib/gmail/message.rb', line 31
def insert
response = Gmail.request(self.class.base_method.insert,{}, msg_parameters)
Message.get(response[:id])
end
|
#insert! ⇒ Object
36
37
38
39
40
|
# File 'lib/gmail/message.rb', line 36
def insert!
response = Gmail.request(self.class.base_method.insert,{}, msg_parameters)
@values = Message.get(response[:id]).values
self
end
|
#raw ⇒ Object
is not in private because the method is used in Draft
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/gmail/message.rb', line 93
def raw
if super
super
else
s = self
msg = Mail.new
msg.subject = subject
if body
msg.body = body
end
msg.from = from
msg.to = to
msg.cc = cc
msg.['X-Bcc'] = bcc unless bcc.nil?
msg.in_reply_to = in_reply_to unless in_reply_to.nil?
msg.references = references unless references.nil?
if text
msg.text_part = Mail::Part.new do |p|
content_type 'text/plain; charset=UTF-8'
p.body s.text
end
end
if html
msg.html_part = Mail::Part.new do |p|
content_type 'text/html; charset=UTF-8'
p.body s.html
end
end
Base64.urlsafe_encode64 msg.to_s.sub("X-Bcc", "Bcc")
end
end
|
#reply_all_with(msg) ⇒ Object
42
43
44
45
46
|
# File 'lib/gmail/message.rb', line 42
def reply_all_with msg
msg = msg
msg = quote_in msg
msg
end
|
#reply_sender_with(msg) ⇒ Object
48
49
50
51
52
53
|
# File 'lib/gmail/message.rb', line 48
def reply_sender_with msg
msg = msg
msg = quote_in msg
msg.cc = nil
msg
end
|
#sent? ⇒ Boolean
83
84
85
|
# File 'lib/gmail/message.rb', line 83
def sent?
labelIds.include?("SENT")
end
|
#thread ⇒ Object
12
13
14
|
# File 'lib/gmail/message.rb', line 12
def thread
Thread.get(threadId)
end
|
#thread_id ⇒ Object
74
75
76
|
# File 'lib/gmail/message.rb', line 74
def thread_id
threadId
end
|
#unread? ⇒ Boolean
79
80
81
|
# File 'lib/gmail/message.rb', line 79
def unread?
labelIds.include?("UNREAD")
end
|