Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/craigp/elixir-gmail
A Gmail API client for Elixir
https://github.com/craigp/elixir-gmail
elixir gmail gmail-api
Last synced: 28 days ago
JSON representation
A Gmail API client for Elixir
- Host: GitHub
- URL: https://github.com/craigp/elixir-gmail
- Owner: craigp
- License: mit
- Created: 2015-02-19T19:10:13.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-04-16T18:25:54.000Z (over 5 years ago)
- Last Synced: 2024-11-01T07:33:18.591Z (about 1 month ago)
- Topics: elixir, gmail, gmail-api
- Language: Elixir
- Homepage:
- Size: 302 KB
- Stars: 50
- Watchers: 4
- Forks: 22
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A simple Gmail REST API client for Elixir. (Email)
- fucking-awesome-elixir - gmail - A simple Gmail REST API client for Elixir. (Email)
- awesome-elixir - gmail - A simple Gmail REST API client for Elixir. (Email)
README
elixir-gmail
============
[![Build Status](https://secure.travis-ci.org/craigp/elixir-gmail.png?branch=master "Build Status")](http://travis-ci.org/craigp/elixir-gmail)
[![Coverage Status](https://coveralls.io/repos/craigp/elixir-gmail/badge.svg?branch=master&service=github)](https://coveralls.io/github/craigp/elixir-gmail?branch=master)
[![hex.pm version](https://img.shields.io/hexpm/v/gmail.svg)](https://hex.pm/packages/gmail)
[![hex.pm downloads](https://img.shields.io/hexpm/dt/gmail.svg)](https://hex.pm/packages/gmail)
[![Inline docs](http://inch-ci.org/github/craigp/elixir-gmail.svg?branch=master&style=flat)](http://inch-ci.org/github/craigp/elixir-gmail)A simple Gmail REST API client for Elixir.
You can find the hex package [here](https://hex.pm/packages/gmail), and the docs [here](http://hexdocs.pm/gmail).
You can find documentation for Gmail's API at https://developers.google.com/gmail/api/
## Usage
First, add the client to your `mix.exs` dependencies:
```elixir
def deps do
[{: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 in `mix.exs`:
```elixir
def application do
[applications: [:logger, :gmail]]
end
```Before you can work with mail for a user you'll need to start a process for them.
```elixir
{:ok, pid} = Gmail.User.start_mail("[email protected]", "user-refresh-token")
```When a user process starts it will automatically fetch a new access token for that user. Then
you can start playing with mail:```elixir
# fetch a list of threads
{:ok, threads, next_page_token} = Gmail.User.threads("[email protected]")# fetch the next page of threads using a page token
{:ok, _, _} = Gmail.User.threads("[email protected]", %{page_token: next_page_token})# fetch a thread by ID
{:ok, thread} = Gmail.User.thread("[email protected]", "1233454566")# fetch a list of labels
{:ok, labels} = Gmail.User.labels("[email protected]")
```Check the docs for a more complete list of functionality.
## API Support
* [ ] Threads
* [x] `get`
* [x] `list`
* [ ] `modify`
* [x] `delete`
* [x] `trash`
* [x] `untrash`
* [ ] Messages
* [x] `delete`
* [x] `get`
* [ ] `insert`
* [x] `list`
* [x] `modify`
* [ ] `send`
* [x] `trash`
* [x] `untrash`
* [ ] `import`
* [ ] `batchDelete`
* [x] Labels
* [x] `create`
* [x] `delete`
* [x] `list`
* [x] `update`
* [x] `get`
* [x] `update`
* [x] `patch`
* [ ] Drafts
* [x] `list`
* [x] `get`
* [x] `delete`
* [ ] `update`
* [ ] `create`
* [x] `send`
* [ ] `send` (with upload)
* [x] History
* [x] `list`
* [x] Attachments
* [x] `get` (thanks to @killtheliterate)## Auth
As of now the library doesn't do the initial auth generation for you; you'll
need to create an app on the [Google Developer
Console](https://console.developers.google.com/) to get a client ID and secret
and authorize a user to get an authorization code, which you can trade for an
access token.The library will however, when you supply a refresh token, use that to refresh
an expired access token for you. Take a look in the `dev.exs.sample` config
file to see what your config should look like.## TODO
* [x] Stop mocking HTTP requests and use [Bypass](https://github.com/PSPDFKit-labs/bypass) instead
* [x] Add format option when fetching threads
* [x] .. and messages
* [ ] .. and drafts
* [ ] Batched requests
* [ ] Document the config (specifically pool size)