node-gmail-api
Advanced tools
Comparing version 0.1.1 to 0.2.0
32
index.js
@@ -15,11 +15,4 @@ var request = require('request') | ||
/* | ||
* Fetches email that matches the query. Returns a stream of messages with a max of 100 messages | ||
* since the batch api sets a limit of 100. | ||
* | ||
* e.g. to search an inbox: gmail.messages('label:inbox') | ||
*/ | ||
Gmail.prototype.messages = function (q, opts) { | ||
var key = this.key | ||
, result = new Parser({objectMode: true}) | ||
var retrieve = function (key, q, endpoint, opts) { | ||
var result = new Parser({objectMode: true}) | ||
, combined = ss() | ||
@@ -29,3 +22,3 @@ , opts = opts || {} | ||
request({ | ||
url: api + '/gmail/v1/users/me/messages', | ||
url: api + '/gmail/v1/users/me/' + endpoint, | ||
json: true, | ||
@@ -47,6 +40,6 @@ qs: { | ||
var messages = body.messages.map(function (m) { | ||
var messages = body[endpoint].map(function (m) { | ||
return { | ||
'Content-Type': 'application/http', | ||
body: 'GET ' + api + '/gmail/v1/users/me/messages/' + m.id + '\n' | ||
body: 'GET ' + api + '/gmail/v1/users/me/' + endpoint + '/' + m.id + '\n' | ||
} | ||
@@ -73,2 +66,3 @@ }) | ||
r.on('response', function (res) { | ||
res.pipe(process.stdout) | ||
var type = res.headers['content-type'] | ||
@@ -92,2 +86,16 @@ , form = new multiparty.Form | ||
/* | ||
* Fetches email that matches the query. Returns a stream of messages with a max of 100 messages | ||
* since the batch api sets a limit of 100. | ||
* | ||
* e.g. to search an inbox: gmail.messages('label:inbox') | ||
*/ | ||
Gmail.prototype.messages = function (q, opts) { | ||
return retrieve(this.key, q, 'messages', opts) | ||
} | ||
Gmail.prototype.threads = function (q, opts) { | ||
return retrieve(this.key, q, 'threads', opts) | ||
} | ||
module.exports = Gmail |
{ | ||
"name": "node-gmail-api", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Interacts with the gmail api, fetching emails", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4362
107