gmail

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Filter Tools

Label Management

Draft Management

Account & Settings

Spam Convenience

Send-As Aliases

Delegates

View Source
var DefaultGmailHandlerDeps = common.NewDefaultHandlerDeps(NewGmailService)

DefaultGmailHandlerDeps holds the default dependencies for production use. Initialize with InitDefaultGmailHandlerDeps after SetDeps to pass deps explicitly.

Attachment Tools

Functions

func ExtractAttachments added in v0.3.1

func ExtractAttachments(payload *gmail.MessagePart) []map[string]any

ExtractAttachments walks the payload tree and returns one entry per part that carries a Body.AttachmentId, with the four fields a caller needs to invoke gmail_get_attachment: attachment_id, filename, mime_type, size. part_id is included for traceability (Gmail uses dotted paths like "0.1").

Returns an empty slice if there are no attachments — callers should treat nil and empty identically.

func ExtractBody

func ExtractBody(payload *gmail.MessagePart) string

ExtractBody gets the message body from parts, preferring text/plain.

func ExtractBodyParts

func ExtractBodyParts(payload *gmail.MessagePart) (textBody, htmlBody string)

ExtractBodyParts extracts both text/plain and text/html bodies from a message. Returns (textBody, htmlBody). Either may be empty if not present.

func ExtractBodyPreferHTML

func ExtractBodyPreferHTML(payload *gmail.MessagePart) string

ExtractBodyPreferHTML gets the message body from parts, preferring text/html.

func FormatMessage

func FormatMessage(msg *gmail.Message) map[string]any

formatMessage extracts useful fields from a Gmail message

func FormatMessageWithOptions

func FormatMessageWithOptions(msg *gmail.Message, opts FormatMessageOptions) map[string]any

FormatMessageWithOptions extracts useful fields from a Gmail message with configurable options.

func InitDefaultGmailHandlerDeps added in v0.1.7

func InitDefaultGmailHandlerDeps(appDeps *common.Deps)

InitDefaultGmailHandlerDeps initializes the default Gmail handler deps with explicit deps, avoiding reliance on the global singleton at call time.

func RegisterTools

func RegisterTools(s *server.MCPServer)

RegisterTools registers all Gmail tools with the MCP server.

func TestableGmailArchive

func TestableGmailArchive(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailArchive archives a message.

func TestableGmailBatchArchive

func TestableGmailBatchArchive(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailBatchArchive archives multiple messages.

func TestableGmailBatchModify

func TestableGmailBatchModify(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailBatchModify modifies labels on multiple messages.

func TestableGmailBatchTrash

func TestableGmailBatchTrash(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailBatchTrash moves multiple messages to trash.

func TestableGmailCreateDelegate added in v0.1.6

func TestableGmailCreateDelegate(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailCreateDelegate adds a new delegate to the account.

func TestableGmailCreateFilter

func TestableGmailCreateFilter(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailCreateFilter creates a new filter.

func TestableGmailCreateLabel

func TestableGmailCreateLabel(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailCreateLabel creates a new label.

func TestableGmailCreateSendAs added in v0.1.6

func TestableGmailCreateSendAs(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailCreateSendAs creates a new send-as alias.

func TestableGmailDeleteDelegate added in v0.1.6

func TestableGmailDeleteDelegate(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailDeleteDelegate removes a delegate from the account.

func TestableGmailDeleteDraft

func TestableGmailDeleteDraft(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailDeleteDraft deletes a draft.

func TestableGmailDeleteFilter

func TestableGmailDeleteFilter(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailDeleteFilter deletes a filter.

func TestableGmailDeleteLabel

func TestableGmailDeleteLabel(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailDeleteLabel deletes a label.

func TestableGmailDeleteSendAs added in v0.1.6

func TestableGmailDeleteSendAs(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailDeleteSendAs deletes a send-as alias.

func TestableGmailDraft

func TestableGmailDraft(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailDraft creates a new draft.

func TestableGmailGetAttachment

func TestableGmailGetAttachment(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailGetAttachment downloads an attachment.

func TestableGmailGetDraft

func TestableGmailGetDraft(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailGetDraft retrieves a draft by ID.

func TestableGmailGetMessage

func TestableGmailGetMessage(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailGetMessage retrieves a single message using the provided service.

func TestableGmailGetMessages

func TestableGmailGetMessages(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailGetMessages retrieves multiple messages using the provided service.

func TestableGmailGetProfile

func TestableGmailGetProfile(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailGetProfile gets the user's profile.

func TestableGmailGetSendAs added in v0.1.6

func TestableGmailGetSendAs(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailGetSendAs gets a specific send-as alias.

func TestableGmailGetThread

func TestableGmailGetThread(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailGetThread retrieves a thread using the provided service.

func TestableGmailGetVacation

func TestableGmailGetVacation(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailGetVacation gets vacation settings.

func TestableGmailListDelegates added in v0.1.6

func TestableGmailListDelegates(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailListDelegates lists all delegates for the account.

func TestableGmailListDrafts

func TestableGmailListDrafts(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailListDrafts lists all drafts.

func TestableGmailListFilters

func TestableGmailListFilters(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailListFilters lists all filters.

func TestableGmailListLabels

func TestableGmailListLabels(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailListLabels lists all labels.

func TestableGmailListSendAs added in v0.1.6

func TestableGmailListSendAs(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailListSendAs lists all send-as aliases for the account.

func TestableGmailMarkRead

func TestableGmailMarkRead(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailMarkRead marks a message as read.

func TestableGmailMarkUnread

func TestableGmailMarkUnread(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailMarkUnread marks a message as unread.

func TestableGmailModifyMessage

func TestableGmailModifyMessage(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailModifyMessage modifies labels on a message.

func TestableGmailModifyThread

func TestableGmailModifyThread(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailModifyThread modifies labels on a thread.

func TestableGmailNotSpam

func TestableGmailNotSpam(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailNotSpam removes a message from spam and moves to inbox.

func TestableGmailReply

func TestableGmailReply(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailReply replies to an email using the provided service.

func TestableGmailSearch

func TestableGmailSearch(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailSearch performs a Gmail search using the provided service.

func TestableGmailSend

func TestableGmailSend(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailSend sends a new email using the provided service.

func TestableGmailSendDraft

func TestableGmailSendDraft(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailSendDraft sends a draft.

func TestableGmailSetVacation

func TestableGmailSetVacation(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailSetVacation sets vacation settings.

func TestableGmailSpam

func TestableGmailSpam(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailSpam marks a message as spam.

func TestableGmailStar

func TestableGmailStar(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailStar stars a message.

func TestableGmailThreadArchive

func TestableGmailThreadArchive(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailThreadArchive archives all messages in a thread (removes INBOX label).

func TestableGmailThreadTrash

func TestableGmailThreadTrash(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailThreadTrash moves an entire thread to trash.

func TestableGmailThreadUntrash

func TestableGmailThreadUntrash(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailThreadUntrash restores an entire thread from trash.

func TestableGmailTrash

func TestableGmailTrash(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailTrash moves a message to trash.

func TestableGmailUnstar

func TestableGmailUnstar(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailUnstar unstars a message.

func TestableGmailUntrash

func TestableGmailUntrash(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailUntrash removes a message from trash.

func TestableGmailUpdateDraft

func TestableGmailUpdateDraft(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailUpdateDraft updates an existing draft.

func TestableGmailUpdateLabel

func TestableGmailUpdateLabel(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailUpdateLabel updates a label.

func TestableGmailUpdateSendAs added in v0.1.6

func TestableGmailUpdateSendAs(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailUpdateSendAs updates an existing send-as alias.

func TestableGmailVerifySendAs added in v0.1.6

func TestableGmailVerifySendAs(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (*mcp.CallToolResult, error)

TestableGmailVerifySendAs initiates verification for a send-as alias.

Types

type BodyFormat

type BodyFormat string

BodyFormat specifies the preferred format for email body extraction.

const (
	// BodyFormatText prefers text/plain content (default, reduces token usage)
	BodyFormatText BodyFormat = "text"
	// BodyFormatHTML prefers text/html content
	BodyFormatHTML BodyFormat = "html"
	// BodyFormatFull returns both text and html if available
	BodyFormatFull BodyFormat = "full"
)

type EmailMessage

type EmailMessage struct {
	To           string
	Cc           string
	Bcc          string
	Subject      string
	Body         string
	ExtraHeaders map[string]string // Additional headers (e.g., In-Reply-To, References)
}

EmailMessage holds the components for building an RFC 2822 email message.

type FormatMessageOptions

type FormatMessageOptions struct {
	BodyFormat BodyFormat
}

FormatMessageOptions configures how messages are formatted.

type GmailDelegateService added in v0.1.7

type GmailDelegateService interface {
	ListDelegates(ctx context.Context) ([]*gmail.Delegate, error)
	CreateDelegate(ctx context.Context, delegate *gmail.Delegate) (*gmail.Delegate, error)
	DeleteDelegate(ctx context.Context, delegateEmail string) error
}

GmailDelegateService manages Gmail account delegates.

type GmailDraftService added in v0.1.7

type GmailDraftService interface {
	ListDrafts(ctx context.Context, maxResults int64, pageToken string) (*gmail.ListDraftsResponse, error)
	GetDraft(ctx context.Context, draftID, format string) (*gmail.Draft, error)
	CreateDraft(ctx context.Context, draft *gmail.Draft) (*gmail.Draft, error)
	UpdateDraft(ctx context.Context, draftID string, draft *gmail.Draft) (*gmail.Draft, error)
	DeleteDraft(ctx context.Context, draftID string) error
	SendDraft(ctx context.Context, draft *gmail.Draft) (*gmail.Message, error)
}

GmailDraftService manages Gmail draft messages.

type GmailFilterService added in v0.1.7

type GmailFilterService interface {
	ListFilters(ctx context.Context) (*gmail.ListFiltersResponse, error)
	CreateFilter(ctx context.Context, filter *gmail.Filter) (*gmail.Filter, error)
	DeleteFilter(ctx context.Context, filterID string) error
}

GmailFilterService manages Gmail filters.

type GmailHandlerDeps

type GmailHandlerDeps = common.HandlerDeps[GmailService]

Type alias using generic types from common package.

type GmailLabelService added in v0.1.7

type GmailLabelService interface {
	ListLabels(ctx context.Context) (*gmail.ListLabelsResponse, error)
	GetLabel(ctx context.Context, labelID string) (*gmail.Label, error)
	CreateLabel(ctx context.Context, label *gmail.Label) (*gmail.Label, error)
	UpdateLabel(ctx context.Context, labelID string, label *gmail.Label) (*gmail.Label, error)
	DeleteLabel(ctx context.Context, labelID string) error
}

GmailLabelService manages Gmail labels.

type GmailMessageReader added in v0.1.7

type GmailMessageReader interface {
	ListMessages(ctx context.Context, query string, maxResults int64, pageToken string) (*gmail.ListMessagesResponse, error)
	GetMessage(ctx context.Context, messageID, format string) (*gmail.Message, error)
	GetAttachment(ctx context.Context, messageID, attachmentID string) (*gmail.MessagePartBody, error)
}

GmailMessageReader provides read access to Gmail messages.

type GmailMessageWriter added in v0.1.7

type GmailMessageWriter interface {
	SendMessage(ctx context.Context, message *gmail.Message) (*gmail.Message, error)
	ModifyMessage(ctx context.Context, messageID string, req *gmail.ModifyMessageRequest) (*gmail.Message, error)
	TrashMessage(ctx context.Context, messageID string) (*gmail.Message, error)
	UntrashMessage(ctx context.Context, messageID string) (*gmail.Message, error)
	BatchModifyMessages(ctx context.Context, req *gmail.BatchModifyMessagesRequest) error
}

GmailMessageWriter provides write/mutation operations on Gmail messages.

type GmailSendAsService added in v0.1.7

type GmailSendAsService interface {
	ListSendAs(ctx context.Context) ([]*gmail.SendAs, error)
	GetSendAs(ctx context.Context, sendAsEmail string) (*gmail.SendAs, error)
	CreateSendAs(ctx context.Context, sendAs *gmail.SendAs) (*gmail.SendAs, error)
	UpdateSendAs(ctx context.Context, sendAsEmail string, sendAs *gmail.SendAs) (*gmail.SendAs, error)
	DeleteSendAs(ctx context.Context, sendAsEmail string) error
	VerifySendAs(ctx context.Context, sendAsEmail string) error
}

GmailSendAsService manages Gmail send-as aliases.

type GmailService

GmailService defines the complete interface for Gmail operations. It is composed from focused sub-interfaces, each covering a single domain. This abstraction enables dependency injection and testing.

func NewGmailService

func NewGmailService(ctx context.Context, client *http.Client) (GmailService, error)

NewGmailService creates a GmailService from an authenticated HTTP client.

func ResolveGmailServiceOrError

func ResolveGmailServiceOrError(ctx context.Context, request mcp.CallToolRequest, deps *GmailHandlerDeps) (GmailService, *mcp.CallToolResult, bool)

ResolveGmailServiceOrError resolves a Gmail service, returning an MCP error result on failure.

type GmailSettingsService added in v0.1.7

type GmailSettingsService interface {
	GetProfile(ctx context.Context) (*gmail.Profile, error)
	GetVacationSettings(ctx context.Context) (*gmail.VacationSettings, error)
	UpdateVacationSettings(ctx context.Context, settings *gmail.VacationSettings) (*gmail.VacationSettings, error)
}

GmailSettingsService manages Gmail account settings.

type GmailTestFixtures

type GmailTestFixtures struct {
	DefaultEmail string
	MockService  *MockGmailService
	Deps         *GmailHandlerDeps
}

GmailTestFixtures provides pre-configured test data for Gmail tests.

func NewGmailTestFixtures

func NewGmailTestFixtures() *GmailTestFixtures

NewGmailTestFixtures creates a new test fixtures instance with default configuration.

type GmailThreadService added in v0.1.7

type GmailThreadService interface {
	GetThread(ctx context.Context, threadID, format string) (*gmail.Thread, error)
	ModifyThread(ctx context.Context, threadID string, req *gmail.ModifyThreadRequest) (*gmail.Thread, error)
	TrashThread(ctx context.Context, threadID string) (*gmail.Thread, error)
	UntrashThread(ctx context.Context, threadID string) (*gmail.Thread, error)
}

GmailThreadService manages Gmail conversation threads.

type MethodCall

type MethodCall = common.MethodCall

MethodCall is an alias to common.MethodCall for backward compatibility in tests.

type MockGmailService

type MockGmailService struct {
	// Data stores
	Messages  map[string]*gmail.Message
	Threads   map[string]*gmail.Thread
	Labels    map[string]*gmail.Label
	Drafts    map[string]*gmail.Draft
	Filters   map[string]*gmail.Filter
	Profile   *gmail.Profile
	Vacation  *gmail.VacationSettings
	SendAs    map[string]*gmail.SendAs
	Delegates map[string]*gmail.Delegate

	// Error to return (if set, operations return this error)
	Error error

	// MethodCalls records all method invocations for verification
	MethodCalls []MethodCall
	// contains filtered or unexported fields
}

MockGmailService is a mock implementation of GmailService for testing.

func NewMockGmailService

func NewMockGmailService() *MockGmailService

NewMockGmailService creates a new MockGmailService with initialized maps.

func (*MockGmailService) AddDelegate added in v0.1.6

func (m *MockGmailService) AddDelegate(delegate *gmail.Delegate)

AddDelegate adds a delegate to the mock store.

func (*MockGmailService) AddDraft

func (m *MockGmailService) AddDraft(draft *gmail.Draft)

AddDraft adds a draft to the mock store.

func (*MockGmailService) AddFilter

func (m *MockGmailService) AddFilter(filter *gmail.Filter)

AddFilter adds a filter to the mock store.

func (*MockGmailService) AddLabel

func (m *MockGmailService) AddLabel(label *gmail.Label)

AddLabel adds a label to the mock store.

func (*MockGmailService) AddMessage

func (m *MockGmailService) AddMessage(msg *gmail.Message)

AddMessage adds a message to the mock store.

func (*MockGmailService) AddSendAs added in v0.1.6

func (m *MockGmailService) AddSendAs(sendAs *gmail.SendAs)

AddSendAs adds a send-as alias to the mock store.

func (*MockGmailService) AddThread

func (m *MockGmailService) AddThread(thread *gmail.Thread)

AddThread adds a thread to the mock store.

func (*MockGmailService) BatchModifyMessages

func (m *MockGmailService) BatchModifyMessages(ctx context.Context, req *gmail.BatchModifyMessagesRequest) error

func (*MockGmailService) CreateDelegate added in v0.1.6

func (m *MockGmailService) CreateDelegate(ctx context.Context, delegate *gmail.Delegate) (*gmail.Delegate, error)

func (*MockGmailService) CreateDraft

func (m *MockGmailService) CreateDraft(ctx context.Context, draft *gmail.Draft) (*gmail.Draft, error)

func (*MockGmailService) CreateFilter

func (m *MockGmailService) CreateFilter(ctx context.Context, filter *gmail.Filter) (*gmail.Filter, error)

func (*MockGmailService) CreateLabel

func (m *MockGmailService) CreateLabel(ctx context.Context, label *gmail.Label) (*gmail.Label, error)

func (*MockGmailService) CreateSendAs added in v0.1.6

func (m *MockGmailService) CreateSendAs(ctx context.Context, sendAs *gmail.SendAs) (*gmail.SendAs, error)

func (*MockGmailService) DeleteDelegate added in v0.1.6

func (m *MockGmailService) DeleteDelegate(ctx context.Context, delegateEmail string) error

func (*MockGmailService) DeleteDraft

func (m *MockGmailService) DeleteDraft(ctx context.Context, draftID string) error

func (*MockGmailService) DeleteFilter

func (m *MockGmailService) DeleteFilter(ctx context.Context, filterID string) error

func (*MockGmailService) DeleteLabel

func (m *MockGmailService) DeleteLabel(ctx context.Context, labelID string) error

func (*MockGmailService) DeleteSendAs added in v0.1.6

func (m *MockGmailService) DeleteSendAs(ctx context.Context, sendAsEmail string) error

func (*MockGmailService) GetAttachment

func (m *MockGmailService) GetAttachment(ctx context.Context, messageID, attachmentID string) (*gmail.MessagePartBody, error)

func (*MockGmailService) GetDraft

func (m *MockGmailService) GetDraft(ctx context.Context, draftID, format string) (*gmail.Draft, error)

func (*MockGmailService) GetLabel

func (m *MockGmailService) GetLabel(ctx context.Context, labelID string) (*gmail.Label, error)

func (*MockGmailService) GetLastCall

func (m *MockGmailService) GetLastCall() *MethodCall

GetLastCall returns the last method call recorded.

func (*MockGmailService) GetMessage

func (m *MockGmailService) GetMessage(ctx context.Context, messageID, format string) (*gmail.Message, error)

func (*MockGmailService) GetProfile

func (m *MockGmailService) GetProfile(ctx context.Context) (*gmail.Profile, error)

func (*MockGmailService) GetSendAs added in v0.1.6

func (m *MockGmailService) GetSendAs(ctx context.Context, sendAsEmail string) (*gmail.SendAs, error)

func (*MockGmailService) GetThread

func (m *MockGmailService) GetThread(ctx context.Context, threadID, format string) (*gmail.Thread, error)

func (*MockGmailService) GetVacationSettings

func (m *MockGmailService) GetVacationSettings(ctx context.Context) (*gmail.VacationSettings, error)

func (*MockGmailService) ListDelegates added in v0.1.6

func (m *MockGmailService) ListDelegates(ctx context.Context) ([]*gmail.Delegate, error)

func (*MockGmailService) ListDrafts

func (m *MockGmailService) ListDrafts(ctx context.Context, maxResults int64, pageToken string) (*gmail.ListDraftsResponse, error)

func (*MockGmailService) ListFilters

func (*MockGmailService) ListLabels

func (*MockGmailService) ListMessages

func (m *MockGmailService) ListMessages(ctx context.Context, query string, maxResults int64, pageToken string) (*gmail.ListMessagesResponse, error)

func (*MockGmailService) ListSendAs added in v0.1.6

func (m *MockGmailService) ListSendAs(ctx context.Context) ([]*gmail.SendAs, error)

func (*MockGmailService) ModifyMessage

func (m *MockGmailService) ModifyMessage(ctx context.Context, messageID string, req *gmail.ModifyMessageRequest) (*gmail.Message, error)

func (*MockGmailService) ModifyThread

func (m *MockGmailService) ModifyThread(ctx context.Context, threadID string, req *gmail.ModifyThreadRequest) (*gmail.Thread, error)

func (*MockGmailService) Reset

func (m *MockGmailService) Reset()

Reset clears all data and method calls for a fresh test.

func (*MockGmailService) SendDraft

func (m *MockGmailService) SendDraft(ctx context.Context, draft *gmail.Draft) (*gmail.Message, error)

func (*MockGmailService) SendMessage

func (m *MockGmailService) SendMessage(ctx context.Context, message *gmail.Message) (*gmail.Message, error)

func (*MockGmailService) SetError

func (m *MockGmailService) SetError(errMsg string)

SetError sets the error that will be returned by all subsequent operations.

func (*MockGmailService) SetVacationSettings

func (m *MockGmailService) SetVacationSettings(settings *gmail.VacationSettings)

VacationSettings is an alias for Vacation field for convenience in tests.

func (*MockGmailService) TrashMessage

func (m *MockGmailService) TrashMessage(ctx context.Context, messageID string) (*gmail.Message, error)

func (*MockGmailService) TrashThread

func (m *MockGmailService) TrashThread(ctx context.Context, threadID string) (*gmail.Thread, error)

func (*MockGmailService) UntrashMessage

func (m *MockGmailService) UntrashMessage(ctx context.Context, messageID string) (*gmail.Message, error)

func (*MockGmailService) UntrashThread

func (m *MockGmailService) UntrashThread(ctx context.Context, threadID string) (*gmail.Thread, error)

func (*MockGmailService) UpdateDraft

func (m *MockGmailService) UpdateDraft(ctx context.Context, draftID string, draft *gmail.Draft) (*gmail.Draft, error)

func (*MockGmailService) UpdateLabel

func (m *MockGmailService) UpdateLabel(ctx context.Context, labelID string, label *gmail.Label) (*gmail.Label, error)

func (*MockGmailService) UpdateSendAs added in v0.1.6

func (m *MockGmailService) UpdateSendAs(ctx context.Context, sendAsEmail string, sendAs *gmail.SendAs) (*gmail.SendAs, error)

func (*MockGmailService) UpdateVacationSettings

func (m *MockGmailService) UpdateVacationSettings(ctx context.Context, settings *gmail.VacationSettings) (*gmail.VacationSettings, error)

func (*MockGmailService) VerifySendAs added in v0.1.6

func (m *MockGmailService) VerifySendAs(ctx context.Context, sendAsEmail string) error

func (*MockGmailService) WasMethodCalled

func (m *MockGmailService) WasMethodCalled(method string) bool

WasMethodCalled checks if a method was called.

type RealGmailService

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

RealGmailService wraps the actual Gmail API service.

func NewRealGmailService

func NewRealGmailService(service *gmail.Service) *RealGmailService

NewRealGmailService creates a new RealGmailService.

func (*RealGmailService) BatchModifyMessages

func (s *RealGmailService) BatchModifyMessages(ctx context.Context, req *gmail.BatchModifyMessagesRequest) error

func (*RealGmailService) CreateDelegate added in v0.1.6

func (s *RealGmailService) CreateDelegate(ctx context.Context, delegate *gmail.Delegate) (*gmail.Delegate, error)

func (*RealGmailService) CreateDraft

func (s *RealGmailService) CreateDraft(ctx context.Context, draft *gmail.Draft) (*gmail.Draft, error)

func (*RealGmailService) CreateFilter

func (s *RealGmailService) CreateFilter(ctx context.Context, filter *gmail.Filter) (*gmail.Filter, error)

func (*RealGmailService) CreateLabel

func (s *RealGmailService) CreateLabel(ctx context.Context, label *gmail.Label) (*gmail.Label, error)

func (*RealGmailService) CreateSendAs added in v0.1.6

func (s *RealGmailService) CreateSendAs(ctx context.Context, sendAs *gmail.SendAs) (*gmail.SendAs, error)

func (*RealGmailService) DeleteDelegate added in v0.1.6

func (s *RealGmailService) DeleteDelegate(ctx context.Context, delegateEmail string) error

func (*RealGmailService) DeleteDraft

func (s *RealGmailService) DeleteDraft(ctx context.Context, draftID string) error

func (*RealGmailService) DeleteFilter

func (s *RealGmailService) DeleteFilter(ctx context.Context, filterID string) error

func (*RealGmailService) DeleteLabel

func (s *RealGmailService) DeleteLabel(ctx context.Context, labelID string) error

func (*RealGmailService) DeleteSendAs added in v0.1.6

func (s *RealGmailService) DeleteSendAs(ctx context.Context, sendAsEmail string) error

func (*RealGmailService) GetAttachment

func (s *RealGmailService) GetAttachment(ctx context.Context, messageID, attachmentID string) (*gmail.MessagePartBody, error)

func (*RealGmailService) GetDraft

func (s *RealGmailService) GetDraft(ctx context.Context, draftID, format string) (*gmail.Draft, error)

func (*RealGmailService) GetLabel

func (s *RealGmailService) GetLabel(ctx context.Context, labelID string) (*gmail.Label, error)

func (*RealGmailService) GetMessage

func (s *RealGmailService) GetMessage(ctx context.Context, messageID, format string) (*gmail.Message, error)

func (*RealGmailService) GetProfile

func (s *RealGmailService) GetProfile(ctx context.Context) (*gmail.Profile, error)

func (*RealGmailService) GetSendAs added in v0.1.6

func (s *RealGmailService) GetSendAs(ctx context.Context, sendAsEmail string) (*gmail.SendAs, error)

func (*RealGmailService) GetThread

func (s *RealGmailService) GetThread(ctx context.Context, threadID, format string) (*gmail.Thread, error)

func (*RealGmailService) GetVacationSettings

func (s *RealGmailService) GetVacationSettings(ctx context.Context) (*gmail.VacationSettings, error)

func (*RealGmailService) ListDelegates added in v0.1.6

func (s *RealGmailService) ListDelegates(ctx context.Context) ([]*gmail.Delegate, error)

func (*RealGmailService) ListDrafts

func (s *RealGmailService) ListDrafts(ctx context.Context, maxResults int64, pageToken string) (*gmail.ListDraftsResponse, error)

func (*RealGmailService) ListFilters

func (*RealGmailService) ListLabels

func (*RealGmailService) ListMessages

func (s *RealGmailService) ListMessages(ctx context.Context, query string, maxResults int64, pageToken string) (*gmail.ListMessagesResponse, error)

func (*RealGmailService) ListSendAs added in v0.1.6

func (s *RealGmailService) ListSendAs(ctx context.Context) ([]*gmail.SendAs, error)

func (*RealGmailService) ModifyMessage

func (s *RealGmailService) ModifyMessage(ctx context.Context, messageID string, req *gmail.ModifyMessageRequest) (*gmail.Message, error)

func (*RealGmailService) ModifyThread

func (s *RealGmailService) ModifyThread(ctx context.Context, threadID string, req *gmail.ModifyThreadRequest) (*gmail.Thread, error)

func (*RealGmailService) SendDraft

func (s *RealGmailService) SendDraft(ctx context.Context, draft *gmail.Draft) (*gmail.Message, error)

func (*RealGmailService) SendMessage

func (s *RealGmailService) SendMessage(ctx context.Context, message *gmail.Message) (*gmail.Message, error)

func (*RealGmailService) TrashMessage

func (s *RealGmailService) TrashMessage(ctx context.Context, messageID string) (*gmail.Message, error)

func (*RealGmailService) TrashThread

func (s *RealGmailService) TrashThread(ctx context.Context, threadID string) (*gmail.Thread, error)

func (*RealGmailService) UntrashMessage

func (s *RealGmailService) UntrashMessage(ctx context.Context, messageID string) (*gmail.Message, error)

func (*RealGmailService) UntrashThread

func (s *RealGmailService) UntrashThread(ctx context.Context, threadID string) (*gmail.Thread, error)

func (*RealGmailService) UpdateDraft

func (s *RealGmailService) UpdateDraft(ctx context.Context, draftID string, draft *gmail.Draft) (*gmail.Draft, error)

func (*RealGmailService) UpdateLabel

func (s *RealGmailService) UpdateLabel(ctx context.Context, labelID string, label *gmail.Label) (*gmail.Label, error)

func (*RealGmailService) UpdateSendAs added in v0.1.6

func (s *RealGmailService) UpdateSendAs(ctx context.Context, sendAsEmail string, sendAs *gmail.SendAs) (*gmail.SendAs, error)

func (*RealGmailService) UpdateVacationSettings

func (s *RealGmailService) UpdateVacationSettings(ctx context.Context, settings *gmail.VacationSettings) (*gmail.VacationSettings, error)

func (*RealGmailService) VerifySendAs added in v0.1.6

func (s *RealGmailService) VerifySendAs(ctx context.Context, sendAsEmail string) error

Jump to

Keyboard shortcuts

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