Documentation
¶
Index ¶
- func ExchangeAuthCode(ctx context.Context, config *oauth2.Config, code string) (*oauth2.Token, error)
- func GetAuthURL(config *oauth2.Config) string
- func GetConfigDir() (string, error)
- func GetCredentialsPath() (string, error)
- func GetOAuthConfig() (*oauth2.Config, error)
- func ShortenPath(path string) string
- type Attachment
- type Client
- func (c *Client) DownloadAttachment(messageID string, attachmentID string) ([]byte, error)
- func (c *Client) DownloadInlineAttachment(messageID string, partID string) ([]byte, error)
- func (c *Client) FetchLabels() error
- func (c *Client) GetAttachments(messageID string) ([]*Attachment, error)
- func (c *Client) GetLabelName(labelID string) string
- func (c *Client) GetLabels() []*gmail.Label
- func (c *Client) GetMessage(messageID string, includeBody bool) (*Message, error)
- func (c *Client) GetThread(id string) ([]*Message, error)
- func (c *Client) SearchMessages(query string, maxResults int64) ([]*Message, int, error)
- type GmailClientInterface
- type LabelResolver
- type Message
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExchangeAuthCode ¶
func ExchangeAuthCode(ctx context.Context, config *oauth2.Config, code string) (*oauth2.Token, error)
ExchangeAuthCode exchanges an authorization code for a token Deprecated: Use auth.ExchangeAuthCode() instead
func GetAuthURL ¶
GetAuthURL returns the OAuth authorization URL Deprecated: Use auth.GetAuthURL() instead
func GetConfigDir ¶
GetConfigDir returns the configuration directory path Deprecated: Use auth.GetConfigDir() instead
func GetCredentialsPath ¶
GetCredentialsPath returns the path to credentials.json Deprecated: Use auth.GetCredentialsPath() instead
func GetOAuthConfig ¶
GetOAuthConfig loads OAuth config from credentials file Deprecated: Use auth.GetOAuthConfig() instead
func ShortenPath ¶ added in v1.0.19
ShortenPath replaces the home directory prefix with ~ for display purposes. Deprecated: Use auth.ShortenPath() instead
Types ¶
type Attachment ¶
type Attachment struct {
Filename string `json:"filename"`
MimeType string `json:"mimeType"`
Size int64 `json:"size"`
AttachmentID string `json:"attachmentId,omitempty"`
PartID string `json:"partId"`
IsInline bool `json:"isInline"`
}
Attachment represents metadata about an email attachment
type Client ¶
type Client struct {
Service *gmail.Service
UserID string
// contains filtered or unexported fields
}
Client wraps the Gmail API service
func (*Client) DownloadAttachment ¶
DownloadAttachment downloads a single attachment by message ID and attachment ID
func (*Client) DownloadInlineAttachment ¶
DownloadInlineAttachment downloads an attachment that has inline data
func (*Client) FetchLabels ¶
FetchLabels retrieves and caches all labels from the Gmail account
func (*Client) GetAttachments ¶
func (c *Client) GetAttachments(messageID string) ([]*Attachment, error)
GetAttachments retrieves attachment metadata for a message
func (*Client) GetLabelName ¶
GetLabelName resolves a label ID to its display name
func (*Client) GetMessage ¶
GetMessage retrieves a single message by ID
type GmailClientInterface ¶ added in v1.0.19
type GmailClientInterface interface {
// GetMessage retrieves a single message by ID
GetMessage(messageID string, includeBody bool) (*Message, error)
// SearchMessages searches for messages matching the query
SearchMessages(query string, maxResults int64) ([]*Message, int, error)
// GetThread retrieves all messages in a thread
GetThread(id string) ([]*Message, error)
// FetchLabels retrieves and caches all labels from the Gmail account
FetchLabels() error
// GetLabelName resolves a label ID to its display name
GetLabelName(labelID string) string
// GetLabels returns all cached labels
GetLabels() []*gmail.Label
// GetAttachments retrieves attachment metadata for a message
GetAttachments(messageID string) ([]*Attachment, error)
// DownloadAttachment downloads a single attachment by message ID and attachment ID
DownloadAttachment(messageID string, attachmentID string) ([]byte, error)
// DownloadInlineAttachment downloads an attachment that has inline data
DownloadInlineAttachment(messageID string, partID string) ([]byte, error)
}
GmailClientInterface defines the interface for Gmail client operations. This enables unit testing through mock implementations.
type LabelResolver ¶
LabelResolver is a function that resolves a label ID to its display name
type Message ¶
type Message struct {
ID string `json:"id"`
ThreadID string `json:"threadId"`
Subject string `json:"subject"`
From string `json:"from"`
To string `json:"to"`
Date string `json:"date"`
Snippet string `json:"snippet"`
Body string `json:"body,omitempty"`
Attachments []*Attachment `json:"attachments,omitempty"`
Labels []string `json:"labels,omitempty"`
Categories []string `json:"categories,omitempty"`
}
Message represents a simplified email message