api

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(apiKey string) *http.Client

NewHTTPClient creates an http.Client with the custom transport

Types

type Attachment

type Attachment struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	ContentType string `json:"contentType,omitempty"`
	Size        int64  `json:"size"`
	IsInline    bool   `json:"isInline"`
}

Attachment represents an email attachment

type Attendee

type Attendee struct {
	Email          string `json:"email"`
	Name           string `json:"name,omitempty"`
	DisplayName    string `json:"displayName,omitempty"` // Alias
	Response       string `json:"response,omitempty"`
	ResponseStatus string `json:"responseStatus,omitempty"` // Alias
}

Attendee represents an event attendee

type AuthStatusResponse

type AuthStatusResponse struct {
	Email        string    `json:"email"`
	OperatorName string    `json:"operatorName"`
	KeyID        int       `json:"keyId"`
	KeyTitle     string    `json:"keyTitle,omitempty"`
	CreatedAt    time.Time `json:"createdAt"`
}

AuthStatusResponse is the response for auth status endpoint

type BusyPeriod

type BusyPeriod struct {
	StartUtc        time.Time `json:"startUtc"`
	EndUtc          time.Time `json:"endUtc"`
	DurationMinutes int       `json:"durationMinutes"`
}

BusyPeriod represents a single busy time block

type Calendar

type Calendar struct {
	ID              int64     `json:"id"`
	ExternalID      string    `json:"externalId,omitempty"`
	Name            string    `json:"name"`
	Provider        string    `json:"provider"`
	Timezone        string    `json:"timezone,omitempty"`
	IsPrimary       bool      `json:"isPrimary"`
	IsOperatorOwner bool      `json:"isOperatorOwner,omitempty"`
	OwnerEmail      string    `json:"ownerEmail,omitempty"`
	LastSyncedAt    time.Time `json:"lastSyncedAt,omitempty"`
}

Calendar represents a calendar

type CalendarsResponse

type CalendarsResponse struct {
	Data       []Calendar `json:"data"`
	AccessInfo string     `json:"accessInfo,omitempty"`
}

CalendarsResponse is the response type for calendars

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(apiKey string) *Client

func (*Client) CreateEvent

func (c *Client) CreateEvent(req CreateEventRequest) (*Event, error)

CreateEvent creates a new event

func (*Client) Delete

func (c *Client) Delete(path string) ([]byte, error)

func (*Client) DeleteEmail

func (c *Client) DeleteEmail(emailID string) error

DeleteEmail deletes (trashes) an email

func (*Client) DeleteEvent

func (c *Client) DeleteEvent(eventID string, notifyAttendees bool) (*DeleteEventResponse, error)

DeleteEvent deletes a calendar event

func (*Client) ForwardEmail

func (c *Client) ForwardEmail(emailID string, req ForwardEmailRequest) (*EmailActionResponse, error)

ForwardEmail forwards an email to specified recipients

func (*Client) Get

func (c *Client) Get(path string) ([]byte, error)

func (*Client) GetAllEmails

func (c *Client) GetAllEmails(params EmailParams) (*EmailsResponse, error)

GetAllEmails fetches all emails by auto-paginating through results

func (*Client) GetAllEvents

func (c *Client) GetAllEvents(params EventParams) (*EventsResponse, error)

GetAllEvents fetches all events by auto-paginating through results

func (*Client) GetAuthStatus

func (c *Client) GetAuthStatus() (*AuthStatusResponse, error)

GetAuthStatus returns the current authentication status

func (*Client) GetCalendars

func (c *Client) GetCalendars() (*CalendarsResponse, error)

GetCalendars returns all calendars

func (*Client) GetEmail

func (c *Client) GetEmail(emailID string, includeBody bool) (*SingleEmailResponse, error)

GetEmail returns a single email by ID

func (*Client) GetEmails

func (c *Client) GetEmails(params EmailParams) (*EmailsResponse, error)

GetEmails returns emails based on search parameters

