This is a function reference for gopherhq-js. View the readme.md file in the the repo that corresponds with this version. Also, view Gopher REST API and the Gopher API Docs for more information.
This is a function reference for gopherhq-js. View the readme.md file in the the repo that corresponds with this version. Also, view Gopher REST API and the Gopher API Docs for more information.
Get information about the extension that corresponds with user's Bearer token (ie, most likely your extension).
(function?)
Optional callback
Promise
:
const res = await gopherClient.extensionGetSelf();
Send an Event to the extension. This does not require and auth token because the endpoint is meant for 3rd party services. Ex: issue created in Github, or an email response or support ticket received. The Gopher Extension can listen for events, act on tasks or create or delete tasks based on events.
(object)
params
(any)
Promise
:
const res = await gopherClient.sendEvent({type: 'event.type', payload: {"foo", "bar"}, event_url: "[unique_event_url]"});
Save Gopher extension data which is sent with every webhook related to that extension. This is how an extension persist's user settings specific to that extension. For params and details, see extension saving data API docs
(object)
Nestable key value value pairs
(any)
Promise
:
const res = await gopherClient.saveExtensionData({ foo: "bar" });
Get saved Gopher extension data For params and details, see extension get data API docs
(any)
const res = await gopherClient.getExtensionData();
Low-level function to make authenticated request to Gopher API
Promise
:
Retrieve logged-in user's extension logs For params and details, see extension saving data API docs
(object)
Filter. Ex:
{type: ['api', 'submit_failed'], extension: ['subdomain'], since: 1517948366, num: 10}
)
(any)
Promise
:
Promise resolving to log results in the form of:
{status: "success", logs[...]}
Get a filtered list of Gopher tasks
(object)
Arguments for API call
Name | Description |
---|---|
params.suppress_webhook boolean
|
Prevent Gopher from firing the task.viewed webhook |
params.status boolean
|
Retrieve completed or open tasks |
(function?)
Optional callback function
Promise
:
// Get all open tasks, sorted by due date
const res = await gopherClient.getTasks();
console.log(res.tasks);
// With a callback
gopherClient.getTasks({ limit: 1 }, (err, res) => {
if (err) done(err);
console.log(res.tasks);
});
Get a Gopher task Passing ?verbose=1 fires a webhook to the extnesion and fetches a rendered HTML email preview of the task
(object)
request params
Name | Description |
---|---|
params.id number
|
taskid |
params.verbose boolean
|
Fires webhook to extension, returns rendered HTML emails in a "messages" array if the extension makes these available in the task.viewed webhook resopnse. |
(any)
Promise
:
const res = await getTask({id: 123});
Create a new Gopher Task.
(any)
(any)
(any)
Promise
:
const res = await gopherClient.createTask(
{
webhook: false,
suppress_email: true,
verbose: 1,
task: {
command: process.env.EXAMPLE_COMMAND
},
send_messages: [
{
type: "email",
subject: "A test email message",
to: "test@example.com",
body: [
{
type: "html",
text: "<h1>This is a test</h1>"
}
]
}
]
});
Send Email and automatically create a Task This creates a gopher task and sends an email. It's a wrapper for createTask with opinionated settings for just sending email.
(any)
Promise
:
const res = await gopherClient.sendEmail({
command: command@my-ext.gopher.email,
to: "test@exampletask.com",
cc: [],
bcc: [],
from: "test@example.com",
subject: "Test1",
body: [
{
type: "html",
text: "<h1>This is a test</h1>"
}
]
});
Update A Gopher Task Used to save data against the task, update content, followup time and more
(any)
(any)
(any)
Promise
:
const res = await gopherClient.updateTask({
task: {
id: 1234,
reference_email: {
to: "newRecipient@exampletask.com"
}
}});
Archive A Gopher Task
(number)
Arguments
Name | Description |
---|---|
params.task number
|
Task object |
params.task.id number
|
Taskid to complete |
(any)
Promise
:
Permanently Delete A Gopher Task
(object)
Taskid to delete
Name | Description |
---|---|
params.task object
|
Task object |
params.task.id number
|
Taskid to delete |
(any)
Promise
:
Trigger a Gopher Task
(object)
Name | Description |
---|---|
params.trigger_url boolean
|
Trigger URL of the task to trigger (get from task object) |
params.verbose boolean?
|
Fire webhook and render HTML email response |
(any)
Promise
:
Resolve Natural Time Format (ex: {naturaltime}@ext.gopher.email)
(object)
params object
Name | Description |
---|---|
params.format string
|
Time format to check (ex: 3days) |
params.timezone string
|
IANA timezone designation ( https://www.wikiwand.com/en/List_of_tz_database_time_zones ) ex: "America/Los_Angeles" |
(any)
Promise
:
Dispatch an email-based action for a task. (Equivalent to sending an action email.)
(object)
Name | Description |
---|---|
params.action string
|
The action string |
params.reference_email object
|
The email that would be sent as the action email |
params.verbose boolean?
|
Include rendered HTML email contents in API response |
(any)
Promise
:
Get information about the currently logged in user
(function?)
Optional callback
Invite users to this extension. If an Auth token is included, the invitation email includes the name of the logged in user who is sending the invitation. "emails" param can be either an array of email addresses, or a string with a single email address.
Validate webhook signature. Set verifyAge to false when testing / mocking HTTP requests. (Server side only)
(string)
(number)
Unix Timestamp of webhook. Used to prevent reply attack
(string)
Unprocessed http post body
(boolean?
= true
)
Use for automated testing
boolean
:
Pass / fail webhook validation