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
- func WebhookHandler(clientSecret string, fn func(WebhookDelta) error) http.Handler
- type Account
- type AuthorizeRequest
- type AuthorizeSettings
- type Calendar
- type CalendarsOptions
- 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) Calendar(ctx context.Context, id string) (Calendar, error)
- func (c *Client) Calendars(ctx context.Context, opts *CalendarsOptions) ([]Calendar, error)
- 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) DeleteAccount(ctx context.Context, id string) error
- func (c *Client) DeleteDraft(ctx context.Context, id string, version int) error
- func (c *Client) DeleteFile(ctx context.Context, id string) error
- func (c *Client) Deltas(ctx context.Context, cursor string, opts *DeltasOptions) (DeltaResponse, error)
- func (c *Client) DownloadFile(ctx context.Context, id string) (io.ReadCloser, 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) Event(ctx context.Context, id string) (Event, error)
- func (c *Client) Events(ctx context.Context, opts *EventsOptions) ([]Event, error)
- func (c *Client) File(ctx context.Context, id string) (File, 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)
- func (c *Client) UploadFile(ctx context.Context, filename string, file io.Reader) (File, error)
- type Delta
- type DeltaResponse
- type DeltasOptions
- type Draft
- type DraftRequest
- type DraftsOptions
- type Error
- type Event
- type EventDate
- type EventDatespan
- type EventParticipant
- type EventRecurrence
- type EventTime
- type EventTimeSubobject
- type EventTimespan
- type EventsOptions
- 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 TimeZone
- type Tracking
- 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 ( OrganizationUnitFolder = "folder" OrganizationUnitLabel = "label" )
OrganizationUnit constants specify either "label" or "folder", depending on the provider capabilities.
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 ¶
func WebhookHandler ¶ added in v0.11.0
func WebhookHandler(clientSecret string, fn func(WebhookDelta) error) http.Handler
WebhookHandler returns a new http.Handler for handling Nylas webhooks.
The X-Nylas-Signature will be verified and any non-nil error returned from fn will result in a 500 response with the error message.
When mounting this route it should be called for both GET and POST requests to handle the initial webhook setup.
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 Calendar ¶ added in v0.16.0
type Calendar struct {
// Globally unique object identifier
ID string `json:"id"`
// A string describing the type of object (value is "calendar")
Object string `json:"object"`
// string Reference to parent account object
AccountID string `json:"account_id"`
// Name of the Calendar
Name string `json:"name"`
// Description of the Calendar
Description string `json:"description"`
// A boolean denoting whether this is the primary calendar associated with a account
IsPrimary bool `json:"is_primary"`
// Job status ID for the calendar modification.
JobStatusID string `json:"job_status_id"`
// True if the Calendar is read only
ReadOnly bool `json:"read_only"`
// IANA time zone database formatted string (e.g. America/New_York).
TimeZone *TimeZone `json:"timezone"`
}
Calendar represents a file in the Nylas system.
type CalendarsOptions ¶ added in v0.16.0
type CalendarsOptions struct {
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
}
CalendarsOptions provides optional parameters to the Calendars method.
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) Calendar ¶ added in v0.16.0
Calendar returns a calendar by id. See: https://developer.nylas.com/docs/api/#get/calendars/id
func (*Client) Calendars ¶ added in v0.16.0
Calendars returns all calendars paginated. See: https://developer.nylas.com/docs/api/#get/calendars
func (*Client) CancelAccount ¶
CancelAccount cancels a paid account. Accounts that are cancelled instead of deleted, can be recovered within 3 days. See: https://developer.nylas.com/docs/api/#post/a/client_id/accounts/id/downgrade
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) DeleteAccount ¶ added in v0.18.0
DeleteAccount deletes an account. Accounts deleted using this method are immediately unavailable. See: https://developer.nylas.com/docs/api/#delete/a/client_id/accounts/id
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) DeleteFile ¶ added in v0.10.0
DeleteFile removes an existing file identified by the specified file ID. See: https://docs.nylas.com/reference#files-delete
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.
func (*Client) DownloadFile ¶ added in v0.9.0
DownloadFile downloads a file attachment.
If the returned error is nil, you are expected to read the io.ReadCloser to EOF and close.
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) Event ¶ added in v0.17.0
Event returns an event by id. See: https://developer.nylas.com/docs/api/#get/events/id
func (*Client) Events ¶ added in v0.17.0
Events returns all events. See: https://developer.nylas.com/docs/api/#get/events
func (*Client) File ¶ added in v0.9.0
File returns a files metadata by id. See: https://docs.nylas.com/reference#get-metadata
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,
},
}
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
func (*Client) UploadFile ¶ added in v0.8.0
UploadFile uploads a file to be used as an attachment. See: https://docs.nylas.com/reference#upload
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"`
Tracking *Tracking `json:"tracking,omitempty"`
}
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 messages belonging to a specific thread
ThreadID string `url:"thread_id,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 Event ¶ added in v0.17.0
type Event struct {
ID string `json:"id"`
Object string `json:"object"`
AccountID string `json:"account_id"`
// A reference to the parent calendar object.
CalendarID string `json:"calendar_id"`
// The title of the event, usually short (maximum string length of 1024 characters).
Title string `json:"title"`
// The description of the event, which may contain more details or an agenda
// (maximum string length of 8192 characters).
Description string `json:"description"`
// Unique identifier as defined in RFC5545. It is used to uniquely identify events across
// calendaring systems. Can be null.
ICalUID string `json:"ical_uid"`
When EventTimeSubobject `json:"-"`
// A location, such as a physical address or meeting room name.
Location string `json:"location"`
// The owner of the event, usually specified with their email or name and email.
Owner string `json:"owner"`
// An array of other participants invited to the event. Keys are email, name, status.
// Participants may also be rooms or resources.
Participants []EventParticipant `json:"participants"`
// One of the following values: confirmed, tentative, or cancelled.
Status string `json:"status"`
// Indicates whether the event can be modified.
ReadOnly bool `json:"read_only"`
// On shared or public calendars, indicates whether to show this event's time block as available.
// (Also called transparency in some systems.)
Busy bool `json:"busy"`
// Included if the event is a master recurring event.
Recurrence EventRecurrence `json:"recurrence"`
// Only included in exceptions (overrides) to recurring events, the ID of the recurring event.
MasterEventID string `json:"master_event_id"`
// Only included in exceptions (overrides) to recurring events, the start time of the recurring event.
OriginalStartTime time.Time `json:"original_start_time"`
// A key-value pair added to an event object to store data
Metadata json.RawMessage `json:"metadata"`
}
Event represents an event in the Nylas system.
func (*Event) UnmarshalJSON ¶ added in v0.17.0
UnmarshalJSON defines an Event unmarshaller that infers the `when` subobject.
type EventDate ¶ added in v0.17.0
EventDate represents a specific date for an event, without a clock-based start or end time. Your birthday and holidays would be represented as date subobjects.
type EventDatespan ¶ added in v0.17.0
type EventDatespan struct {
// The start date of the event.
StartDate time.Time `json:"start_date"`
// The end date of the event.
EndDate time.Time `json:"end_date"`
}
EventDatespan a span of entire days without specific times. A business quarter or academic semester would be represented as datespan subobjects.
type EventParticipant ¶ added in v0.17.0
type EventParticipant struct {
// (Optional) The participant's full name.
Name string `json:"name"`
// The participant's email address.
Email string `json:"email"`
// The participant's attendance status. Allowed values are yes, maybe, no and noreply.
// The default value is noreply.
Status string `json:"status"`
// (Optional) A comment by the participant.
Comment string `json:"comment"`
}
EventParticipant represents an event participant in the Nylas system.
type EventRecurrence ¶ added in v0.17.0
type EventRecurrence struct {
// An array of RRULE and EXDATE strings. See RFC-5545 for more details.
// Please note that EXRULE and RDATE strings are not supported for POST or PUT requests at this time.
// This tool is helpful in understanding the RRULE spec.
RRule []string `json:"rrule"`
// The participant's email address.
Timezone *TimeZone `json:"timezone"`
}
EventRecurrence represents an event recurrence in the Nylas system.
type EventTime ¶ added in v0.17.0
type EventTime struct {
// Event time in UTC.
Time time.Time `json:"time"`
// If timezone is present, then the value for time will be read with timezone. Timezone using IANA formatted string.
Timezone *TimeZone `json:"timezone"`
}
EventTime subobject corresponds a single moment in time, which has no duration. Reminders or alarms are represented as time subobjects.
type EventTimeSubobject ¶ added in v0.17.0
type EventTimeSubobject interface {
// contains filtered or unexported methods
}
EventTimeSubobject represents an event time subobject.
type EventTimespan ¶ added in v0.17.0
type EventTimespan struct {
// The start time of the event.
StartTime time.Time `json:"start_time"`
// The end time of the event.
EndTime time.Time `json:"end_time"`
// start_timezone and end_timezone must be submitted together. Timezone using IANA formatted string.
StartTimezone *TimeZone `json:"start_timezone"`
// start_timezone and end_timezone must be submitted together. Timezone using IANA formatted string.
EndTimezone *TimeZone `json:"end_timezone"`
}
EventTimespan represents a span of time with a specific beginning and end time. An hour lunch meeting would be represented as timespan subobjects.
type EventsOptions ¶ added in v0.17.0
type EventsOptions struct {
ShowCancelled string `url:"show_cancelled,omitempty"`
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
EventID string `url:"event_id,omitempty"`
CalendarID string `url:"calendar_id,omitempty"`
Title string `url:"title,omitempty"`
Description string `url:"description,omitempty"`
Location string `url:"location,omitempty"`
StartsBefore string `url:"starts_before,omitempty"`
StartsAfter string `url:"starts_after,omitempty"`
EndsBefore string `url:"ends_before,omitempty"`
EndsAfter string `url:"ends_after,omitempty"`
MetadataKey string `url:"metadata_key,omitempty"`
MetadataValue string `url:"metadata_value,omitempty"`
ExpandRecurring bool `url:"expand_recurring,omitempty"`
MetadataPair string `url:"metadata_pair,omitempty"`
Busy bool `url:"busy,omitempty"`
}
EventsOptions represents request options.
type ExchangeAuthorizeSettings ¶
type ExchangeAuthorizeSettings struct {
Username string `json:"username"`
Password string `json:"password"`
EASServerHost string `json:"eas_server_host"`
}
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"`
ContentID string `json:"content_id"`
ContentDisposition string `json:"content_disposition"`
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 WithErrorHandler ¶ added in v0.12.0
WithErrorHandler returns an Option to set the error handler 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 {
Username string `json:"username"`
Password string `json:"password"`
EASServerHost string `json:"eas_server_host"`
}
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 TimeZone ¶ added in v0.16.0
TimeZone location.
func (*TimeZone) UnmarshalJSON ¶ added in v0.16.0
UnmarshalJSON implements the json.Unmarshaler interface.
type Tracking ¶ added in v0.15.0
type Tracking struct {
Links bool `json:"links,omitempty"`
Opens bool `json:"opens,omitempty"`
ThreadReplies bool `json:"thread_replies,omitempty"`
Payload string `json:"payload,omitempty"`
}
Tracking contains the requst parameters required to track an email See: https://docs.nylas.com/docs/message-tracking
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 required to 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.