-
-
Save curtisbelt/b576da1acdaf68cceb6c5ed14aa996ad to your computer and use it in GitHub Desktop.
nylas-support-engineer-challenge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1. Retrieve `thread_id` 1ykhop6itgiao6rxyqu10a5g and share your request and the API response. | |
*/ | |
import nylas from "./index.js"; | |
const thread = await nylas.threads.find("1ykhop6itgiao6rxyqu10a5g"); | |
console.log(thread); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread { | |
connection: <ref *1> NylasConnection { | |
threads: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/threads' | |
}, | |
contacts: ContactRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/contacts' | |
}, | |
messages: MessageRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/messages' | |
}, | |
drafts: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/drafts' | |
}, | |
files: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/files' | |
}, | |
calendars: CalendarRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/calendars' | |
}, | |
jobStatuses: JobStatusRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/job-statuses' | |
}, | |
events: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/events' | |
}, | |
resources: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/resources' | |
}, | |
deltas: DeltaCollection { path: '/delta', connection: [Circular *1] }, | |
labels: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/labels' | |
}, | |
folders: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/folders' | |
}, | |
account: RestfulModelInstance { | |
modelClass: [Function], | |
connection: [Circular *1] | |
}, | |
component: ComponentRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/component' | |
}, | |
scheduler: SchedulerRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/manage/pages', | |
baseUrl: 'https://api.schedule.nylas.com' | |
}, | |
outbox: Outbox { path: '/v2/outbox', connection: [Circular *1] }, | |
neural: Neural { | |
connection: [Circular *1], | |
id: undefined, | |
accountId: undefined, | |
object: undefined | |
}, | |
accessToken: '2G92spEQ2yT4vKfHRn2bPUfD6esjqg', | |
clientId: '6cft3z9ue91uqcg6ibqcywxvq' | |
}, | |
id: '1ykhop6itgiao6rxyqu10a5g', | |
accountId: 'c3t3t4u3xv9g42b0gm566yzu9', | |
object: 'thread', | |
subject: 'Nylas Challenge - Curtis Belt - 2022-06-06', | |
participants: [ | |
EmailParticipant { | |
email: '[email protected]', | |
name: 'Dominic Jodoin' | |
}, | |
EmailParticipant { | |
email: '[email protected]', | |
name: '' | |
} | |
], | |
lastMessageTimestamp: 2022-06-06T20:18:08.000Z, | |
lastMessageReceivedTimestamp: 2022-06-06T20:18:08.000Z, | |
firstMessageTimestamp: 2022-06-06T20:17:53.000Z, | |
messageIds: [ '980mod9nek2438pnli3548fhb', '18f7x19fpfpskbk5ci4yfyl8f' ], | |
snippet: 'Hello, Please reply to the sender of this message with your favorite snack in the body. Regards, -- Dominic.', | |
unread: true, | |
starred: false, | |
version: 1, | |
lastMessageSentTimestamp: null, | |
hasAttachments: false, | |
labels: [ | |
Label { | |
connection: [NylasConnection], | |
id: '7rq887nrwxc2qqf0r1rxia8bn', | |
accountId: undefined, | |
object: undefined, | |
name: 'inbox', | |
displayName: 'Inbox' | |
} | |
], | |
draftIds: [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 2. Provide the subject of each message in the thread above. | |
*/ | |
import nylas from "./index.js"; | |
const thread = await nylas.threads.find("1ykhop6itgiao6rxyqu10a5g"); | |
const messages = await nylas.messages.findMultiple(thread.messageIds); | |
for (let message of messages) { | |
console.log(message.subject); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nylas Challenge - Curtis Belt - 2022-06-06 | |
Re: Nylas Challenge - Curtis Belt - 2022-06-06 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 3. What `message_id`s belong to this thread? Store the message IDs in a variable. | |
*/ | |
import nylas from "./index.js"; | |
const thread = await nylas.threads.find("1ykhop6itgiao6rxyqu10a5g"); | |
const messageIds = thread.messageIds; | |
console.log(messageIds); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ '980mod9nek2438pnli3548fhb', '18f7x19fpfpskbk5ci4yfyl8f' ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 4. Use the `message_id`s from the thread object and retrieve all message objects from the API. | |
*/ | |
import nylas from "./index.js"; | |
const thread = await nylas.threads.find("1ykhop6itgiao6rxyqu10a5g"); | |
const messages = await nylas.messages.findMultiple(thread.messageIds); | |
console.log(messages); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
Message { | |
connection: NylasConnection { | |
threads: [RestfulModelCollection], | |
contacts: [ContactRestfulModelCollection], | |
messages: [MessageRestfulModelCollection], | |
drafts: [RestfulModelCollection], | |
files: [RestfulModelCollection], | |
calendars: [CalendarRestfulModelCollection], | |
jobStatuses: [JobStatusRestfulModelCollection], | |
events: [RestfulModelCollection], | |
resources: [RestfulModelCollection], | |
deltas: [DeltaCollection], | |
labels: [RestfulModelCollection], | |
folders: [RestfulModelCollection], | |
account: [RestfulModelInstance], | |
component: [ComponentRestfulModelCollection], | |
scheduler: [SchedulerRestfulModelCollection], | |
outbox: [Outbox], | |
neural: [Neural], | |
accessToken: '2G92spEQ2yT4vKfHRn2bPUfD6esjqg', | |
clientId: '6cft3z9ue91uqcg6ibqcywxvq' | |
}, | |
id: '980mod9nek2438pnli3548fhb', | |
accountId: 'c3t3t4u3xv9g42b0gm566yzu9', | |
object: 'message', | |
to: [ [EmailParticipant] ], | |
subject: 'Nylas Challenge - Curtis Belt - 2022-06-06', | |
from: [ [EmailParticipant] ], | |
replyTo: [], | |
cc: [], | |
bcc: [], | |
date: 2022-06-06T20:17:53.000Z, | |
threadId: '1ykhop6itgiao6rxyqu10a5g', | |
snippet: 'Hey there! Please make a request to the Nylas API that marks every message in this thread as "read" and be sure to include all requests and responses made. Regards, -- Dominic.', | |
body: '<div dir="ltr"><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hey there!<br><br>Please make a request to the Nylas API that marks every message in this thread as "read" and be sure to include all requests and responses made.<br><br>Regards,<br><br>-- Dominic.<br></div></div></div></div></div></div>', | |
unread: true, | |
starred: false, | |
files: [], | |
events: [], | |
labels: [ [Label] ] | |
}, | |
Message { | |
connection: NylasConnection { | |
threads: [RestfulModelCollection], | |
contacts: [ContactRestfulModelCollection], | |
messages: [MessageRestfulModelCollection], | |
drafts: [RestfulModelCollection], | |
files: [RestfulModelCollection], | |
calendars: [CalendarRestfulModelCollection], | |
jobStatuses: [JobStatusRestfulModelCollection], | |
events: [RestfulModelCollection], | |
resources: [RestfulModelCollection], | |
deltas: [DeltaCollection], | |
labels: [RestfulModelCollection], | |
folders: [RestfulModelCollection], | |
account: [RestfulModelInstance], | |
component: [ComponentRestfulModelCollection], | |
scheduler: [SchedulerRestfulModelCollection], | |
outbox: [Outbox], | |
neural: [Neural], | |
accessToken: '2G92spEQ2yT4vKfHRn2bPUfD6esjqg', | |
clientId: '6cft3z9ue91uqcg6ibqcywxvq' | |
}, | |
id: '18f7x19fpfpskbk5ci4yfyl8f', | |
accountId: 'c3t3t4u3xv9g42b0gm566yzu9', | |
object: 'message', | |
to: [ [EmailParticipant] ], | |
subject: 'Re: Nylas Challenge - Curtis Belt - 2022-06-06', | |
from: [ [EmailParticipant] ], | |
replyTo: [], | |
cc: [], | |
bcc: [], | |
date: 2022-06-06T20:18:08.000Z, | |
threadId: '1ykhop6itgiao6rxyqu10a5g', | |
snippet: 'Hello, Please reply to the sender of this message with your favorite snack in the body. Regards, -- Dominic.', | |
body: '<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<br><br>Please reply to the sender of this message with your favorite snack in the body.<br><br>Regards,<br><br>-- Dominic.<br></div></div></div></div>', | |
unread: true, | |
starred: false, | |
files: [], | |
events: [], | |
labels: [ [Label] ] | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 5. Make a request to get the labels available in this account, and add the "Interviews" label to the thread object. This label already exists. Please do not create a new one. | |
*/ | |
import nylas from "./index.js"; | |
const thread = await nylas.threads.find("1ykhop6itgiao6rxyqu10a5g"); | |
// Looks like the search method only works for messages and threads, darn! | |
// const findLabel = await nylas.labels.search("Interviews"); | |
/** | |
* labels.list() returns 100 by default. In a production environment, you can't rely on | |
* the label you want being in the first 100, so pagination would be used here | |
* via the offset and limit parameters. | |
*/ | |
const labels = await nylas.labels.list(); | |
const interviewLabel = labels.find( | |
(label) => label.displayName === "Interviews" | |
); | |
// Add the label and save the thread. | |
thread.labels.push(interviewLabel); | |
thread.save(); | |
console.log(thread); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thread { | |
connection: <ref *1> NylasConnection { | |
threads: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/threads' | |
}, | |
contacts: ContactRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/contacts' | |
}, | |
messages: MessageRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/messages' | |
}, | |
drafts: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/drafts' | |
}, | |
files: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/files' | |
}, | |
calendars: CalendarRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/calendars' | |
}, | |
jobStatuses: JobStatusRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/job-statuses' | |
}, | |
events: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/events' | |
}, | |
resources: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/resources' | |
}, | |
deltas: DeltaCollection { path: '/delta', connection: [Circular *1] }, | |
labels: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/labels' | |
}, | |
folders: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/folders' | |
}, | |
account: RestfulModelInstance { | |
modelClass: [Function], | |
connection: [Circular *1] | |
}, | |
component: ComponentRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/component' | |
}, | |
scheduler: SchedulerRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/manage/pages', | |
baseUrl: 'https://api.schedule.nylas.com' | |
}, | |
outbox: Outbox { path: '/v2/outbox', connection: [Circular *1] }, | |
neural: Neural { | |
connection: [Circular *1], | |
id: undefined, | |
accountId: undefined, | |
object: undefined | |
}, | |
accessToken: '2G92spEQ2yT4vKfHRn2bPUfD6esjqg', | |
clientId: '6cft3z9ue91uqcg6ibqcywxvq' | |
}, | |
id: '1ykhop6itgiao6rxyqu10a5g', | |
accountId: 'c3t3t4u3xv9g42b0gm566yzu9', | |
object: 'thread', | |
subject: 'Nylas Challenge - Curtis Belt - 2022-06-06', | |
participants: [ | |
EmailParticipant { | |
email: '[email protected]', | |
name: 'Dominic Jodoin' | |
}, | |
EmailParticipant { | |
email: '[email protected]', | |
name: '' | |
} | |
], | |
lastMessageTimestamp: 2022-06-06T20:18:08.000Z, | |
lastMessageReceivedTimestamp: 2022-06-06T20:18:08.000Z, | |
firstMessageTimestamp: 2022-06-06T20:17:53.000Z, | |
messageIds: [ '980mod9nek2438pnli3548fhb', '18f7x19fpfpskbk5ci4yfyl8f' ], | |
snippet: 'Hello, Please reply to the sender of this message with your favorite snack in the body. Regards, -- Dominic.', | |
unread: true, | |
starred: false, | |
version: 1, | |
lastMessageSentTimestamp: null, | |
hasAttachments: false, | |
labels: [ | |
Label { | |
connection: [NylasConnection], | |
id: '7rq887nrwxc2qqf0r1rxia8bn', | |
accountId: undefined, | |
object: undefined, | |
name: 'inbox', | |
displayName: 'Inbox' | |
}, | |
Label { | |
connection: [NylasConnection], | |
id: 'ei6l9dyt6xjfgh4pln3ykezh3', | |
accountId: 'c3t3t4u3xv9g42b0gm566yzu9', | |
object: 'label', | |
name: '', | |
displayName: 'Interviews' | |
} | |
], | |
draftIds: [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 6. Follow the instructions listed in the `body` of each of the messages. | |
*/ | |
import nylas from "./index.js"; | |
import Draft from "nylas/lib/models/draft.js"; | |
const thread = await nylas.threads.find("1ykhop6itgiao6rxyqu10a5g"); | |
const getMessages = async () => | |
await nylas.messages.findMultiple(thread.messageIds); | |
// Display the message IDs and snippets to find out what the tasks are. | |
for (let { id, snippet, unread } of await getMessages()) { | |
console.log({ id, snippet, unread }); | |
} | |
/** | |
* TASK 1 ******************************************************************* | |
* Hey there! Please make a request to the Nylas API that marks every message | |
* in this thread as "read" and be sure to include all requests and responses | |
* made. Regards, -- Dominic. | |
*/ | |
thread.unread = false; | |
await thread.save(); // Use await to ensure thread has time to save | |
for (let { id, snippet, unread } of await getMessages()) { | |
console.log({ id, snippet, unread }); | |
} | |
/** | |
* TASK 2 ******************************************************************* | |
* Hello, Please reply to the sender of this message with your favorite snack | |
* in the body. Regards, -- Dominic. (Message ID: 18f7x19fpfpskbk5ci4yfyl8f) | |
*/ | |
const taskTwoMessage = await nylas.messages.find("18f7x19fpfpskbk5ci4yfyl8f"); | |
console.log(taskTwoMessage); | |
const draft = new Draft.default(nylas, { | |
replyToMessageId: "18f7x19fpfpskbk5ci4yfyl8f", | |
body: "My favorite snack is Twix candy bars!", | |
to: taskTwoMessage.from, | |
replyTo: [ | |
{ | |
email: "[email protected]", | |
name: "Curtis Belt", | |
}, | |
], | |
}); | |
await draft.save(); | |
console.log(draft.id); | |
const sentMessage = await draft.send(); | |
console.log(sentMessage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
id: '980mod9nek2438pnli3548fhb', | |
snippet: 'Hey there! Please make a request to the Nylas API that marks every message in this thread as "read" and be sure to include all requests and responses made. Regards, -- Dominic.', | |
unread: true | |
} | |
{ | |
id: '18f7x19fpfpskbk5ci4yfyl8f', | |
snippet: 'Hello, Please reply to the sender of this message with your favorite snack in the body. Regards, -- Dominic.', | |
unread: true | |
} | |
{ | |
id: '980mod9nek2438pnli3548fhb', | |
snippet: 'Hey there! Please make a request to the Nylas API that marks every message in this thread as "read" and be sure to include all requests and responses made. Regards, -- Dominic.', | |
unread: false | |
} | |
{ | |
id: '18f7x19fpfpskbk5ci4yfyl8f', | |
snippet: 'Hello, Please reply to the sender of this message with your favorite snack in the body. Regards, -- Dominic.', | |
unread: false | |
} | |
Draft { | |
connection: <ref *1> NylasConnection { | |
threads: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/threads' | |
}, | |
contacts: ContactRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/contacts' | |
}, | |
messages: MessageRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/messages' | |
}, | |
drafts: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/drafts' | |
}, | |
files: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/files' | |
}, | |
calendars: CalendarRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/calendars' | |
}, | |
jobStatuses: JobStatusRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/job-statuses' | |
}, | |
events: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/events' | |
}, | |
resources: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/resources' | |
}, | |
deltas: DeltaCollection { path: '/delta', connection: [Circular *1] }, | |
labels: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/labels' | |
}, | |
folders: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/folders' | |
}, | |
account: RestfulModelInstance { | |
modelClass: [Function], | |
connection: [Circular *1] | |
}, | |
component: ComponentRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/component' | |
}, | |
scheduler: SchedulerRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/manage/pages', | |
baseUrl: 'https://api.schedule.nylas.com' | |
}, | |
outbox: Outbox { path: '/v2/outbox', connection: [Circular *1] }, | |
neural: Neural { | |
connection: [Circular *1], | |
id: undefined, | |
accountId: undefined, | |
object: undefined | |
}, | |
accessToken: '2G92spEQ2yT4vKfHRn2bPUfD6esjqg', | |
clientId: '6cft3z9ue91uqcg6ibqcywxvq' | |
}, | |
id: undefined, | |
accountId: undefined, | |
object: undefined, | |
to: [] | |
} | |
Message { | |
connection: <ref *1> NylasConnection { | |
threads: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/threads' | |
}, | |
contacts: ContactRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/contacts' | |
}, | |
messages: MessageRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/messages' | |
}, | |
drafts: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/drafts' | |
}, | |
files: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/files' | |
}, | |
calendars: CalendarRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/calendars' | |
}, | |
jobStatuses: JobStatusRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/job-statuses' | |
}, | |
events: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/events' | |
}, | |
resources: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/resources' | |
}, | |
deltas: DeltaCollection { path: '/delta', connection: [Circular *1] }, | |
labels: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/labels' | |
}, | |
folders: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/folders' | |
}, | |
account: RestfulModelInstance { | |
modelClass: [Function], | |
connection: [Circular *1] | |
}, | |
component: ComponentRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/component' | |
}, | |
scheduler: SchedulerRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/manage/pages', | |
baseUrl: 'https://api.schedule.nylas.com' | |
}, | |
outbox: Outbox { path: '/v2/outbox', connection: [Circular *1] }, | |
neural: Neural { | |
connection: [Circular *1], | |
id: undefined, | |
accountId: undefined, | |
object: undefined | |
}, | |
accessToken: '2G92spEQ2yT4vKfHRn2bPUfD6esjqg', | |
clientId: '6cft3z9ue91uqcg6ibqcywxvq' | |
}, | |
id: '18f7x19fpfpskbk5ci4yfyl8f', | |
accountId: 'c3t3t4u3xv9g42b0gm566yzu9', | |
object: 'message', | |
to: [ | |
EmailParticipant { | |
email: '[email protected]', | |
name: '' | |
} | |
], | |
subject: 'Re: Nylas Challenge - Curtis Belt - 2022-06-06', | |
from: [ | |
EmailParticipant { | |
email: '[email protected]', | |
name: 'Dominic Jodoin' | |
} | |
], | |
replyTo: [], | |
cc: [], | |
bcc: [], | |
date: 2022-06-06T20:18:08.000Z, | |
threadId: '1ykhop6itgiao6rxyqu10a5g', | |
snippet: 'Hello, Please reply to the sender of this message with your favorite snack in the body. Regards, -- Dominic.', | |
body: '<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<br><br>Please reply to the sender of this message with your favorite snack in the body.<br><br>Regards,<br><br>-- Dominic.<br></div></div></div></div>', | |
unread: false, | |
starred: false, | |
files: [], | |
events: [], | |
labels: [ | |
Label { | |
connection: [NylasConnection], | |
id: '7rq887nrwxc2qqf0r1rxia8bn', | |
accountId: undefined, | |
object: undefined, | |
name: 'inbox', | |
displayName: 'Inbox' | |
} | |
] | |
} | |
1oyhdf1no2zod8bbn4tixqzyj | |
Message { | |
connection: <ref *1> NylasConnection { | |
threads: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/threads' | |
}, | |
contacts: ContactRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/contacts' | |
}, | |
messages: MessageRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/messages' | |
}, | |
drafts: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/drafts' | |
}, | |
files: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/files' | |
}, | |
calendars: CalendarRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/calendars' | |
}, | |
jobStatuses: JobStatusRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/job-statuses' | |
}, | |
events: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/events' | |
}, | |
resources: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/resources' | |
}, | |
deltas: DeltaCollection { path: '/delta', connection: [Circular *1] }, | |
labels: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/labels' | |
}, | |
folders: RestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/folders' | |
}, | |
account: RestfulModelInstance { | |
modelClass: [Function], | |
connection: [Circular *1] | |
}, | |
component: ComponentRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/component' | |
}, | |
scheduler: SchedulerRestfulModelCollection { | |
modelClass: [Function], | |
connection: [Circular *1], | |
_path: '/manage/pages', | |
baseUrl: 'https://api.schedule.nylas.com' | |
}, | |
outbox: Outbox { path: '/v2/outbox', connection: [Circular *1] }, | |
neural: Neural { | |
connection: [Circular *1], | |
id: undefined, | |
accountId: undefined, | |
object: undefined | |
}, | |
accessToken: '2G92spEQ2yT4vKfHRn2bPUfD6esjqg', | |
clientId: '6cft3z9ue91uqcg6ibqcywxvq' | |
}, | |
id: '1oyhdf1no2zod8bbn4tixqzyj', | |
accountId: 'c3t3t4u3xv9g42b0gm566yzu9', | |
object: 'message', | |
to: [ | |
EmailParticipant { | |
email: '[email protected]', | |
name: 'Dominic Jodoin' | |
} | |
], | |
subject: 'Re: Nylas Challenge - Curtis Belt - 2022-06-06', | |
from: [ | |
EmailParticipant { | |
email: '[email protected]', | |
name: 'dse_challenge nylas' | |
} | |
], | |
replyTo: [ | |
EmailParticipant { | |
email: '[email protected]', | |
name: 'Curtis Belt' | |
} | |
], | |
cc: [], | |
bcc: [], | |
date: 2022-06-09T02:32:36.000Z, | |
threadId: '1ykhop6itgiao6rxyqu10a5g', | |
snippet: 'My favorite snack is Twix candy bars!', | |
body: 'My favorite snack is Twix candy bars!', | |
unread: false, | |
starred: false, | |
files: [], | |
events: [], | |
labels: [ | |
Label { | |
connection: [NylasConnection], | |
id: '9knv8xk1zyw1nm2n3p8tiu1na', | |
accountId: undefined, | |
object: undefined, | |
name: 'drafts', | |
displayName: 'Drafts' | |
}, | |
Label { | |
connection: [NylasConnection], | |
id: '8voi4244lor13uinu2zjki141', | |
accountId: undefined, | |
object: undefined, | |
name: 'sent', | |
displayName: 'Sent Mail' | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Nylas from "nylas"; | |
Nylas.config({ | |
clientId: process.env.NYLAS_CLIENT_ID, | |
clientSecret: process.env.NYLAS_CLIENT_SECRET, | |
}); | |
const nylas = Nylas.with(process.env.NYLAS_ACCESS_TOKEN); | |
export default nylas; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "module", | |
"dependencies": { | |
"nylas": "^6.4.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment