gmail-api-ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +7 -4
- data/lib/gmail/message.rb +10 -11
- data/lib/gmail/version.rb +1 -1
- data/test/gmail/message_test.rb +67 -15
- data/test/test_data.rb +32 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0051811d108e2510bd1218eb52ca2d427bf321a
|
4
|
+
data.tar.gz: 62bf68b06a9550d8e1b87e3ea6492e6ef0a2612f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ce55db1411521412fa73213f532205f01b8614a9d42b78283777494daf34350925e0c9d81ecede8d8c9c47f20e8dc4ec3807a4a38e8f6c9976b47f582e00ee0
|
7
|
+
data.tar.gz: d070572c372a8c960866ac9de2f9cba34e465db2c51ba8f6fae3f28001e05b7b34d9d5917971a761df4dcf51792a85c70b636245a28a62ddff404fbfbb4f9343
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -127,13 +127,16 @@ In that scenario, you still assign, if needed, ThreadId and labelIds as previous
|
|
127
127
|
If you want to quickly generate a reply or a forward to message
|
128
128
|
|
129
129
|
```ruby
|
130
|
-
# this will
|
130
|
+
# this will construct everything for you, keeping the subject the thread etc as it would happen in Gmail
|
131
131
|
# reply only to the sender of Message m.
|
132
|
-
m.reply_sender_with Gmail::Message.new(body: "some reply text")
|
132
|
+
msg = m.reply_sender_with Gmail::Message.new(body: "some reply text")
|
133
133
|
# reply to all (sender, to (without yourself) and cc)
|
134
|
-
m.reply_all_with Gmail::Message.new(body: "some reply text")
|
134
|
+
msg = m.reply_all_with Gmail::Message.new(body: "some reply text")
|
135
135
|
# forward
|
136
|
-
m.forward_with Gmail::Message.new(body: "some forward text", to: "address@toforward.com")
|
136
|
+
msg = m.forward_with Gmail::Message.new(body: "some forward text", to: "address@toforward.com")
|
137
|
+
# Note that the above will not send the resulting msg
|
138
|
+
msg.deliver #to send the constructed reply message
|
139
|
+
|
137
140
|
```
|
138
141
|
|
139
142
|
Other stuffs that you can do with Message object
|
data/lib/gmail/message.rb
CHANGED
@@ -31,14 +31,14 @@ module Gmail
|
|
31
31
|
def reply_all_with msg
|
32
32
|
msg = set_headers_for_reply msg
|
33
33
|
msg = quote_in msg
|
34
|
-
msg
|
34
|
+
msg
|
35
35
|
end
|
36
36
|
|
37
37
|
def reply_sender_with msg
|
38
38
|
msg = set_headers_for_reply msg
|
39
39
|
msg = quote_in msg
|
40
40
|
msg.cc = nil
|
41
|
-
msg
|
41
|
+
msg
|
42
42
|
end
|
43
43
|
|
44
44
|
def forward_with msg
|
@@ -56,8 +56,7 @@ module Gmail
|
|
56
56
|
msg.to = x_to
|
57
57
|
msg.bcc = x_bcc
|
58
58
|
msg.subject = x_subject
|
59
|
-
|
60
|
-
msg.deliver
|
59
|
+
msg
|
61
60
|
end
|
62
61
|
|
63
62
|
|
@@ -127,30 +126,30 @@ module Gmail
|
|
127
126
|
|
128
127
|
def set_headers_for_reply msg
|
129
128
|
to_ar = []
|
129
|
+
split_regexp = Regexp.new "\s*,\s*"
|
130
130
|
if delivered_to
|
131
|
-
to_ar = to.split(
|
131
|
+
to_ar = to.split(split_regexp)
|
132
132
|
result = to_ar.grep(Regexp.new delivered_to)
|
133
133
|
if result
|
134
|
-
to_ar
|
134
|
+
to_ar = to_ar - result
|
135
135
|
end
|
136
136
|
end
|
137
|
-
|
138
137
|
msg.subject = subject
|
139
138
|
msg.to = from
|
140
139
|
if cc.nil?
|
141
140
|
msg.cc = to_ar.join(", ")
|
142
141
|
else
|
143
|
-
msg.cc = to_ar.join(", ")
|
142
|
+
msg.cc = (to_ar + cc.split(split_regexp)).join(", ")
|
144
143
|
end
|
145
144
|
msg.bcc = nil
|
146
145
|
msg.threadId = thread_id
|
147
|
-
msg.references = (references || "") + " "
|
148
|
-
msg.in_reply_to = (in_reply_to || "") + " "
|
146
|
+
msg.references = ((references || "").split(Regexp.new "\s+") << message_id).join(" ")
|
147
|
+
msg.in_reply_to = ((in_reply_to || "").split(Regexp.new "\s+") << message_id).join(" ")
|
149
148
|
msg
|
150
149
|
end
|
151
150
|
|
152
151
|
def quote_in reply_msg
|
153
|
-
text_to_append = "\n\n#{date} #{from}:\n\n>" + (body || text).gsub("\n", "\n>") unless body.nil? && text.nil?
|
152
|
+
text_to_append = "\r\n\r\n#{date} #{from}:\r\n\r\n>" + (body || text).gsub("\n", "\n>") unless body.nil? && text.nil?
|
154
153
|
html_to_append = "\r\n<br><br><div class=\"gmail_quote\"> #{date} #{CGI.escapeHTML(from)}:<br><blockquote class=\"gmail_quote\" style=\"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex\">" + html + "</blockquote></div><br>" unless html.nil?
|
155
154
|
reply_msg.html = "<div>" + reply_msg.html + "</div>" + html_to_append unless reply_msg.html.nil?
|
156
155
|
reply_msg.text = reply_msg.text + text_to_append unless reply_msg.text.nil?
|
data/lib/gmail/version.rb
CHANGED
data/test/gmail/message_test.rb
CHANGED
@@ -231,35 +231,87 @@ module Gmail
|
|
231
231
|
end
|
232
232
|
|
233
233
|
|
234
|
-
should "Reply to sender should be easy" do
|
234
|
+
should "Reply to sender contruct should be easy" do
|
235
235
|
m = Gmail::Message.new test_to_reply_message
|
236
236
|
reply_message = Gmail::Message.new test_reply_message
|
237
|
-
@mock.expects(:execute).
|
238
|
-
|
239
|
-
|
237
|
+
@mock.expects(:execute).never
|
238
|
+
expected_msg = Gmail::Message.new test_replied_message
|
240
239
|
new_m = m.reply_sender_with reply_message
|
241
|
-
|
240
|
+
|
241
|
+
assert_equal expected_msg.to, new_m.to
|
242
|
+
assert_nil new_m.cc
|
243
|
+
assert_nil new_m.bcc
|
244
|
+
assert_equal expected_msg.subject, new_m.subject
|
245
|
+
assert_equal expected_msg.references, new_m.references
|
246
|
+
assert_equal expected_msg.in_reply_to, new_m.in_reply_to
|
247
|
+
assert_equal expected_msg.thread_id, new_m.thread_id
|
248
|
+
assert_equal expected_msg.body, new_m.body
|
249
|
+
assert_nil new_m.html
|
250
|
+
assert_nil new_m.text
|
251
|
+
|
252
|
+
new_m = m.reply_sender_with(Gmail::Message.new test_reply_message_with_html)
|
253
|
+
expected_msg = Gmail::Message.new(test_replied_message_with_html)
|
254
|
+
|
255
|
+
assert_equal expected_msg.text, new_m.text
|
256
|
+
assert_equal expected_msg.html, new_m.html
|
257
|
+
assert_nil new_m.body
|
242
258
|
|
243
259
|
end
|
244
260
|
|
245
|
-
should "Reply to all should be easy" do
|
261
|
+
should "Reply to all construct should be easy" do
|
246
262
|
m = Gmail::Message.new test_to_reply_message
|
247
263
|
reply_message = Gmail::Message.new test_reply_message
|
248
|
-
@mock.expects(:execute).
|
249
|
-
@mock.expects(:execute).with(api_method: Gmail.service.users.messages.get, parameters: {userId: "me", id: test_replied_message[:id]}, headers: {'Content-Type' => 'application/json'}).once.returns(test_response(test_replied_message))
|
250
|
-
|
264
|
+
@mock.expects(:execute).never
|
251
265
|
new_m = m.reply_all_with reply_message
|
252
|
-
|
266
|
+
expected_msg = Gmail::Message.new test_replied_message
|
267
|
+
|
268
|
+
assert_equal expected_msg.to, new_m.to
|
269
|
+
assert_equal expected_msg.cc, new_m.cc
|
270
|
+
assert_nil new_m.bcc
|
271
|
+
assert_equal expected_msg.subject, new_m.subject
|
272
|
+
assert_equal expected_msg.references, new_m.references
|
273
|
+
assert_equal expected_msg.in_reply_to, new_m.in_reply_to
|
274
|
+
assert_equal expected_msg.thread_id, new_m.thread_id
|
275
|
+
assert_equal expected_msg.body, new_m.body
|
276
|
+
assert_nil new_m.html
|
277
|
+
assert_nil new_m.text
|
278
|
+
|
279
|
+
new_m = m.reply_all_with(Gmail::Message.new test_reply_message_with_html)
|
280
|
+
expected_msg = Gmail::Message.new(test_replied_message_with_html)
|
281
|
+
|
282
|
+
assert_equal expected_msg.text, new_m.text
|
283
|
+
assert_equal expected_msg.html, new_m.html
|
284
|
+
assert_nil new_m.body
|
285
|
+
|
286
|
+
|
253
287
|
end
|
254
288
|
|
255
|
-
should "forward should be easy" do
|
289
|
+
should "forward construct should be easy" do
|
256
290
|
m = Gmail::Message.new test_to_reply_message
|
257
|
-
forward_message = Gmail::Message.new
|
258
|
-
@mock.expects(:execute).
|
259
|
-
@mock.expects(:execute).with(api_method: Gmail.service.users.messages.get, parameters: {userId: "me", id: test_replied_message[:id]}, headers: {'Content-Type' => 'application/json'}).once.returns(test_response(test_replied_message))
|
260
|
-
|
291
|
+
forward_message = Gmail::Message.new(test_forward_message)
|
292
|
+
@mock.expects(:execute).never
|
261
293
|
new_m = m.forward_with forward_message
|
294
|
+
expected_msg = Gmail::Message.new test_forwarded_message
|
262
295
|
# to be completed to be fully tested
|
296
|
+
|
297
|
+
assert_equal expected_msg.to, new_m.to
|
298
|
+
assert_equal expected_msg.cc, new_m.cc
|
299
|
+
assert_nil new_m.bcc
|
300
|
+
assert_equal expected_msg.subject, new_m.subject
|
301
|
+
assert_equal expected_msg.references, new_m.references
|
302
|
+
assert_equal expected_msg.in_reply_to, new_m.in_reply_to
|
303
|
+
assert_equal expected_msg.thread_id, new_m.thread_id
|
304
|
+
assert_equal expected_msg.body, new_m.body
|
305
|
+
assert_nil new_m.html
|
306
|
+
assert_nil new_m.text
|
307
|
+
|
308
|
+
forward_message = Gmail::Message.new({to: "test@test.com", bbc: "coucou", cc: "test@couocu.com, second@second.com", subject: "cool subject", html: "<b>test</b>", text: "test"})
|
309
|
+
new_m = m.forward_with forward_message
|
310
|
+
expected_msg = Gmail::Message.new test_forwarded_message_with_html
|
311
|
+
|
312
|
+
assert_equal expected_msg.text, new_m.text
|
313
|
+
assert_equal expected_msg.html, new_m.html
|
314
|
+
assert_nil new_m.body
|
263
315
|
end
|
264
316
|
|
265
317
|
end
|
data/test/test_data.rb
CHANGED
@@ -150,20 +150,48 @@ module Gmail
|
|
150
150
|
{body: "test"}
|
151
151
|
end
|
152
152
|
|
153
|
+
def test_forward_message
|
154
|
+
{to: "julien@wepopp.com", bbc: "julien.hobeika@gmail.com", cc: "julien@juliedesk.com, nicolas@juliedesk.com", subject: "cool subject", body: "test"}
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_forward_message_with_html
|
158
|
+
{to: "julien@wepopp.com", bbc: "julien.hobeika@gmail.com", cc: "julien@juliedesk.com, nicolas@juliedesk.com", subject: "cool subject", text: "test", html: "<b>test</b>"}
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_forwarded_message
|
162
|
+
{:id=>"14aef32bd53a74bb", :threadId=>"14aecf708ee65122", :labelIds=>["SENT"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"234207", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 12:04:47 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 12:04:47 -0800"}, {:name=>"To", :value=>"julien@wepopp.com"}, {:name=>"Cc", :value=>"julien@juliedesk.com, nicolas@juliedesk.com"}, {:name=>"Message-Id", :value=>"<CAFXNVWTyUTRoC-yqHd0zmaAF8heyWAO3Hskfv_uxESWwgtX9Mg@mail.gmail.com>"}, {:name=>"In-Reply-To", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"References", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"Subject", :value=>"cool subject"}, {:name=>"Mime-Version", :value=>"1.0"}, {:name=>"Content-Type", :value=>"text/plain; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}, {:name=>"From", :value=>"julie@juliedesk.com"}], :body=>{:size=>238, :data=>"dGVzdA0KDQpUaHUsIDE1IEphbiAyMDE1IDEwOjM5OjU5ICswMTAwIEp1bGllbiBIb2JlaWthIDxqdWxpZW5AanVsaWVkZXNrLmNvbT46DQoNCj5jb3Vjb3UNCj4NCj4NCj4qSnVsaWVuIEhvYmVpa2EgfCBDby1Gb3VuZGVyICYgQ0VPKkVtYWlsOiBqdWxpZW5AanVsaWVkZXNrLmNvbQ0KPlRlbDogKzMzIDYgNjMgMzMgMTcgNTUNCj4NCj4qSnVsaWUgRGVzayoNCj53d3cuanVsaWVkZXNrLmNvbQ0KPg0KPg0KPuGQpw0KPg=="}}, :sizeEstimate=>948}
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
def test_forwarded_message_with_html
|
167
|
+
{:id=>"14aef33bfcd19656", :threadId=>"14aecf708ee65122", :labelIds=>["SENT"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: coucou Julien", :historyId=>"234237", :payload=>{:mimeType=>"multipart/alternative", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 12:05:53 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 12:05:53 -0800"}, {:name=>"To", :value=>"julien@wepopp.com"}, {:name=>"Cc", :value=>"julien@juliedesk.com, nicolas@juliedesk.com"}, {:name=>"Message-Id", :value=>"<CAFXNVWR8k5sc39WbqyUoEA-ssYRtx0RALtNUkdDL1M9g6w3dEA@mail.gmail.com>"}, {:name=>"In-Reply-To", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"References", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"Subject", :value=>"cool subject"}, {:name=>"Mime-Version", :value=>"1.0"}, {:name=>"Content-Type", :value=>"multipart/alternative; boundary=\"--==_mimepart_54b81da0a179_d3733fe0444541d8958c\"; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"7bit"}, {:name=>"From", :value=>"julie@juliedesk.com"}], :body=>{:size=>0}, :parts=>[{:partId=>"0", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Content-Type", :value=>"text/plain; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}], :body=>{:size=>238, :data=>"dGVzdA0KDQpUaHUsIDE1IEphbiAyMDE1IDEwOjM5OjU5ICswMTAwIEp1bGllbiBIb2JlaWthIDxqdWxpZW5AanVsaWVkZXNrLmNvbT46DQoNCj5jb3Vjb3UNCj4NCj4NCj4qSnVsaWVuIEhvYmVpa2EgfCBDby1Gb3VuZGVyICYgQ0VPKkVtYWlsOiBqdWxpZW5AanVsaWVkZXNrLmNvbQ0KPlRlbDogKzMzIDYgNjMgMzMgMTcgNTUNCj4NCj4qSnVsaWUgRGVzayoNCj53d3cuanVsaWVkZXNrLmNvbQ0KPg0KPg0KPuGQpw0KPg=="}}, {:partId=>"1", :mimeType=>"text/html", :filename=>"", :headers=>[{:name=>"Content-Type", :value=>"text/html; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}], :body=>{:size=>1005, :data=>"PGRpdj48Yj50ZXN0PC9iPjwvZGl2Pg0KPGJyPjxicj48ZGl2IGNsYXNzPSJnbWFpbF9xdW90ZSI-IFRodSwgMTUgSmFuIDIwMTUgMTA6Mzk6NTkgKzAxMDAgSnVsaWVuIEhvYmVpa2EgJmx0O2p1bGllbkBqdWxpZWRlc2suY29tJmd0Ozo8YnI-PGJsb2NrcXVvdGUgY2xhc3M9ImdtYWlsX3F1b3RlIiBzdHlsZT0ibWFyZ2luOjAgMCAwIC44ZXg7Ym9yZGVyLWxlZnQ6MXB4ICNjY2Mgc29saWQ7cGFkZGluZy1sZWZ0OjFleCI-PGRpdiBkaXI9Imx0ciI-Y291Y291PGJyIGNsZWFyPSJhbGwiPjxkaXY-PGRpdiBjbGFzcz0iZ21haWxfc2lnbmF0dXJlIj48ZGl2IGRpcj0ibHRyIj48cD48Yj5KdWxpZW4gSG9iZWlrYSB8IENvLUZvdW5kZXIgJmFtcDsgQ0VPPGJyPjwvYj5FbWFpbDrCoDxhIGhyZWY9Im1haWx0bzpqdWxpZW5AanVsaWVkZXNrLmNvbSIgdGFyZ2V0PSJfYmxhbmsiPmp1bGllbkBqdWxpZWRlc2suY29tPC9hPjxicj5UZWw6ICszMyA2IDYzIDMzIDE3IDU1PC9wPjxwPjxiPkp1bGllIERlc2s8L2I-PGI-PGJyPjwvYj48YSBocmVmPSJodHRwOi8vd3d3Lmp1bGllZGVzay5jb20vIiBzdHlsZT0iY29sb3I6cmdiKDE3LDg1LDIwNCk7Zm9udC1mYW1pbHk6SGVsdmV0aWNhIiB0YXJnZXQ9Il9ibGFuayI-d3d3Lmp1bGllZGVzay5jb208L2E-PGI-PGJyPjwvYj48L3A-PHA-PGJyPjwvcD48L2Rpdj48L2Rpdj48L2Rpdj4NCjxkaXYgaHNwYWNlPSJzdHJlYWstcHQtbWFyayIgc3R5bGU9Im1heC1oZWlnaHQ6MXB4Ij48aW1nIHN0eWxlPSJ3aWR0aDowcHg7IG1heC1oZWlnaHQ6MHB4OyIgc3JjPSJodHRwczovL21haWxmb29nYWUuYXBwc3BvdC5jb20vdD9zZW5kZXI9YWFuVnNhV1Z1UUhkbGNHOXdjQzVqYjIwJTNEJmFtcDt0eXBlPXplcm9jb250ZW50JmFtcDtndWlkPTBiMWRiODRkLTFmMTctNDE1MS05ZmE5LTUxMWNiYTg0ODAyMiI-PGZvbnQgY29sb3I9IiNmZmZmZmYiIHNpemU9IjEiPuGQpzwvZm9udD48L2Rpdj48L2Rpdj4NCjwvYmxvY2txdW90ZT48L2Rpdj48YnI-"}}]}, :sizeEstimate=>2448}
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_reply_message_with_html(params = {})
|
171
|
+
{html: "<b>test</b>", text: "test"}
|
172
|
+
end
|
173
|
+
|
153
174
|
def test_replied_message(params = {})
|
154
|
-
{:id=>"14aecf9e31d945ba", :threadId=>"14aecf708ee65122", :labelIds=>["SENT", "INBOX", "UNREAD"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"232799", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"
|
175
|
+
{:id=>"14aecf9e31d945ba", :threadId=>"14aecf708ee65122", :labelIds=>["SENT", "INBOX", "UNREAD"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"232799", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"Julien Hobeika <julien.hobeika@gmail.com>, Julien Hobeika <julien@juliedesk.com>, Nicolas Marlier <nicolas@wepopp.com>"}, {:name=>"Message-Id", :value=>"<CAFXNVWSqyaY6Qp7s6iTm9GwTVpCxgTxSCaa3UMU8rpNzZc+-Uw@mail.gmail.com>"}, {:name=>"In-Reply-To", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"References", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"Subject", :value=>"test reply message"}, {:name=>"Mime-Version", :value=>"1.0"}, {:name=>"Content-Type", :value=>"text/plain; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}, {:name=>"From", :value=>"julie@juliedesk.com"}], :body=>{:size=>238, :data=>"dGVzdA0KDQpUaHUsIDE1IEphbiAyMDE1IDEwOjM5OjU5ICswMTAwIEp1bGllbiBIb2JlaWthIDxqdWxpZW5AanVsaWVkZXNrLmNvbT46DQoNCj5jb3Vjb3UNCj4NCj4NCj4qSnVsaWVuIEhvYmVpa2EgfCBDby1Gb3VuZGVyICYgQ0VPKkVtYWlsOiBqdWxpZW5AanVsaWVkZXNrLmNvbQ0KPlRlbDogKzMzIDYgNjMgMzMgMTcgNTUNCj4NCj4qSnVsaWUgRGVzayoNCj53d3cuanVsaWVkZXNrLmNvbQ0KPg0KPg0KPuGQpw0KPg=="}}, :sizeEstimate=>1089}
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
def test_replied_message_with_html(params = {})
|
180
|
+
{:id=>"14aef0d08d39b4df", :threadId=>"14aecf708ee65122", :labelIds=>["SENT", "INBOX", "UNREAD"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: coucou Julien", :historyId=>"234054", :payload=>{:mimeType=>"multipart/alternative", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 11:23:36 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 11:23:36 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"Julien Hobeika <julien.hobeika@gmail.com>, Julien Hobeika <julien@juliedesk.com>, Nicolas Marlier <nicolas@wepopp.com>"}, {:name=>"Message-Id", :value=>"<CAFXNVWQO=9Z5LaNgSUQTEA4ucDw4LA5BbA-Qv6RpcLq0kOKM6A@mail.gmail.com>"}, {:name=>"In-Reply-To", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"References", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"Subject", :value=>"test reply message"}, {:name=>"Mime-Version", :value=>"1.0"}, {:name=>"Content-Type", :value=>"multipart/alternative; boundary=\"--==_mimepart_54b813b749eaa_d0963fc7bc45c1d0581fa\"; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"7bit"}, {:name=>"From", :value=>"julie@juliedesk.com"}], :body=>{:size=>0}, :parts=>[{:partId=>"0", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Content-Type", :value=>"text/plain; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}], :body=>{:size=>238, :data=>"dGVzdA0KDQpUaHUsIDE1IEphbiAyMDE1IDEwOjM5OjU5ICswMTAwIEp1bGllbiBIb2JlaWthIDxqdWxpZW5AanVsaWVkZXNrLmNvbT46DQoNCj5jb3Vjb3UNCj4NCj4NCj4qSnVsaWVuIEhvYmVpa2EgfCBDby1Gb3VuZGVyICYgQ0VPKkVtYWlsOiBqdWxpZW5AanVsaWVkZXNrLmNvbQ0KPlRlbDogKzMzIDYgNjMgMzMgMTcgNTUNCj4NCj4qSnVsaWUgRGVzayoNCj53d3cuanVsaWVkZXNrLmNvbQ0KPg0KPg0KPuGQpw0KPg=="}}, {:partId=>"1", :mimeType=>"text/html", :filename=>"", :headers=>[{:name=>"Content-Type", :value=>"text/html; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}], :body=>{:size=>1005, :data=>"PGRpdj48Yj50ZXN0PC9iPjwvZGl2Pg0KPGJyPjxicj48ZGl2IGNsYXNzPSJnbWFpbF9xdW90ZSI-IFRodSwgMTUgSmFuIDIwMTUgMTA6Mzk6NTkgKzAxMDAgSnVsaWVuIEhvYmVpa2EgJmx0O2p1bGllbkBqdWxpZWRlc2suY29tJmd0Ozo8YnI-PGJsb2NrcXVvdGUgY2xhc3M9ImdtYWlsX3F1b3RlIiBzdHlsZT0ibWFyZ2luOjAgMCAwIC44ZXg7Ym9yZGVyLWxlZnQ6MXB4ICNjY2Mgc29saWQ7cGFkZGluZy1sZWZ0OjFleCI-PGRpdiBkaXI9Imx0ciI-Y291Y291PGJyIGNsZWFyPSJhbGwiPjxkaXY-PGRpdiBjbGFzcz0iZ21haWxfc2lnbmF0dXJlIj48ZGl2IGRpcj0ibHRyIj48cD48Yj5KdWxpZW4gSG9iZWlrYSB8IENvLUZvdW5kZXIgJmFtcDsgQ0VPPGJyPjwvYj5FbWFpbDrCoDxhIGhyZWY9Im1haWx0bzpqdWxpZW5AanVsaWVkZXNrLmNvbSIgdGFyZ2V0PSJfYmxhbmsiPmp1bGllbkBqdWxpZWRlc2suY29tPC9hPjxicj5UZWw6ICszMyA2IDYzIDMzIDE3IDU1PC9wPjxwPjxiPkp1bGllIERlc2s8L2I-PGI-PGJyPjwvYj48YSBocmVmPSJodHRwOi8vd3d3Lmp1bGllZGVzay5jb20vIiBzdHlsZT0iY29sb3I6cmdiKDE3LDg1LDIwNCk7Zm9udC1mYW1pbHk6SGVsdmV0aWNhIiB0YXJnZXQ9Il9ibGFuayI-d3d3Lmp1bGllZGVzay5jb208L2E-PGI-PGJyPjwvYj48L3A-PHA-PGJyPjwvcD48L2Rpdj48L2Rpdj48L2Rpdj4NCjxkaXYgaHNwYWNlPSJzdHJlYWstcHQtbWFyayIgc3R5bGU9Im1heC1oZWlnaHQ6MXB4Ij48aW1nIHN0eWxlPSJ3aWR0aDowcHg7IG1heC1oZWlnaHQ6MHB4OyIgc3JjPSJodHRwczovL21haWxmb29nYWUuYXBwc3BvdC5jb20vdD9zZW5kZXI9YWFuVnNhV1Z1UUhkbGNHOXdjQzVqYjIwJTNEJmFtcDt0eXBlPXplcm9jb250ZW50JmFtcDtndWlkPTBiMWRiODRkLTFmMTctNDE1MS05ZmE5LTUxMWNiYTg0ODAyMiI-PGZvbnQgY29sb3I9IiNmZmZmZmYiIHNpemU9IjEiPuGQpzwvZm9udD48L2Rpdj48L2Rpdj4NCjwvYmxvY2txdW90ZT48L2Rpdj48YnI-"}}]}, :sizeEstimate=>2597}
|
155
181
|
end
|
156
182
|
|
183
|
+
|
184
|
+
|
157
185
|
def test_unread_message(params = {})
|
158
|
-
{:id=>"14aecf9e31d945ba", :threadId=>"14aecf708ee65122", :labelIds=>["IMPORTANT", "CATEGORY_PERSONAL","UNREAD"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"232799", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"
|
186
|
+
{:id=>"14aecf9e31d945ba", :threadId=>"14aecf708ee65122", :labelIds=>["IMPORTANT", "CATEGORY_PERSONAL","UNREAD"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"232799", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"Julien Hobeika <julien.hobeika@gmail.com>, Julien Hobeika <julien@juliedesk.com>, Nicolas Marlier <nicolas@wepopp.com>"}, {:name=>"Message-Id", :value=>"<CAFXNVWSqyaY6Qp7s6iTm9GwTVpCxgTxSCaa3UMU8rpNzZc+-Uw@mail.gmail.com>"}, {:name=>"In-Reply-To", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"References", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"Subject", :value=>"test reply message"}, {:name=>"Mime-Version", :value=>"1.0"}, {:name=>"Content-Type", :value=>"text/plain; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}, {:name=>"From", :value=>"julie@juliedesk.com"}], :body=>{:size=>238, :data=>"dGVzdA0KDQpUaHUsIDE1IEphbiAyMDE1IDEwOjM5OjU5ICswMTAwIEp1bGllbiBIb2JlaWthIDxqdWxpZW5AanVsaWVkZXNrLmNvbT46DQoNCj5jb3Vjb3UNCj4NCj4NCj4qSnVsaWVuIEhvYmVpa2EgfCBDby1Gb3VuZGVyICYgQ0VPKkVtYWlsOiBqdWxpZW5AanVsaWVkZXNrLmNvbQ0KPlRlbDogKzMzIDYgNjMgMzMgMTcgNTUNCj4NCj4qSnVsaWUgRGVzayoNCj53d3cuanVsaWVkZXNrLmNvbQ0KPg0KPg0KPuGQpw0KPg=="}}, :sizeEstimate=>1089}
|
159
187
|
end
|
160
188
|
|
161
189
|
def test_sent_message(params = {})
|
162
|
-
{:id=>"14aecf9e31d945ba", :threadId=>"14aecf708ee65122", :labelIds=>["IMPORTANT", "CATEGORY_PERSONAL","SENT"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"232799", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"
|
190
|
+
{:id=>"14aecf9e31d945ba", :threadId=>"14aecf708ee65122", :labelIds=>["IMPORTANT", "CATEGORY_PERSONAL","SENT"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"232799", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"Julien Hobeika <julien.hobeika@gmail.com>, Julien Hobeika <julien@juliedesk.com>, Nicolas Marlier <nicolas@wepopp.com>"}, {:name=>"Message-Id", :value=>"<CAFXNVWSqyaY6Qp7s6iTm9GwTVpCxgTxSCaa3UMU8rpNzZc+-Uw@mail.gmail.com>"}, {:name=>"In-Reply-To", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"References", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"Subject", :value=>"test reply message"}, {:name=>"Mime-Version", :value=>"1.0"}, {:name=>"Content-Type", :value=>"text/plain; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}, {:name=>"From", :value=>"julie@juliedesk.com"}], :body=>{:size=>238, :data=>"dGVzdA0KDQpUaHUsIDE1IEphbiAyMDE1IDEwOjM5OjU5ICswMTAwIEp1bGllbiBIb2JlaWthIDxqdWxpZW5AanVsaWVkZXNrLmNvbT46DQoNCj5jb3Vjb3UNCj4NCj4NCj4qSnVsaWVuIEhvYmVpa2EgfCBDby1Gb3VuZGVyICYgQ0VPKkVtYWlsOiBqdWxpZW5AanVsaWVkZXNrLmNvbQ0KPlRlbDogKzMzIDYgNjMgMzMgMTcgNTUNCj4NCj4qSnVsaWUgRGVzayoNCj53d3cuanVsaWVkZXNrLmNvbQ0KPg0KPg0KPuGQpw0KPg=="}}, :sizeEstimate=>1089}
|
163
191
|
end
|
164
192
|
|
165
193
|
def test_inbox_message(params = {})
|
166
|
-
{:id=>"14aecf9e31d945ba", :threadId=>"14aecf708ee65122", :labelIds=>["IMPORTANT", "CATEGORY_PERSONAL","INBOX"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"232799", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"
|
194
|
+
{:id=>"14aecf9e31d945ba", :threadId=>"14aecf708ee65122", :labelIds=>["IMPORTANT", "CATEGORY_PERSONAL","INBOX"], :snippet=>"test Thu, 15 Jan 2015 10:39:59 +0100 Julien Hobeika <julien@juliedesk.com>: >coucou >", :historyId=>"232799", :payload=>{:partId=>"", :mimeType=>"text/plain", :filename=>"", :headers=>[{:name=>"Received", :value=>"from 992877924458-i6nbjvo0fspv8hpmpss0i9aglneqrdpm.apps.googleusercontent.com named unknown by gmailapi.google.com with HTTPREST; Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"Date", :value=>"Thu, 15 Jan 2015 01:43:27 -0800"}, {:name=>"To", :value=>"Julien Hobeika <julien@juliedesk.com>"}, {:name=>"Cc", :value=>"Julien Hobeika <julien.hobeika@gmail.com>, Julien Hobeika <julien@juliedesk.com>, Nicolas Marlier <nicolas@wepopp.com>"}, {:name=>"Message-Id", :value=>"<CAFXNVWSqyaY6Qp7s6iTm9GwTVpCxgTxSCaa3UMU8rpNzZc+-Uw@mail.gmail.com>"}, {:name=>"In-Reply-To", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"References", :value=>"<CAA-2G7UbpEhf1G6-fF_ruSew7SRjsOpU+wPbmWufrknmbxQVZg@mail.gmail.com>"}, {:name=>"Subject", :value=>"test reply message"}, {:name=>"Mime-Version", :value=>"1.0"}, {:name=>"Content-Type", :value=>"text/plain; charset=UTF-8"}, {:name=>"Content-Transfer-Encoding", :value=>"quoted-printable"}, {:name=>"From", :value=>"julie@juliedesk.com"}], :body=>{:size=>238, :data=>"dGVzdA0KDQpUaHUsIDE1IEphbiAyMDE1IDEwOjM5OjU5ICswMTAwIEp1bGllbiBIb2JlaWthIDxqdWxpZW5AanVsaWVkZXNrLmNvbT46DQoNCj5jb3Vjb3UNCj4NCj4NCj4qSnVsaWVuIEhvYmVpa2EgfCBDby1Gb3VuZGVyICYgQ0VPKkVtYWlsOiBqdWxpZW5AanVsaWVkZXNrLmNvbQ0KPlRlbDogKzMzIDYgNjMgMzMgMTcgNTUNCj4NCj4qSnVsaWUgRGVzayoNCj53d3cuanVsaWVkZXNrLmNvbQ0KPg0KPg0KPuGQpw0KPg=="}}, :sizeEstimate=>1089}
|
167
195
|
end
|
168
196
|
|
169
197
|
def test_message_list
|