Documentation
¶
Overview ¶
Package nylas provides an API Client for working with the v2 of the Nylas API.
See https://docs.nylas.com/ for full documentation of the API which this package makes requests to.
Index ¶
- Constants
- Variables
- func Bool(v bool) *bool
- func NewError(resp *http.Response) error
- func String(v string) *string
- type Account
- type AuthorizeRequest
- type AuthorizeSettings
- type Client
- func (c *Client) Account(ctx context.Context) (Account, error)
- func (c *Client) Accounts(ctx context.Context) ([]ManagementAccount, error)
- func (c *Client) As(accessToken string) *Client
- func (c *Client) CancelAccount(ctx context.Context, id string) error
- func (c *Client) ConnectAccount(ctx context.Context, authReq AuthorizeRequest) (Account, error)
- func (c *Client) CreateDraft(ctx context.Context, draftReq DraftRequest) (Draft, error)
- func (c *Client) DeleteDraft(ctx context.Context, id string, version int) error
- func (c *Client) Deltas(ctx context.Context, cursor string, opts *DeltasOptions) (DeltaResponse, error)
- func (c *Client) Draft(ctx context.Context, id string) (Draft, error)
- func (c *Client) Drafts(ctx context.Context, opts *DraftsOptions) ([]Draft, error)
- func (c *Client) DraftsCount(ctx context.Context, opts *DraftsOptions) (int, error)
- func (c *Client) Folders(ctx context.Context, opts *FoldersOptions) ([]Folder, error)
- func (c *Client) FoldersCount(ctx context.Context) (int, error)
- func (c *Client) Labels(ctx context.Context, opts *LabelsOptions) ([]Label, error)
- func (c *Client) LabelsCount(ctx context.Context) (int, error)
- func (c *Client) LatestDeltaCursor(ctx context.Context) (string, error)
- func (c *Client) Message(ctx context.Context, id string, expanded bool) (Message, error)
- func (c *Client) Messages(ctx context.Context, opts *MessagesOptions) ([]Message, error)
- func (c *Client) MessagesCount(ctx context.Context, opts *MessagesOptions) (int, error)
- func (c *Client) RawMessage(ctx context.Context, id string) ([]byte, error)
- func (c *Client) ReactivateAccount(ctx context.Context, id string) error
- func (c *Client) RevokeAccountTokens(ctx context.Context, id string, keepToken *string) error
- func (c *Client) SendDirectly(ctx context.Context, draftRequest DraftRequest) (Message, error)
- func (c *Client) SendDraft(ctx context.Context, id string, version int) (Message, error)
- func (c *Client) StreamDeltas(ctx context.Context, cursor string, fn func(Delta)) error
- func (c *Client) Thread(ctx context.Context, id string, expanded bool) (Thread, error)
- func (c *Client) Threads(ctx context.Context, opts *ThreadsOptions) ([]Thread, error)
- func (c *Client) ThreadsCount(ctx context.Context, opts *ThreadsOptions) (int, error)
- func (c *Client) UpdateDraft(ctx context.Context, id string, updateReq UpdateDraftRequest) (Draft, error)
- func (c *Client) UpdateMessage(ctx context.Context, id string, updateReq UpdateMessageRequest) (Message, error)
- func (c *Client) UpdateThread(ctx context.Context, id string, updateReq UpdateThreadRequest) (Thread, error)
- type Delta
- type DeltaResponse
- type DeltasOptions
- type Draft
- type DraftRequest
- type DraftsOptions
- type Error
- type ExchangeAuthorizeSettings
- type File
- type Folder
- type FoldersOptions
- type GmailAuthorizeSettings
- type IMAPAuthorizeSettings
- type Label
- type LabelsOptions
- type ManagementAccount
- type Message
- type MessagesOptions
- type Office365AuthorizeSettings
- type Option
- type OutlookAuthorizeSettings
- type Participant
- type Thread
- type ThreadsOptions
- type UpdateDraftRequest
- type UpdateMessageRequest
- type UpdateThreadRequest
- type WebhookDelta
- type WebhookListener
Constants ¶
const ( BillingStateCancelled = "cancelled" BillingStatePaid = "paid" BillingStateDeleted = "deleted" )
BillingState constants, for more info see: https://docs.nylas.com/reference#aclient_idaccounts
const ( ViewCount = "count" ViewExpanded = "expanded" ViewIDs = "ids" )
View constants for more info, see: https://docs.nylas.com/reference#views
const ( MailboxInbox = "inbox" MailboxAll = "all" MailboxTrash = "trash" MailboxArchive = "archive" MailboxDrafts = "drafts" MailboxSent = "sent" MailboxSpam = "spam" MailboxImportant = "important" )
Label/Folder mailbox name constants, for more info see: https://docs.nylas.com/reference#get-labels https://docs.nylas.com/reference#get-folders https://tools.ietf.org/html/rfc6154
Variables ¶
var ErrAccessTokenNotSet = errors.New("access token not set on client")
ErrAccessTokenNotSet is returned when Client methods are called that require an access token to be set.
Functions ¶
Types ¶
type Account ¶
type Account struct {
ID string `json:"id"`
Object string `json:"object"`
AccountID string `json:"account_id"`
Name string `json:"name"`
EmailAddress string `json:"email_address"`
Provider string `json:"provider"`
OrganizationUnit string `json:"organization_unit"`
SyncState string `json:"sync_state"`
LinkedAt int `json:"linked_at"`
// Only populated after a call to ConnectAccount
AccessToken string `json:"access_token"`
BillingState string `json:"billing_state"`
}
Account contains the details of an account which corresponds to an email address, mailbox, and optionally a calendar.
type AuthorizeRequest ¶
type AuthorizeRequest struct {
Name string
EmailAddress string
Settings AuthorizeSettings
Scopes []string
// contains filtered or unexported fields
}
AuthorizeRequest used to start the process of connecting an account to Nylas. See: https://docs.nylas.com/reference#connectauthorize
func (AuthorizeRequest) MarshalJSON ¶
func (r AuthorizeRequest) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
type AuthorizeSettings ¶
type AuthorizeSettings interface {
// Provider returns the provider value to be used in a connect request.
Provider() string
}
AuthorizeSettings provides settings for a native authentication connect request and should JSON marshal into the desired object. See: https://docs.nylas.com/reference#section-provider-specific-settings
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for working with the Nylas API.
func (*Client) Account ¶
Account returns the account information for the user the client is authenticated as. See: https://docs.nylas.com/reference#account
func (*Client) Accounts ¶
func (c *Client) Accounts(ctx context.Context) ([]ManagementAccount, error)
Accounts returns the account information for all accounts. See: https://docs.nylas.com/reference#aclient_idaccounts
func (*Client) CancelAccount ¶
CancelAccount cancels a paid account. See: https://docs.nylas.com/reference#cancel-an-account
func (*Client) ConnectAccount ¶
ConnectAccount to Nylas with Native Authentication. See: https://docs.nylas.com/docs/native-authentication
func (*Client) CreateDraft ¶
CreateDraft creates a new draft. See: https://docs.nylas.com/reference#post-draft
func (*Client) DeleteDraft ¶
DeleteDraft deletes draft matching the id, version must be the latest version of the draft. See: https://docs.nylas.com/reference#draftsid
func (*Client) Deltas ¶
func (c *Client) Deltas( ctx context.Context, cursor string, opts *DeltasOptions, ) (DeltaResponse, error)
Deltas requests a set of changes starting at cursor for a users mailbox.
Note: this may not return all the changes that have happened since the start of the cursor and so you should keep requesting using DeltaResponse.CursorEnd until a response is given with CursorStart equal to CursorEnd.
See: https://docs.nylas.com/reference#requesting-a-set-of-deltas
func (*Client) Draft ¶
Draft returns a draft by id. See: https://docs.nylas.com/reference#get-draft
func (*Client) Drafts ¶
Drafts returns drafts which match the filter specified by parameters. See: https://docs.nylas.com/reference#get-drafts
func (*Client) DraftsCount ¶
DraftsCount returns the count of drafts which match the filter specified by parameters. See: https://docs.nylas.com/reference#get-drafts
func (*Client) Folders ¶
Folders returns folders which match the filter specified by parameters. See: https://docs.nylas.com/reference#get-folders
func (*Client) FoldersCount ¶
FoldersCount returns the count of folders. See: https://docs.nylas.com/reference#get-folders
func (*Client) Labels ¶
Labels returns labels which match the filter specified by parameters. See: https://docs.nylas.com/reference#get-labels
func (*Client) LabelsCount ¶
LabelsCount returns the count of labels. See: https://docs.nylas.com/reference#get-labels
func (*Client) LatestDeltaCursor ¶
LatestDeltaCursor returns latest delta cursor for a users mailbox. See: https://docs.nylas.com/reference#obtaining-a-delta-cursor
func (*Client) Message ¶
Message returns a message by id. See: https://docs.nylas.com/reference#messagesid
func (*Client) Messages ¶
Messages returns messages which match the filter specified by parameters. See: https://docs.nylas.com/reference#messages-1
func (*Client) MessagesCount ¶
MessagesCount returns the count of messages which match the filter specified by parameters. See: https://docs.nylas.com/reference#messages-1
func (*Client) RawMessage ¶
RawMessage returns the raw message in RFC-2822 format. See: https://docs.nylas.com/reference#raw-message-contents
func (*Client) ReactivateAccount ¶
ReactivateAccount re-enables a cancelled account to make it activate again. See: https://docs.nylas.com/reference#re-activate-an-account.
func (*Client) RevokeAccountTokens ¶
RevokeAccountTokens revokes all account tokens, optionally excluding one. See: https://docs.nylas.com/reference#revoke-all
func (*Client) SendDirectly ¶
SendDirectly a message without creating a draft first. See: https://docs.nylas.com/reference#sending-directly
func (*Client) SendDraft ¶
SendDraft sends an existing drafted with the given id and version. Version must be the most recent version of the draft or the request will fail. See: https://docs.nylas.com/reference#sending-drafts
func (*Client) StreamDeltas ¶
StreamDeltas streams deltas for a users mailbox with a long lived connection calling the provided function with each delta.
This method will block until the context is cancelled or an error occurs. Ensure you set a http.Client with appropriate timeout settings, e.g:
&http.Client{
Transport: &http.Transport{
Dial: (&net.Dialer{
Timeout: 5 * time.Second,
}).Dial,
ResponseHeaderTimeout: 10 * time.Second,
TLSHandshakeTimeout: 5 * time.Second,
},
}
See: https://docs.nylas.com/reference#streaming-delta-updates
func (*Client) Thread ¶
Thread returns a thread by id. See: https://docs.nylas.com/reference#threadsid
func (*Client) Threads ¶
Threads returns threads which match the filter specified by parameters. See: https://docs.nylas.com/reference#get-threads
func (*Client) ThreadsCount ¶
ThreadsCount returns the count of threads which match the filter specified by parameters. See: https://docs.nylas.com/reference#get-threads
func (*Client) UpdateDraft ¶
func (c *Client) UpdateDraft( ctx context.Context, id string, updateReq UpdateDraftRequest, ) (Draft, error)
UpdateDraft updates a draft with the id.
Updating a draft returns a draft with the same ID but different Version. When submitting subsequent send or save actions, you must use this new version. See: https://docs.nylas.com/reference#put-draft
func (*Client) UpdateMessage ¶
func (c *Client) UpdateMessage( ctx context.Context, id string, updateReq UpdateMessageRequest, ) (Message, error)
UpdateMessage updates a message with the id. See: https://docs.nylas.com/reference#messagesid-1
func (*Client) UpdateThread ¶
func (c *Client) UpdateThread( ctx context.Context, id string, updateReq UpdateThreadRequest, ) (Thread, error)
UpdateThread updates a thread with the id. See: https://docs.nylas.com/reference#threadsid-1
type Delta ¶
type Delta struct {
ID string `json:"id"`
Object string `json:"object"`
Event string `json:"event"`
Cursor string `json:"cursor"`
Attributes json.RawMessage `json:"attributes"`
}
Delta represents a change in the Nylas system. See: https://docs.nylas.com/reference#deltas
type DeltaResponse ¶
type DeltaResponse struct {
CursorStart string `json:"cursor_start"`
CursorEnd string `json:"cursor_end"`
Deltas []Delta `json:"deltas"`
}
DeltaResponse contains the response of a Delta API request.
type DeltasOptions ¶
type DeltasOptions struct {
IncludeTypes []string `url:"include_types,comma,omitempty"`
ExcludeTypes []string `url:"exclude_types,comma,omitempty"`
View string `url:"view,omitempty"`
}
DeltasOptions provides optional parameters to the Deltas method.
type Draft ¶
type Draft struct {
Message
ReplyToMessageID string `json:"reply_to_message_id"`
Version int `json:"version"`
}
Draft is a special kind of message which has not been sent, and therefore it's body contents and recipients are still mutable. See: https://docs.nylas.com/reference#drafts
type DraftRequest ¶
type DraftRequest struct {
Subject string `json:"subject"`
From []Participant `json:"from"`
To []Participant `json:"to"`
CC []Participant `json:"cc"`
BCC []Participant `json:"bcc"`
ReplyTo []Participant `json:"reply_to"`
ReplyToMessageID string `json:"reply_to_message_id,omitempty"`
Body string `json:"body"`
FileIDs []string `json:"file_ids"`
}
DraftRequest contains the request parameters required to create a draft or send it directly. See: https://docs.nylas.com/reference#drafts
type DraftsOptions ¶
type DraftsOptions struct {
View string `url:"view,omitempty"`
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
// Return drafts that have been sent or received from the list of
// email addresses. A maximum of 25 emails may be specified
AnyEmail []string `url:"any_email,comma,omitempty"`
}
DraftsOptions provides optional parameters to the Drafts method.
type Error ¶
type Error struct {
StatusCode int `json:"-"`
Body []byte `json:"-"`
Message string `json:"message"`
Type string `json:"type"`
ServerError string `json:"server_error"`
}
Error returned from the Nylas API. See: https://docs.nylas.com/reference#errors See: https://docs.nylas.com/reference#section-sending-errors
type ExchangeAuthorizeSettings ¶
type ExchangeAuthorizeSettings struct {
Username string `json:"username"`
Password string `json:"password"`
}
ExchangeAuthorizeSettings implements AuthorizeSettings.
func (ExchangeAuthorizeSettings) Provider ¶
func (ExchangeAuthorizeSettings) Provider() string
Provider returns the provider value to be used in a connect request.
type File ¶
type File struct {
ID string `json:"id"`
Object string `json:"object"`
AccountID string `json:"account_id"`
ContentType string `json:"content_type"`
Filename string `json:"filename"`
Size int `json:"size"`
}
File represents a file in the Nylas system.
type Folder ¶
type Folder struct {
ID string `json:"id"`
Object string `json:"object"`
AccountID string `json:"account_id"`
// Localized name of the folder
DisplayName string `json:"display_name"`
// Standard categories type, based on RFC-6154, can be one of the
// Mailbox* constants, e.g MailboxInbox or empty if user created.
// See: https://tools.ietf.org/html/rfc6154
Name string `json:"name"`
}
Folder represents a folder in the Nylas system.
type FoldersOptions ¶
type FoldersOptions struct {
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
}
FoldersOptions provides optional parameters to the Folders method.
type GmailAuthorizeSettings ¶
type GmailAuthorizeSettings struct {
GoogleClientID string `json:"google_client_id"`
GoogleClientSecret string `json:"google_client_secret"`
GoogleRefreshToken string `json:"google_refresh_token"`
}
GmailAuthorizeSettings implements AuthorizeSettings.
func (GmailAuthorizeSettings) Provider ¶
func (GmailAuthorizeSettings) Provider() string
Provider returns the provider value to be used in a connect request.
type IMAPAuthorizeSettings ¶
type IMAPAuthorizeSettings struct {
IMAPHost string `json:"imap_host"`
IMAPPort int `json:"imap_port"`
IMAPUsername string `json:"imap_username"`
IMAPPassword string `json:"imap_password"`
SMTPHost string `json:"smtp_host"`
SMTPPort int `json:"smtp_port"`
SMTPUsername string `json:"smtp_username"`
SMTPPassword string `json:"smtp_password"`
SSLRequired bool `json:"ssl_required"`
}
IMAPAuthorizeSettings implements AuthorizeSettings.
func (IMAPAuthorizeSettings) Provider ¶
func (IMAPAuthorizeSettings) Provider() string
Provider returns the provider value to be used in a connect request.
type Label ¶
type Label struct {
ID string `json:"id"`
Object string `json:"object"`
AccountID string `json:"account_id"`
// Localized name of the label
DisplayName string `json:"display_name"`
// Standard categories type, based on RFC-6154, can be one of the
// Mailbox* constants, e.g MailboxInbox or empty if user created.
// See: https://tools.ietf.org/html/rfc6154
Name string `json:"name"`
}
Label represents a label in the Nylas system.
type LabelsOptions ¶
LabelsOptions provides optional parameters to the Labels method.
type ManagementAccount ¶
type ManagementAccount struct {
ID string `json:"id"`
AccountID string `json:"account_id"`
BillingState string `json:"billing_state"`
Email string `json:"email"`
Provider string `json:"provider"`
SyncState string `json:"sync_state"`
Trial bool `json:"trial"`
}
ManagementAccount contains the details of an account and is used when working with the Account Management endpoints. See: https://docs.nylas.com/reference#account-management
type Message ¶
type Message struct {
ID string `json:"id"`
Object string `json:"object"`
AccountID string `json:"account_id"`
ThreadID string `json:"thread_id"`
From []Participant `json:"from"`
To []Participant `json:"to"`
CC []Participant `json:"cc"`
BCC []Participant `json:"bcc"`
ReplyTo []Participant `json:"reply_to"`
// Only available in expanded view, see:
// https://docs.nylas.com/reference#views
Headers struct {
InReplyTo string `json:"In-Reply-To"`
MessageID string `json:"Message-Id"`
References []string `json:"References"`
} `json:"headers"`
Subject string `json:"subject"`
Date int64 `json:"date"`
Body string `json:"body"`
Snippet string `json:"snippet"`
Events []interface{} `json:"events"`
Files []File `json:"files"`
Folder Folder `json:"folder"`
Labels []Label `json:"labels"`
Starred bool `json:"starred"`
Unread bool `json:"unread"`
}
Message contains all the details of a single email message. See: https://docs.nylas.com/reference#messages
type MessagesOptions ¶
type MessagesOptions struct {
View string `url:"view,omitempty"`
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
// Return messages with a matching literal subject
Subject string `url:"subject,omitempty"`
// Return messages that have been sent or received from the list of
// email addresses. A maximum of 25 emails may be specified
AnyEmail []string `url:"any_email,comma,omitempty"`
// Return messages sent to this email address
To string `url:"to,omitempty"`
// Return messages sent from this email address
From string `url:"from,omitempty"`
// Return messages that were CC'd to this email address
CC string `url:"cc,omitempty"`
// Return messages that were BCC'd to this email address, likely sent
// from the parent account.
// (Most SMTP gateways remove BCC information.)
BCC string `url:"bcc,omitempty"`
// Return messages in a given folder, or with a given label.
// This parameter supports the name, display_name, or id of a folder or
// label.
In string `url:"in,omitempty"`
Unread *bool `url:"unread,omitempty"`
Starred *bool `url:"starred,omitempty"`
// Return messages belonging to a specific thread
ThreadID string `url:"thread_id,omitempty"`
Filename string `url:"filename,omitempty"`
// Return messages received before this Unix-based timestamp.
ReceivedBefore int64 `url:"received_before,omitempty"`
// Return messages received after this Unix-based timestamp.
ReceivedAfter int64 `url:"received_after,omitempty"`
HasAttachment *bool `url:"has_attachment,omitempty"`
}
MessagesOptions provides optional parameters to the Messages method.
type Office365AuthorizeSettings ¶
type Office365AuthorizeSettings struct {
MicrosoftClientSecret string `json:"microsoft_client_secret"`
MicrosoftRefreshToken string `json:"microsoft_refresh_token"`
RedirectURI string `json:"redirect_uri"`
}
Office365AuthorizeSettings implements AuthorizeSettings.
func (Office365AuthorizeSettings) Provider ¶
func (Office365AuthorizeSettings) Provider() string
Provider returns the provider value to be used in a connect request.
type Option ¶
type Option func(*Client)
Option sets an optional setting on the Client.
func WithAccessToken ¶
WithAccessToken returns an option to set the access token to be used. This token is used for user mailbox specific methods.
func WithBaseURL ¶
WithBaseURL returns an Option to set the base URL to be used.
func WithHTTPClient ¶
WithHTTPClient returns an Option to set the http.Client to be used.
type OutlookAuthorizeSettings ¶ added in v0.3.0
type OutlookAuthorizeSettings struct {
Password string `json:"password"`
}
OutlookAuthorizeSettings implements AuthorizeSettings.
func (OutlookAuthorizeSettings) Provider ¶ added in v0.3.0
func (OutlookAuthorizeSettings) Provider() string
Provider returns the provider value to be used in a connect request.
type Participant ¶
Participant in a Message/Thread.
type Thread ¶
type Thread struct {
ID string `json:"id"`
Object string `json:"object"`
AccountID string `json:"account_id"`
Folders []Folder `json:"folders"`
HasAttachments bool `json:"has_attachments"`
FirstMessageTimestamp int64 `json:"first_message_timestamp"`
LastMessageReceivedTimestamp int64 `json:"last_message_received_timestamp"`
LastMessageSentTimestamp int64 `json:"last_message_sent_timestamp"`
LastMessageTimestamp int64 `json:"last_message_timestamp"`
MessageIDs []string `json:"message_ids"`
DraftIDs []string `json:"draft_ids"`
// Only available in expanded view and the body will be missing, see:
// https://docs.nylas.com/reference#views
Messages []Message `json:"messages"`
Drafts []Message `json:"drafts"`
Participants []Participant `json:"participants"`
Labels []Label `json:"labels"`
Snippet string `json:"snippet"`
Starred bool `json:"starred"`
Subject string `json:"subject"`
Unread bool `json:"unread"`
Version int `json:"version"`
}
Thread combines multiple messages from the same conversation into a single first-class object that is similar to what users expect from email clients. See: https://docs.nylas.com/reference#threads
type ThreadsOptions ¶
type ThreadsOptions struct {
View string `url:"view,omitempty"`
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
// Return threads with a matching literal subject
Subject string `url:"subject,omitempty"`
// Return threads that have been sent or received from the list of email
// addresses. A maximum of 25 emails may be specified
AnyEmail []string `url:"any_email,comma,omitempty"`
// Return threads containing messages sent to this email address
To string `url:"to,omitempty"`
// Return threads containing messages sent from this email address
From string `url:"from,omitempty"`
// Return threads containing messages that were CC'd to this email address
CC string `url:"cc,omitempty"`
// Return threads containing messages that were BCC'd to this email
// address, likely sent from the parent account. (Most SMTP gateways
// remove BCC information.)
BCC string `url:"bcc,omitempty"`
// Return threads in a given folder, or with a given label.
// This parameter supports the name, display_name, or id of a folder or
// label.
In string `url:"in,omitempty"`
// Return threads with one or more unread messages
Unread *bool `url:"unread,omitempty"`
Filename string `url:"filename,omitempty"`
// Return threads whose most recent message was received before this
// Unix-based timestamp.
LastMessageBefore int64 `url:"last_message_before,omitempty"`
// Return threads whose most recent message was received after this
// Unix-based timestamp.
LastMessageAfter int64 `url:"last_message_after,omitempty"`
// Return threads whose first message was received before this
// Unix-based timestamp.
StartedBefore int64 `url:"started_before,omitempty"`
// Return threads whose first message was received after this
// Unix-based timestamp.
StartedAfter int64 `url:"started_after,omitempty"`
}
ThreadsOptions provides optional parameters to the Threads method.
type UpdateDraftRequest ¶
type UpdateDraftRequest struct {
Subject *string `json:"subject,omitempty"`
From *[]Participant `json:"from,omitempty"`
To *[]Participant `json:"to,omitempty"`
CC *[]Participant `json:"cc,omitempty"`
BCC *[]Participant `json:"bcc,omitempty"`
ReplyTo *[]Participant `json:"reply_to,omitempty"`
ReplyToMessageID *string `json:"reply_to_message_id,omitempty"`
Body *string `json:"body,omitempty"`
FileIDs *[]string `json:"file_ids,omitempty"`
Version int `json:"version"`
}
UpdateDraftRequest contains the request parameters requiredto update a draft.
Version is required to specify the version of the draft you wish to update, other fields are optional and will overwrite previous values if given.
type UpdateMessageRequest ¶
type UpdateMessageRequest struct {
Unread *bool `json:"unread,omitempty"`
Starred *bool `json:"starred,omitempty"`
// FolderID to move this message to.
FolderID *string `json:"folder_id,omitempty"`
// LabelIDs to overwrite any previous labels with, you must provide
// existing labels such as sent/drafts.
LabelIDs *[]string `json:"label_ids,omitempty"`
}
UpdateMessageRequest contains the request parameters required to update a message.
type UpdateThreadRequest ¶
type UpdateThreadRequest struct {
Unread *bool `json:"unread,omitempty"`
Starred *bool `json:"starred,omitempty"`
// FolderID to move this thread to.
FolderID *string `json:"folder_id,omitempty"`
// LabelIDs to overwrite any previous labels with, you must provide
// existing labels such as sent/drafts.
LabelIDs *[]string `json:"label_ids,omitempty"`
}
UpdateThreadRequest contains the request parameters required to update a thread.
type WebhookDelta ¶
type WebhookDelta struct {
Date int `json:"date"`
Object string `json:"object"`
Type string `json:"type"`
ObjectData struct {
ID string `json:"id"`
Object string `json:"object"`
AccountID string `json:"account_id"`
NamespaceID string `json:"namespace_id"`
Attributes struct {
ThreadID string `json:"thread_id"`
ReceivedDate int `json:"received_date"`
} `json:"attributes"`
// used for tracking, see:
// https://docs.nylas.com/reference#understanding-tracking-notifications
Metadata map[string]interface{} `json:"metadata"`
} `json:"object_data"`
}
WebhookDelta represents a change in a users mailbox from a webhook request.
type WebhookListener ¶
type WebhookListener struct {
// contains filtered or unexported fields
}
WebhookListener receives requests from a Nylas webhook. See: https://docs.nylas.com/reference#webhooks
func NewWebhookListener ¶
func NewWebhookListener(clientSecret string) *WebhookListener
NewWebhookListener returns a new WebhookListener..
func (*WebhookListener) Listen ¶
func (l *WebhookListener) Listen(addr string, fn func(WebhookDelta) error) error
Listen for webhooks on the given address. The callback will be called for each webhook and a non-nil error will respond with a 500 including the error message.
Note: the callback is handled synchronously, so if you need to do slow work in response to a webhook return nil and handle it in another routine.
See: https://docs.nylas.com/reference#receiving-notifications