Categorygithub.com/teamwork/nylas-go
modulepackage
0.18.0
Repository: https://github.com/teamwork/nylas-go.git
Documentation: pkg.go.dev

# README

Nylas API v2 Go client

Build Status GoDoc Go Report Card License MIT

Provides access to the Nylas Platform v2 REST API.

This library does not currently cover all endpoints and will be implemented as and when they are needed by our internal projects. Check the GoDoc or Status for current implementation status.

This is not an official SDK for the Nylas Platform, for the official SDKs visit Nylas SDKs.

Installation

go get github.com/teamwork/nylas-go

Usage

package main

import (
    "context"
    "log"
    "net/http"
    "time"

    nylas "github.com/teamwork/nylas-go"
)

const (
    clientID     = "..."
    clientSecret = "..."
    accessToken  = "..."
)

func main() {
    client := nylas.NewClient(clientID, clientSecret,
        nylas.WithHTTPClient(&http.Client{
            Timeout: 3 * time.Second,
        }),
        nylas.WithAccessToken(accessToken), // not required for account management endpoints
    )

    ctx := context.Background()
    deltaResp, err := client.Deltas(ctx, cursor, &nylas.DeltasOptions{
        View:         nylas.ViewExpanded,
        IncludeTypes: []string{"thread"},
    })
    if err != nil {
        log.Fatalf("get thread deltas: %v", err)
    }

    for _, d := range deltaResp.Deltas {
        log.Printf("%+v", d)
    }
}

Examples

See the example directory.

Contributing

We would like to make this library feature complete with the offical SDK projects and contributions are welcome.

Following the existing code style and conventions and submit a PR.

Status

The following features are implemented in the client:

Authentication

Hosted Authentication

  • GET /oauth/authorize
  • POST /oauth/token
  • POST /oauth/revoke

Native Authentication

  • POST /connect/authorize
  • POST /connect/token

Apps & Accounts

Accounts

  • GET /account

Account Management

  • GET /a/{client_id}/accounts
  • GET /a/{client_id}/accounts/{id}
  • DEL /a/{client_id}/accounts/{id}
  • POST /a/{client_id}/accounts/{id}/downgrade
  • POST /a/{client_id}/accounts/{id}/upgrade
  • POST /a/{client_id}/accounts/{id}/revoke-all
  • GET /a/{client_id}/ip_addresses
  • POST /a/{client_id}/accounts/{id}/token-info

Application Management

  • GET /a/{client_id}
  • POST /a/{client_id}

Threads

  • GET /threads
  • GET /threads/{id}
  • PUT /threads/{id}

Messages

  • GET /messages
  • GET /messages/{id}
  • PUT /messages/{id}
  • GET /messages/{id} (raw message content)

Folders

  • GET /folders
  • GET /folders/{id}
  • POST /folders
  • PUT /folders/{id}
  • DEL /folders/{id}

Labels

  • GET /labels
  • GET /labels/{id}
  • POST /labels
  • PUT /labels/{id}
  • DEL /labels/{id}

Drafts

  • GET /drafts
  • GET /drafts/{id}
  • POST /drafts
  • PUT /drafts/{id}
  • DEL /drafts/{id}

Sending

  • POST /send#drafts
  • POST /send#directly
  • POST /send#raw

Files

  • GET /files
  • GET /files/{id}
  • GET /files/{id}/download
  • POST /files
  • DEL /files/{id}

Calendars

  • GET /calendars
  • GET /calendars/{id}
  • POST /calendars/free-busy

Events

  • GET /events
  • GET /events/{id}
  • POST /events
  • PUT /events/{id}
  • DEL /events/{id}
  • POST /send-rsvp

Room Resources

  • GET /resources

Contacts

  • GET /contacts
  • GET /contacts/{id}
  • POST /contacts
  • PUT /contacts/{id}
  • DEL /contacts/{id}
  • GET /contacts/{id}/picture
  • GET /contacts/groups

Search

  • GET /threads/search
  • GET /messages/search

Webhooks

  • Listener client
  • GET /webhooks
  • POST /webhooks
  • GET /webhooks/{id}
  • PUT /webhooks/{id}
  • DEL /webhooks/{id}

