0.0.7 • Published 7 months ago

gmail-query-services v0.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

:mailbox_with_no_mail: gmail-query-services

lib to facilitate integration with gmail

Prerequisites

  • Node.js
  • A Google account with Gmail enabled

Turn on the Gmail API

In resulting dialog click DOWNLOAD CLIENT CONFIGURATION and save the file credentials.json to app config directory.

Installation

npm i gmail-query-services

envs

env.TOKEN_PATH => the path of the gmail token env.CREDENTIALS_PATH => the path of the gmail credentials env.TIMEOUT => timeout for Google apis to respond. (default => 5 seconds)

Importing

const { authorizer, message } = require('../src')

Authorizer

In the first time, you need run the authorizer first, to generate the token file. Run authorizer, get the uri that service return in console, put in you browser, get the code retunr by gmail. Put de code in console, press enter. Should apear a message, "Token stored to...".

That's all.

const { authorizer } = require('../src')
authorizer.exec()

Overview

Response body

If successful, the response body contains data with the same structure on the gmail documentation.

But in the Part body, we add the attachment, if the part has a attachment. The attachment structure is the same on the gmail documentation

Query functions

from
await message().from(email).exec()
subject
await message().subject(subject).exec()
hasAttachment
await message().from(email).hasAttachment().exec()

If you are looking for a file name

await message().from(email).hasAttachment('filename').exec()
after
await message().from(email).after(date).exec()
before
await message().from(email).before(date).exec()

Date Warning

All dates used in the search query are interpreted as midnight on that date in the PST timezone. To specify accurate dates for other timezones pass the value in seconds instead:

?q=in:sent after:1388552400 before:1391230800
read
await message().from(email).read().exec()
unread
await message().from(email).read(false).exec()
contains
await message().from(email).contains('hello').exec()
0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago