Skip to content

A simple wrapper ontop of the Gmail API for Google App Engine (Don't use outside NewsAI codebase yet)

License

Notifications You must be signed in to change notification settings

news-ai/go-gmail

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-gmail

A simple wrapper ontop of the Gmail API. This library is useful only after you have an access token from the user.

Gmail API

The Gmail REST API is structured by:

  1. Drafts
  2. History
  3. Labels
  4. Messages
  5. Message Attachments
  6. Threads
  7. Users

The rate limit will be set using:

  1. Daily Usage at 1,000,000,000 quota units per day
  2. Per User Rate Limit at 250 quota units per user per second

Documentation

Get the package, and install it:

go get github.com/abhiagarwal/go-gmail, import Gmail "github.com/abhiagarwal/go-gmail"

All of the methods below require an access token for a single user.

1. Drafts

2. History

3. Labels

4. Messages

Get the emails of the user.

var gmail Gmail.Gmail
gmail.AccessToken = AccessToken
allResults, err := gmail.GetEmails(100)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(allResults)
return

Get a single email of the user given an Id.

var gmail Gmail.Gmail
gmail.AccessToken = AccessToken
allResults, err := gmail.GetEmails(100)
if err != nil {
	fmt.Println(err)
	return
}
singleResult, err := gmail.GetEmailById(allResults.Messages[0].ID)
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(singleResult)
return

5. Message Attachments

Get attachment from a specific email that's received by a user.

var gmail Gmail
gmail.AccessToken = AccessToken
singleAttachment, err := gmail.GetAttachmentById("", "")
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(singleAttachment)

6. Threads

7. Users

Get the profile of the user.

var gmail Gmail.Gmail
gmail.AccessToken = AccessToken
singleResult, err := gmail.GetProfile()
if err != nil {
	fmt.Println(err)
	return
}
fmt.Println(singleResult)

About

A simple wrapper ontop of the Gmail API for Google App Engine (Don't use outside NewsAI codebase yet)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%