Deltas

  • POST /delta/latest_cursor
  • GET /delta
  • GET /delta/longpoll
  • GET /delta/streaming

# Packages

No description provided by the author

# Functions

Bool returns a pointer to the given bool value.
NewClient returns a new client for working with the Nylas API.
NewError creates a new Error from an API response.
NewWebhookListener returns a new WebhookListener..
String returns a pointer to the given string value.
WebhookHandler returns a new http.Handler for handling Nylas webhooks.
WithAccessToken returns an option to set the access token to be used.
WithBaseURL returns an Option to set the base URL to be used.
WithErrorHandler returns an Option to set the error handler to be used.
WithHTTPClient returns an Option to set the http.Client to be used.

# Constants

BillingState constants, for more info see: https://docs.nylas.com/reference#aclient_idaccounts.
BillingState constants, for more info see: https://docs.nylas.com/reference#aclient_idaccounts.
BillingState constants, for more info see: https://docs.nylas.com/reference#aclient_idaccounts.
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.
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.
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.
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.
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.
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.
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.
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.
OrganizationUnit constants specify either "label" or "folder", depending on the provider capabilities.
OrganizationUnit constants specify either "label" or "folder", depending on the provider capabilities.
View constants for more info, see: https://docs.nylas.com/reference#views.
View constants for more info, see: https://docs.nylas.com/reference#views.
View constants for more info, see: https://docs.nylas.com/reference#views.

# Variables

ErrAccessTokenNotSet is returned when Client methods are called that require an access token to be set.

# Structs

Account contains the details of an account which corresponds to an email address, mailbox, and optionally a calendar.
AuthorizeRequest used to start the process of connecting an account to Nylas.
Calendar represents a file in the Nylas system.
CalendarsOptions provides optional parameters to the Calendars method.
Client for working with the Nylas API.
Delta represents a change in the Nylas system.
DeltaResponse contains the response of a Delta API request.
DeltasOptions provides optional parameters to the Deltas method.
Draft is a special kind of message which has not been sent, and therefore it's body contents and recipients are still mutable.
DraftRequest contains the request parameters required to create a draft or send it directly.
DraftsOptions provides optional parameters to the Drafts method.
Error returned from the Nylas API.
Event represents an event in the Nylas system.
EventDate represents a specific date for an event, without a clock-based start or end time.
EventDatespan a span of entire days without specific times.
EventParticipant represents an event participant in the Nylas system.
EventRecurrence represents an event recurrence in the Nylas system.
EventsOptions represents request options.
EventTime subobject corresponds a single moment in time, which has no duration.
EventTimespan represents a span of time with a specific beginning and end time.
ExchangeAuthorizeSettings implements AuthorizeSettings.
File represents a file in the Nylas system.
Folder represents a folder in the Nylas system.
FoldersOptions provides optional parameters to the Folders method.
GmailAuthorizeSettings implements AuthorizeSettings.
IMAPAuthorizeSettings implements AuthorizeSettings.
Label represents a label in the Nylas system.
LabelsOptions provides optional parameters to the Labels method.
ManagementAccount contains the details of an account and is used when working with the Account Management endpoints.
Message contains all the details of a single email message.
MessagesOptions provides optional parameters to the Messages method.
Office365AuthorizeSettings implements AuthorizeSettings.
OutlookAuthorizeSettings implements AuthorizeSettings.
Participant in a Message/Thread.
Thread combines multiple messages from the same conversation into a single first-class object that is similar to what users expect from email clients.
ThreadsOptions provides optional parameters to the Threads method.
TimeZone location.
Tracking contains the requst parameters required to track an email See: https://docs.nylas.com/docs/message-tracking.
UpdateDraftRequest contains the request parameters required to update a draft.
UpdateMessageRequest contains the request parameters required to update a message.
UpdateThreadRequest contains the request parameters required to update a thread.
WebhookDelta represents a change in a users mailbox from a webhook request.
WebhookListener receives requests from a Nylas webhook.

# Interfaces

AuthorizeSettings provides settings for a native authentication connect request and should JSON marshal into the desired object.
EventTimeSubobject represents an event time subobject.

# Type aliases

Option sets an optional setting on the Client.