Documentation ¶
Overview ¶
Package gmailutils provides helpers for Gmail API.
Index ¶
- Constants
- func FetchConcurent(ctx context.Context, srv *gmail.Service, user, query string, concurentReq int) ([]*gmail.Message, error)
- func FetchLabels(ctx context.Context, client *http.Client) (*gmail.ListLabelsResponse, error)
- func FormatAsID(label string) string
- func MessageTextBody(payload *gmail.MessagePart) ([]byte, error)
- func ModifyMsgsDelLabel(srv *gmail.Service, user string, messages []*gmail.Message, label string)
- func NewClient(needWriteAccess bool) *http.Client
- func NormalizeAndSplit(subj string) []string
- func PrintAllLabels(srv *gmail.Service, user string) []*gmail.Label
- func ReadLblFixturesJSON(name string) []*gmail.Label
- func ReadMsgFixturesJSON(name string) []*gmail.Message
- func Subject(m *gmail.MessagePart) string
Constants ¶
const Instructions = `` /* 301-byte string literal not displayed */
Instructions are user manual for OAuth app configuration from Gmail.
Variables ¶
This section is empty.
Functions ¶
func FetchConcurent ¶
func FetchConcurent(ctx context.Context, srv *gmail.Service, user, query string, concurentReq int) ([]*gmail.Message, error)
FetchConcurent fetches matching messages for a given query in paralle from the Gmail. It is blocking, but doing N concurrent fetche requests. TODO(bzz): make it a method on the struct, that holds srv instance.
func FetchLabels ¶
FetchLabels fetches the list of labels, as returned by Gmail using authorized http Client.
func FormatAsID ¶
FormatAsID formats human-readable lable as ID, consumable by Gmail API.
func MessageTextBody ¶
MessageTextBody returns the text (if any) of a given message ID
func ModifyMsgsDelLabel ¶
ModifyMsgsDelLabel batch-deletes a label from all the given messages. TODO(bzz): move user to a const in this package
func NewClient ¶
NewClient a client configured with OAuth using 'credentials.json' and a 'token.json'.
func NormalizeAndSplit ¶
NormalizeAndSplit normalizes subj format and split it to type/source.
func PrintAllLabels ¶
func PrintAllLabels(srv *gmail.Service, user string) []*gmail.Label
PrintAllLabels prints all labels for a given user.
func ReadLblFixturesJSON ¶
func ReadLblFixturesJSON(name string) []*gmail.Label
ReadLblFixturesJSON reads Gmail labels from a given JSON file.
func ReadMsgFixturesJSON ¶
func ReadMsgFixturesJSON(name string) []*gmail.Message
ReadMsgFixturesJSON reads Gmail messages from a given JSON file.
Types ¶
This section is empty.