func (*Client) GetEvent

func (c *Client) GetEvent(eventID string) (*SingleEventResponse, error)

GetEvent returns a single event by ID

func (*Client) GetEvents

func (c *Client) GetEvents(params EventParams) (*EventsResponse, error)

GetEvents returns events based on parameters

func (*Client) GetEventsByContact

func (c *Client) GetEventsByContact(params EventsByContactParams) (*EventsResponse, error)

GetEventsByContact returns events with a specific contact Requires at least one of: email or name email and name parameters support partial matching (case-insensitive)

func (*Client) GetFreeBusy

func (c *Client) GetFreeBusy(params FreeBusyParams) (*FreeBusyResponse, error)

GetFreeBusy returns free/busy information for calendars

func (*Client) GetThread

func (c *Client) GetThread(threadID string) (*ThreadResponse, error)

GetThread returns all messages in a thread by ID

func (*Client) Logout

func (c *Client) Logout() error

Logout revokes the current API key

func (*Client) ModifyEmail

func (c *Client) ModifyEmail(emailID string, req ModifyEmailRequest) error

ModifyEmail modifies email properties (read status, labels)

func (*Client) Patch

func (c *Client) Patch(path string, data interface{}) ([]byte, error)

func (*Client) Post

func (c *Client) Post(path string, data interface{}) ([]byte, error)

func (*Client) ReplyToEmail

func (c *Client) ReplyToEmail(emailID string, req ReplyEmailRequest) (*EmailActionResponse, error)

ReplyToEmail replies to an existing email

func (*Client) RespondToEvent

func (c *Client) RespondToEvent(eventID, status string) (*Event, error)

RespondToEvent responds to an event invitation

func (*Client) SendEmail

func (c *Client) SendEmail(req SendEmailRequest) (*EmailActionResponse, error)

SendEmail sends a new email

func (*Client) UpdateEvent

func (c *Client) UpdateEvent(eventID string, req UpdateEventRequest) (*Event, error)

UpdateEvent updates an existing event (partial update)

func (*Client) WithBaseURL

func (c *Client) WithBaseURL(baseURL string) *Client

WithBaseURL sets a custom base URL (useful for testing)

type CreateEventRequest

type CreateEventRequest struct {
	CalendarID  int64     `json:"calendarId"`
	Summary     string    `json:"summary"`
	Description string    `json:"description,omitempty"`
	Location    string    `json:"location,omitempty"`
	From        time.Time `json:"from"`
	To          time.Time `json:"to"`
	IsAllDay    bool      `json:"isAllDay,omitempty"`
	Attendees   []string  `json:"attendees,omitempty"`
	Recurrence  []string  `json:"recurrence,omitempty"`
}

CreateEventRequest represents a request to create an event

type DeleteEventResponse

type DeleteEventResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

DeleteEventResponse is the response from deleting an event

type Email

type Email struct {
	ID             string        `json:"id"`
	ThreadID       string        `json:"threadId,omitempty"`
	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"`
	BodyPreview    string        `json:"bodyPreview,omitempty"`
	Body           string        `json:"body,omitempty"`
	BodyType       string        `json:"bodyType,omitempty"`
	SentAt         time.Time     `json:"sentAt,omitempty"`
	ReceivedAt     time.Time     `json:"receivedAt,omitempty"`
	IsRead         bool          `json:"isRead"`
	HasAttachments bool          `json:"hasAttachments"`
	Attachments    []Attachment  `json:"attachments,omitempty"`
	Labels         []string      `json:"labels,omitempty"`
	Importance     string        `json:"importance,omitempty"`
	Provider       string        `json:"provider"`
}

Email represents an email message

type EmailActionResponse

type EmailActionResponse struct {
	Success      bool   `json:"success"`
	EmailID      string `json:"emailId,omitempty"`
	ThreadID     string `json:"threadId,omitempty"`
	ErrorMessage string `json:"errorMessage,omitempty"`
}

