Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A Gmail API client for Elixir

License

NotificationsYou must be signed in to change notification settings

craigp/elixir-gmail

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build StatusCoverage Statushex.pm versionhex.pm downloadsInline docs

A simple Gmail REST API client for Elixir.

You can find the hex packagehere, and the docshere.

You can find documentation for Gmail's API athttps://developers.google.com/gmail/api/

Usage

First, add the client to yourmix.exs dependencies:

defdepsdo[{:gmail,"~> 0.1"}]end

Then run$ mix do deps.get, compile to download and compile your dependencies.

Finally, add the:gmail application as your list of applications inmix.exs:

defapplicationdo[applications:[:logger,:gmail]]end

Before you can work with mail for a user you'll need to start a process for them.

{:ok,pid}=Gmail.User.start_mail("user@example.com","user-refresh-token")

When a user process starts it will automatically fetch a new access token for that user. Thenyou can start playing with mail:

# fetch a list of threads{:ok,threads,next_page_token}=Gmail.User.threads("user@example.com")# fetch the next page of threads using a page token{:ok,_,_}=Gmail.User.threads("user@example.com",%{page_token:next_page_token})# fetch a thread by ID{:ok,thread}=Gmail.User.thread("user@example.com","1233454566")# fetch a list of labels{:ok,labels}=Gmail.User.labels("user@example.com")

Check the docs for a more complete list of functionality.

API Support

  • Threads
    • get
    • list
    • modify
    • delete
    • trash
    • untrash
  • Messages
    • delete
    • get
    • insert
    • list
    • modify
    • send
    • trash
    • untrash
    • import
    • batchDelete
  • Labels
    • create
    • delete
    • list
    • update
    • get
    • update
    • patch
  • Drafts
    • list
    • get
    • delete
    • update
    • create
    • send
    • send (with upload)
  • History
    • list
  • Attachments
    • get (thanks to @killtheliterate)

Auth

As of now the library doesn't do the initial auth generation for you; you'llneed to create an app on theGoogle DeveloperConsole to get a client ID and secretand authorize a user to get an authorization code, which you can trade for anaccess token.

The library will however, when you supply a refresh token, use that to refreshan expired access token for you. Take a look in thedev.exs.sample configfile to see what your config should look like.

TODO

  • Stop mocking HTTP requests and useBypass instead
  • Add format option when fetching threads
  • .. and messages
  • .. and drafts
  • Batched requests
  • Document the config (specifically pool size)

About

A Gmail API client for Elixir

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors5

Languages


[8]ページ先頭

©2009-2025 Movatter.jp