google-gmail-api 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5271fb04d9d1d496994aa096af6b033f06ed29c157db01441921d50fe433be89
4
+ data.tar.gz: a039e599e1dc82fc7d9d044ac57b98691a9f0c4f0403e021d32050237cd0e0d8
5
+ SHA512:
6
+ metadata.gz: b48b8df28b423f417d705c158bf9a00651cce1e649bcdefe2d5fdff9e95ec9477bd0bfc290a34d99470a988b244ec5b665e8d5e5203d4fd9ca32621e67709fef
7
+ data.tar.gz: 82cb5fd88de580b9b426da9e13f4846dada607d946efde3c9ac89f00096a77f3189bffa98d9ff929c2f5def915336aec83550068eba81b60dcafe226af91d436
@@ -0,0 +1 @@
1
+ --- {}
@@ -0,0 +1,32 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## rubymine
17
+ .idea
18
+
19
+ ## PROJECT::GENERAL
20
+ coverage
21
+ rdoc
22
+ pkg
23
+ Gemfile.lock
24
+
25
+ ## Gem build
26
+ *.gem
27
+
28
+ ## PROJECT::SPECIFIC
29
+ *.rdb
30
+
31
+ ## Test Account details
32
+ account.yml
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.2.0
5
+ - 2.0.0
6
+ - 2.1.0
7
+ - 2.1.2
@@ -0,0 +1,40 @@
1
+ # gmail-api-ruby gem changelog
2
+ ## 0.0.1 / 2015-01
3
+
4
+ * Birthday!
5
+
6
+ ## 0.0.3 / 2015-01-15
7
+
8
+ * forward_with, reply_sender_with and reply_all_with won't trigger a deliver but will build the ready to send object
9
+
10
+ ## 0.0.4 / 2015-01-15
11
+
12
+ * No change, only gem description
13
+
14
+ ## 0.0.5 / 2015-01-15
15
+
16
+ * updated dependencies
17
+
18
+ ## 0.0.6 / 2015-01-16
19
+
20
+ * Added insert method for Message and some minor improvements
21
+
22
+ ## 0.0.7 / 2015-01-19
23
+
24
+ * Fix array empty errors for listing method
25
+
26
+ ## 0.0.8 / 2015-01-29
27
+
28
+ * minor fix
29
+
30
+ ## 0.0.9 / 2015-02-12
31
+
32
+ * minor fix
33
+
34
+ ## 0.0.10 / 2015-02-17
35
+
36
+ * Fixed email parsing in forward and reply method when contact names contain ,
37
+
38
+ ## 0.0.11 / 2015-06-22
39
+
40
+ * Forked to Carpela. Changed auth to work with Service Account
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyrignt (c) 2015 Julien Hobeika
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,294 @@
1
+ # WARNING! IT'S NOT FOR PRODUCTION. IT'S A TESTING REPO!
2
+
3
+ # Gmail for Ruby
4
+
5
+ A Ruby interface to Gmail API: Search,
6
+ read and send multipart emails, archive, mark as read/unread, delete emails,
7
+ and manage labels. Everything goes through Gmail API (and not through IMAP or SMTP protocols)
8
+
9
+ [![Gem Version](https://badge.fury.io/rb/gmail-api-ruby.svg)](http://badge.fury.io/rb/gmail-api-ruby)
10
+ [![Build Status](https://travis-ci.org/jhk753/gmail-ruby-api.svg)](https://travis-ci.org/jhk753/gmail-ruby-api)
11
+ [![Dependency Status](https://gemnasium.com/jhk753/gmail-ruby-api.svg)](https://gemnasium.com/jhk753/gmail-ruby-api)
12
+
13
+
14
+ # Notice
15
+
16
+ If for your usecase, the gem is too limited there are two solutions for you:
17
+
18
+ 1. Contribute ;)
19
+ 2. Look at [Gmail Api doc](https://developers.google.com/gmail/api/v1/reference) to:
20
+ * Do custom query by adding parameters I didn't talk about in my doc
21
+ * If for some reason I forgot to build some methods, note that you can call fully custom request via Gmail.client (Standard Google Api Client)
22
+
23
+ # To Do
24
+
25
+ * write proper error handling
26
+
27
+ ## Installation
28
+
29
+ gem install gmail-api-ruby
30
+
31
+ ## Initialization
32
+
33
+ ```ruby
34
+ Gmail.client_id = "...Your app client id..." or the email from your service account credentials
35
+ Gmail.client_secret = "...Your app Secret..." or the pem version of hte api key for service account
36
+ Gmail.refresh_token = "...the refresh token of the Gmail account you want to use..." or the account email address for service account auth
37
+ # Or for service Accounts
38
+ Gmail.auth_method = "service_account"
39
+ Gmail.client_id = "... or the email from your service account credentials..."
40
+ Gmail.client_secret = "...pem version of the api key ..."
41
+ Gmail.email_account = "...the email account you're going to use"
42
+ Gmail.auth_scopes = ['http://mail.google.com'] # an array of the permissions required.
43
+ ```
44
+
45
+ ## Usage
46
+
47
+ ```ruby
48
+ require "gmail"
49
+ ```
50
+
51
+ ### Common methods
52
+
53
+ this works for Messages, Labels, Drafts and Threads (everything)
54
+
55
+ ```ruby
56
+ Gmail::Message.all
57
+ Gmail::Message.all(maxResults: -1) #will parse everything. Use with care. Can through request timeout if used in web apps
58
+ Gmail::Message.get(message_id)
59
+ some_gmail_message.delete
60
+ ```
61
+
62
+ this will work for Messages and Threads
63
+
64
+ ```ruby
65
+ some_message.archive
66
+ some_message.unarchive
67
+ some_message.trash
68
+ some_message.untrash
69
+ some_message.star
70
+ some_message.unstar
71
+ some_message.mark_as_read
72
+ some_message.mark_as_unread
73
+
74
+ Gmail::Message.search(in: "labelId" from: "me@gmail.com", to: "you@gmail.com, theothers@gmail.com", subject: "some subject", after: "date", before: "date", has_words: "some words", has_not_words: "some text")
75
+ Gmail::Message.search("some words") #search as you would do in gmail interface
76
+
77
+ ```
78
+
79
+
80
+ ### Message
81
+
82
+ Create a Message object
83
+
84
+ ```ruby
85
+ m = Gmail::Message.new(
86
+ from: "test@test.com",
87
+ to: "hello@world.com",
88
+ subject: "this is the subject",
89
+ body: "this is a text body")
90
+ ```
91
+
92
+ If you want a multipart message
93
+
94
+ ```ruby
95
+ m = Gmail::Message.new(
96
+ from: "test@test.com",
97
+ to: "hello@world.com",
98
+ subject: "this is the subject",
99
+ text: "this is a text body",
100
+ html: "<div>this is a html body</div>",
101
+ labelIds: ["cool label", "Newsletter"] #labelIds is always array of labels
102
+ )
103
+ ```
104
+
105
+ From this you can create a Draft in Gmail
106
+
107
+ ```ruby
108
+ m.create_draft
109
+ ```
110
+
111
+ or send the Message
112
+
113
+ ```ruby
114
+ m.deliver
115
+ ```
116
+
117
+ or simply insert the message in the user mailbox
118
+
119
+ ```ruby
120
+ m.insert
121
+ ```
122
+
123
+ Notice that the Message object can use from, to, cc, bcc, threadId, labelIds, text, html, body
124
+
125
+ If you need to send Message or create draft with custom headers or set other headers.
126
+ Or if you need to create a different multipart email, you need to build the "raw" email yourself
127
+
128
+ example:
129
+
130
+ ```ruby
131
+ mail = Mail.new #this is the native ruby Mail object
132
+ #
133
+ # construct your Mail object
134
+ #
135
+ raw = Base64.urlsafe_encode64 mail.to_s
136
+ m = Gmail::Message.new(raw: raw)
137
+ ```
138
+
139
+ In that scenario, you still assign, if needed, ThreadId and labelIds as previously
140
+
141
+ ```ruby
142
+ m.threadId = "somethreadId"
143
+ m.labelIds = ["cool label"]
144
+ ```
145
+
146
+ If you want to quickly generate a reply or a forward to message
147
+
148
+ ```ruby
149
+ # this will construct everything for you, keeping the subject the thread etc as it would happen in Gmail
150
+ # reply only to the sender of Message m.
151
+ msg = m.reply_sender_with Gmail::Message.new(body: "some reply text")
152
+ # reply to all (sender, to (without yourself) and cc)
153
+ msg = m.reply_all_with Gmail::Message.new(body: "some reply text")
154
+ # forward
155
+ msg = m.forward_with Gmail::Message.new(body: "some forward text", to: "address@toforward.com")
156
+ # Note that the above will not send the resulting msg
157
+ msg.deliver #to send the constructed reply message
158
+
159
+ ```
160
+
161
+ Other stuffs that you can do with Message object
162
+
163
+ ```ruby
164
+ m.detailed #if for any reason Google did send us the full detail of on email object
165
+ m.thread #to get the associated Thread
166
+ m.inbox? #to know if email is in inbox
167
+ m.sent? #to know if email is a sent email
168
+ m.unread? #to know if email is unread
169
+ ```
170
+
171
+ Those are basics helpers feel free to add more if you want (ex: starred?, important?, etc)
172
+
173
+
174
+ ## Thread
175
+
176
+ Get a thread
177
+
178
+ ```ruby
179
+ one_thread = Gmail::Thread.get(thread_id)
180
+ ```
181
+
182
+ or
183
+
184
+ ```ruby
185
+ one_thread = one_message.thread
186
+ ```
187
+
188
+ Filter messages in Thread
189
+
190
+ ```ruby
191
+ one_thread.unread_messages
192
+ one_thread.sent_messages
193
+ ```
194
+
195
+ Expand messages in Thread
196
+
197
+ ```ruby
198
+ one_thread.detailed #this will return a thread object but with all messages detailed
199
+ one_thread.messages #this will return an array of message objects
200
+ ```
201
+
202
+ ## Draft
203
+
204
+ As we explained in Message, you create a draft with
205
+
206
+ ```ruby
207
+ d = some_message.create_draft
208
+ ```
209
+
210
+ Modify it with
211
+
212
+ ```ruby
213
+ d.message.subject = "some different subject than before"
214
+ d.save
215
+ ```
216
+
217
+ send it with
218
+
219
+ ```ruby
220
+ d.deliver
221
+ ```
222
+
223
+ ## Label
224
+
225
+ You can create a label like this:
226
+
227
+ ```ruby
228
+ l = Gmail::Label.new
229
+ l.name = "different Name"
230
+ l.messageListVisibility = "hide" #can be 'hide' or 'show'
231
+ l.labelListVisibility = "labelShowIfUnread" #can be "labelShowIfUnread", "labelShow", "labelHide"
232
+ l.save
233
+ ```
234
+
235
+ You can modify a label like this:
236
+
237
+ ```ruby
238
+ l = Gmail::Label.get("labelId")
239
+ l.name = "different Name"
240
+ l.messageListVisibility = "hide"
241
+ l.labelListVisibility = "labelShowIfUnread"
242
+ l.save
243
+ ```
244
+
245
+ You can use Labels to directly access box information
246
+
247
+ ```ruby
248
+ l.detailed #will display number of messages and number of threads if you don't see it
249
+ ```
250
+
251
+ For system labels like inbox, sent, trash, important, starred, draft, spam, unread, category_updates, category_promotions, category_social, category_personal, category_forums
252
+
253
+ ```ruby
254
+ l = Gmail::Label.inbox
255
+ ```
256
+
257
+ Access threads and messages from labels
258
+
259
+ ```ruby
260
+ l.threads
261
+ l.messages
262
+
263
+ l.unread_threads
264
+ l.unread_messages
265
+ ```
266
+
267
+ Access threads, drafts and messages with labels
268
+
269
+ ```ruby
270
+ Gmail::Message.all(labelIds: ["UNREAD", "INBOX"])
271
+ ```
272
+
273
+ ## License
274
+
275
+ Copyrignt (c) 2015 Julien Hobeika
276
+
277
+ Permission is hereby granted, free of charge, to any person obtaining
278
+ a copy of this software and associated documentation files (the
279
+ "Software"), to deal in the Software without restriction, including
280
+ without limitation the rights to use, copy, modify, merge, publish,
281
+ distribute, sublicense, and/or sell copies of the Software, and to
282
+ permit persons to whom the Software is furnished to do so, subject to
283
+ the following conditions:
284
+
285
+ The above copyright notice and this permission notice shall be
286
+ included in all copies or substantial portions of the Software.
287
+
288
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
289
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
290
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
291
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
292
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
293
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
294
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env rake
2
+
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
9
+ begin
10
+ require 'rdoc/task'
11
+ rescue LoadError
12
+ require 'rdoc/rdoc'
13
+ require 'rake/rdoctask'
14
+ RDoc::Task = Rake::RDocTask
15
+ end
16
+
17
+ RDoc::Task.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = "Gmail API for Ruby #{Gmail::VERSION}"
20
+ rdoc.rdoc_files.include('README*')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ Bundler::GemHelper.install_tasks
25
+
26
+ require 'rake/testtask'
27
+
28
+ task :default => [:test]
29
+
30
+ Rake::TestTask.new do |t|
31
+ t.pattern = './test/**/*_test.rb'
32
+ end