EmailActionResponse is the response for send/reply/forward operations

type EmailParams

type EmailParams struct {
	Query         string
	From          string
	To            string
	Subject       string
	Label         string
	Unread        *bool
	After         time.Time
	Before        time.Time
	HasAttachment *bool
	Limit         int
	IncludeBody   bool
	PageToken     string
}

EmailParams holds parameters for email list/search queries

type EmailsResponse

type EmailsResponse struct {
	Emails        []Email `json:"emails"`
	TotalCount    int     `json:"totalCount,omitempty"`
	HasMore       bool    `json:"hasMore,omitempty"`
	NextPageToken string  `json:"nextPageToken,omitempty"`
	AccessInfo    string  `json:"accessInfo,omitempty"`
}

EmailsResponse is the response type for email list/search operations

type Event

type Event struct {
	ID               string     `json:"id"`
	CalendarID       int64      `json:"calendarId,omitempty"`
	Title            string     `json:"title"`
	Summary          string     `json:"summary,omitempty"` // Alias for backwards compat
	Description      string     `json:"description,omitempty"`
	Location         string     `json:"location,omitempty"`
	StartUtc         time.Time  `json:"startUtc"`
	EndUtc           time.Time  `json:"endUtc"`
	StartLocal       string     `json:"startLocal,omitempty"`
	EndLocal         string     `json:"endLocal,omitempty"`
	DurationMinutes  int        `json:"durationMinutes,omitempty"`
	Status           string     `json:"status"`
	AllDay           bool       `json:"allDay"`
	IsAllDay         bool       `json:"isAllDay,omitempty"` // Alias for backwards compat
	Attendees        []Attendee `json:"attendees,omitempty"`
	Organizer        string     `json:"organizer,omitempty"`
	JoinUrl          string     `json:"joinUrl,omitempty"`
	Labels           []string   `json:"labels,omitempty"`
	IsRecurringEvent bool       `json:"isRecurringEvent,omitempty"`
}

Event represents a calendar event

type EventParams

type EventParams struct {
	From             time.Time
	To               time.Time
	CalendarID       int64
	Limit            int
	Offset           int
	Query            string // keyword search (q parameter)
	Attendees        string // comma-separated attendee emails
	IncludeCancelled bool
}

EventParams holds parameters for event queries

type EventsByContactParams

type EventsByContactParams struct {
	Email  string // Partial email matching (case-insensitive)
	Name   string // Partial name/display name matching (case-insensitive)
	Limit  int
	Offset int
}

EventsByContactParams holds parameters for events by-contact queries

type EventsResponse

type EventsResponse struct {
	RequestID                string  `json:"request_id,omitempty"`
	Events                   []Event `json:"events"`
	Meta                     *Meta   `json:"meta,omitempty"`
	AccessInfo               string  `json:"accessInfo,omitempty"`
	CurrentUserCalendarEmail string  `json:"currentUserCalendarEmail,omitempty"`
}

EventsResponse is the response type for calendar events

type ForwardEmailRequest

type ForwardEmailRequest struct {
	To       []Participant `json:"to"`
	CC       []Participant `json:"cc,omitempty"`
	Body     string        `json:"body,omitempty"`
	BodyType string        `json:"bodyType,omitempty"`
}

ForwardEmailRequest represents a request to forward an email

type FreeBusyCalendar

type FreeBusyCalendar struct {
	CalendarID   int64        `json:"calendarId"`
	CalendarName string       `json:"calendarName"`
	Busy         []BusyPeriod `json:"busy"`
}

FreeBusyCalendar represents free/busy info for a single calendar

type FreeBusyParams

type FreeBusyParams struct {
	From      time.Time
	To        time.Time
	Calendars string // comma-separated calendar IDs
}

FreeBusyParams holds parameters for free/busy queries

type FreeBusyResponse

type FreeBusyResponse struct {
	Calendars  []FreeBusyCalendar `json:"calendars"`
	AccessInfo string             `json:"accessInfo,omitempty"`
}

