diff --git a/README.md b/README.md
index cb97103..79ee635 100644
--- a/README.md
+++ b/README.md
@@ -98,18 +98,20 @@ An array of `email` objects with the following fields:
_Some senders will send you `text/html` content, the others will send you `plain/text`, and some will send you both. Make sure you are looking for the content in the right body field._
-### `check_inbox(credentials_json, token_path, subject, from, to, wait_time_sec = 30, max_wait_time_sec = 60, options = {})`
+### `check_inbox(credentials_json, token_path, options = {})`
`credentials_json`: Path to credentials JSON file.
`token_path`: Path to OAuth2 token file.
-`subject`: Subject to look for. Exact match.
-`from`: Sender email to look for. Exact match.
-`to`: Receiver's email. Exact match.
-`wait_time_sec`: Interval between inbox checks (in seconds). _Default: 30 seconds_.
-`max_wait_time_sec`: Maximum wait time (in seconds). When reached and the email was not found, the script exits. _Default: 60 seconds_.
`options`:
-* `include_body`: boolean. Set to `true` to fetch decoded email bodies. _Default: false_.
+* `from`: String. Filter on the email address of the receiver.
+* `to`: String. Filter on the email address of the sender.
+* `subject`: String. Filter on the subject of the email.
+* `include_body`: boolean. Set to `true` to fetch decoded email bodies.
+* `before`: Date. Filter messages received _after_ the specified date.
+* `after`: Date. Filter messages received _before_ the specified date.
+* `wait_time_sec`: Integer. Interval between inbox checks (in seconds). _Default: 30 seconds_.
+* `max_wait_time_sec`: Integer. Maximum wait time (in seconds). When reached and the email was not found, the script exits. _Default: 60 seconds_.
**Returns:**
An array of `email` objects with the following fields:
diff --git a/gmail-tester.js b/gmail-tester.js
index 68f7efc..81613a0 100644
--- a/gmail-tester.js
+++ b/gmail-tester.js
@@ -139,6 +139,21 @@ async function __check_inbox(credentials_json, token_path, options = {}) {
}
}
+/**
+ * Poll inbox.
+ *
+ * @param {string} credentials_json - Path to credentials json file.
+ * @param {string} token_path - Path to token json file.
+ * @param {Object} options
+ * @param {boolean} options.include_body - Set to `true` to fetch decoded email bodies.
+ * @param {boolean} options.from - Filter on the email address of the receiver.
+ * @param {boolean} options.to - Filter on the email address of the sender.
+ * @param {boolean} options.subject - Filter on the subject of the email.
+ * @param {boolean} options.before - Date. Filter messages received _after_ the specified date.
+ * @param {boolean} options.after - Date. Filter messages received _before_ the specified date.
+ * @param {boolean} options.wait_time_sec - Interval between inbox checks (in seconds). Default: 30 seconds.
+ * @param {boolean} options.max_wait_time_sec - Maximum wait time (in seconds). When reached and the email was not found, the script exits. Default: 60 seconds.
+ */
async function check_inbox(
credentials_json,
token_path,
@@ -147,12 +162,13 @@ async function check_inbox(
from: undefined,
to: undefined,
wait_time_sec: 30,
- max_wait_time_sec: 30
+ max_wait_time_sec: 30,
+ include_body: false
}
) {
- if (typeof options === "string") {
+ if (typeof options !== "object") {
console.error(
- "This functionality is absolete! Please pass all filter params using options object!"
+ "This functionality is absolete! Please pass all params in options object!"
);
process.exit(1);
}
diff --git a/package.json b/package.json
index b051602..9b64f9e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "gmail-tester",
- "version": "1.1.5",
+ "version": "1.2.0",
"description": "A simple NodeJS gmail client which checks the inbox for specific message existance",
"main": "gmail-tester.js",
"scripts": {},