Skip to content

An API for gmail message search and classification using Google's Gmail API

License

Notifications You must be signed in to change notification settings

rdparedes/linelos

Repository files navigation

Linelos

Linelos is an api made in Clojure that uses Google Gmail API to search for the user emails, then it extracts data using regexes and returns a json object.

It also takes advantage of Clojure's interop with Java to use the gmail java library. So in the end you take the compatibility of Java with the functional programming goodness of Clojure.

What this program does

Supose you have a bunch of emails from your bank with this format:

From:notifications@thebank.com
===============================

Hello Roberto,

You have made a payment with your account # 123

Vendor: Some vendor
Date of transaction 05/02/2019 at 16:14
Amount $ 1.00.

You can send Linelos a request with a query param similar to what you would search inside your gmail client

curl -XGET localhost:3478/transactions?query=from:(notifications@thebank.com)%20payment

The message parser will process each email that matches the query and extract the fields according to the provided regexes. You will end with a response that looks like this:

{
  "transacciones": [
    {
      "vendor": "Some vendor",
      "date": "2019-02-05T16:14:00Z",
      "amount": 1
    },
    {
      "vendor": "Some other vendor",
      "date": "2019-03-01T11:11:00Z",
      "amount": 9001
    }
  ]
}

What's Next

  • Currently, only one format of message is supported. That is just the basic idea put into workable code, but ideally the parsing and regex stuff would be provided with the request.
  • Documentation for the API.

Setup

  • Create a new API from Google if you don't have one yet and download your client secret.
  • Copy your client_secret.json into the root directory of the project.

Configure your local environment

Creating a Docker container for production

  • Copy .lein-env.example to .lein-env.prod and edit it.
  • Run docker build -t linelos .

Development Commands

Command Description
lein ring server-headless [port] Start server locally
lein test:unit Run unit tests
lein test:functional Run functional tests
lein test Run all tests
lein test:coverage Run tests with code coverage report
lein kibit Analyze code for more idiomatic functions or macros
lein cljfmt fix Run linter and fix files
lein check Run all checks and tests

Useful docs

About

An API for gmail message search and classification using Google's Gmail API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published