FreeBusyResponse is the response type for free/busy queries

type Meta

type Meta struct {
	Count       int       `json:"count,omitempty"`
	Offset      int       `json:"offset,omitempty"`
	HasMore     bool      `json:"hasMore,omitempty"`
	TotalCount  int       `json:"totalCount,omitempty"`
	Truncated   bool      `json:"truncated,omitempty"`
	ExecutionMs int       `json:"execution_ms,omitempty"`
	From        time.Time `json:"from,omitempty"`
	To          time.Time `json:"to,omitempty"`
	Timestamp   time.Time `json:"timestamp,omitempty"`
}

Meta contains response metadata

type ModifyEmailRequest

type ModifyEmailRequest struct {
	MarkAsRead   *bool    `json:"markAsRead,omitempty"`
	AddLabels    []string `json:"addLabels,omitempty"`
	RemoveLabels []string `json:"removeLabels,omitempty"`
}

ModifyEmailRequest represents a request to modify email properties

type Participant

type Participant struct {
	Email string `json:"email"`
	Name  string `json:"name,omitempty"`
}

Participant represents an email participant (sender/recipient)

type ReplyEmailRequest

type ReplyEmailRequest struct {
	Body     string `json:"body"`
	BodyType string `json:"bodyType,omitempty"`
	ReplyAll bool   `json:"replyAll,omitempty"`
}

ReplyEmailRequest represents a request to reply to an email

type SendEmailRequest

type SendEmailRequest struct {
	To           []Participant `json:"to"`
	CC           []Participant `json:"cc,omitempty"`
	BCC          []Participant `json:"bcc,omitempty"`
	Subject      string        `json:"subject"`
	Body         string        `json:"body"`
	BodyType     string        `json:"bodyType,omitempty"`
	Importance   string        `json:"importance,omitempty"`
	ConnectionID *int64        `json:"connectionId,omitempty"`
}

SendEmailRequest represents a request to send a new email

type SingleEmailResponse

type SingleEmailResponse struct {
	Email      Email  `json:"email"`
	AccessInfo string `json:"accessInfo,omitempty"`
}

SingleEmailResponse wraps a single email with access info

type SingleEventResponse

type SingleEventResponse struct {
	Event                    Event  `json:"event"`
	AccessInfo               string `json:"accessInfo,omitempty"`
	CurrentUserCalendarEmail string `json:"currentUserCalendarEmail,omitempty"`
}

SingleEventResponse is the response type for a single event GET

type ThreadResponse

type ThreadResponse struct {
	ID            string        `json:"id"`
	Subject       string        `json:"subject,omitempty"`
	Messages      []Email       `json:"messages"`
	MessageCount  int           `json:"messageCount"`
	Participants  []Participant `json:"participants,omitempty"`
	LastMessageAt time.Time     `json:"lastMessageAt,omitempty"`
	Provider      string        `json:"provider"`
	AccessInfo    string        `json:"accessInfo,omitempty"`
}

ThreadResponse is the response type for GET /threads/{id}

type Transport

type Transport struct {
	Base   http.RoundTripper
	APIKey string
}

Transport implements http.RoundTripper with automatic auth and logging

func NewTransport

func NewTransport(apiKey string) *Transport

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

type UpdateEventRequest

type UpdateEventRequest struct {
	Summary           string     `json:"summary,omitempty"`
	Description       string     `json:"description,omitempty"`
	Location          string     `json:"location,omitempty"`
	From              *time.Time `json:"from,omitempty"`
	To                *time.Time `json:"to,omitempty"`
	IsAllDay          *bool      `json:"isAllDay,omitempty"`
	AddAttendees      []string   `json:"addAttendees,omitempty"`
	RemoveAttendees   []string   `json:"removeAttendees,omitempty"`
	SendNotifications *bool      `json:"sendNotifications,omitempty"`
}

UpdateEventRequest represents a request to update an event (PATCH)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL