gmailutil

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GmailDateFormat  = "2006/01/02"
	ReferenceURL     = "https://developers.google.com/gmail/api/v1/reference"
	TutorialURLGO    = "https://developers.google.com/gmail/api/quickstart/go"
	ListApiReference = "https://developers.google.com/gmail/api/v1/reference/users/messages/list"
	ListApiExample   = "https://stackoverflow.com/questions/43057478/google-api-go-client-listing-messages-w-label-and-fetching-header-fields"
	FilteringExample = "https://developers.google.com/gmail/api/guides/filtering"
	FilterRules      = "https://support.google.com/mail/answer/7190"

	CategoryForums     = "forums"
	CategoryPromotions = "promotions"
	CategorySocial     = "social"
	CategoryUpdates    = "updates"

	ExampleRule1 = "category:promotions older_than:2y"
	ExampleRule2 = "category:updates older_than:2y"
	ExampleRule3 = "category:social older_than:2y"
)
View Source
const UserIDMe = "me"

Variables

View Source
var (
	ErrGmailServiceCannotBeNil  = errors.New("gmail service cannot be nil")
	ErrGmailUserIDCannotBeEmpty = errors.New("gmail userid cannot be empty")
)

Functions

func GetLabelNames

func GetLabelNames(client *http.Client) ([]string, error)

func NewUsersService

func NewUsersService(client *http.Client) (*gmail.UsersService, error)

Types

type GmailService

type GmailService struct {
	APICallOptions []googleapi.CallOption
	Service        *gmail.Service
	UsersService   *gmail.UsersService
	MessagesAPI    MessagesAPI
	// contains filtered or unexported fields
}

func NewGmailService

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

type MessagesAPI added in v0.4.0

type MessagesAPI struct {
	GmailService *GmailService
}

func (*MessagesAPI) BatchDeleteMessages added in v0.4.0

func (mapi *MessagesAPI) BatchDeleteMessages(userID string, messageIDs []string) error

func (*MessagesAPI) DeleteMessagesFrom added in v0.4.0

func (mapi *MessagesAPI) DeleteMessagesFrom(rfc822s []string) (int, int, error)

func (*MessagesAPI) GetMessage added in v0.4.0

func (mapi *MessagesAPI) GetMessage(userID, messageID string) (*gmail.Message, error)

func (*MessagesAPI) GetMessagesByCategory added in v0.4.0

func (mapi *MessagesAPI) GetMessagesByCategory(userID, categoryName string, getAll bool) ([]*gmail.Message, error)

func (*MessagesAPI) GetMessagesFrom added in v0.4.0

func (mapi *MessagesAPI) GetMessagesFrom(rfc822 string) (*gmail.ListMessagesResponse, error)

func (*MessagesAPI) GetMessagesList added in v0.4.0

func (mapi *MessagesAPI) GetMessagesList(opts MessagesListOpts) (*gmail.ListMessagesResponse, error)

func (*MessagesAPI) InflateMessages added in v0.4.0

func (mapi *MessagesAPI) InflateMessages(userID string, msgMetas []*gmail.Message) ([]*gmail.Message, error)

type MessagesListOpts

type MessagesListOpts struct {
	UserId               string
	IncludeSpamTrash     bool
	LabelIds             []string
	MaxResults           uint64
	PageToken            string
	Query                MessagesListQueryOpts
	Fields               []googleapi.Field
	IfNoneMatchEntityTag string
}

func (*MessagesListOpts) Condense

func (opts *MessagesListOpts) Condense()

func (*MessagesListOpts) Inflate

func (opts *MessagesListOpts) Inflate()

type MessagesListQueryOpts

type MessagesListQueryOpts struct {
	Category    string
	In          string
	From        string
	RFC822msgid string
	After       time.Time
	Before      time.Time
	OlderThan   string // #(mdy)
	NewerThan   string // #(mdy)
	Interval    timeutil.Interval
}

func (*MessagesListQueryOpts) Encode

func (opts *MessagesListQueryOpts) Encode() string

func (*MessagesListQueryOpts) TrimSpace

func (opts *MessagesListQueryOpts) TrimSpace()

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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