Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
allancalix committed Sep 9, 2021
0 parents commit bd451f9
Show file tree
Hide file tree
Showing 32 changed files with 8,383 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
jobs:
release:
name: Publish release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATESIO_TOKEN }}
- uses: softprops/action-gh-release@v1
21 changes: 21 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Test
on:
push:
branches:
- main
jobs:
linux:
name: Linux Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
env:
PLAID_SECRET: ${{ secrets.PLAID_SECRET }}
PLAID_CLIENT_ID: ${{ secrets.PLAID_CLIENT_ID }}
with:
command: test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
37 changes: 37 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "rplaid"
version = "0.2.0"
authors = ["Allan Calix <[email protected]>"]
edition = "2018"
description = """
An async client library for Plaid APIs.
"""
homepage = "https://github.com/allancalix/rplaid"
documentation = "https://docs.rs/rplaid"
repository = "https://github.com/allancalix/rplaid"
readme = "README.md"
keywords = ["plaid", "api", "client", "async", "finance"]
categories = ["api-bindings"]
exclude = ["/.github/*"]
license = "MIT"

[features]
default = ["streams"]
bare = []
streams = ["async-stream", "futures-core", "futures-util"]

[dependencies]
http-client = "6.5.1"
tokio = { version = "1", features = ["macros"] }
http-types = "2.12.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0.28"
async-stream = { version = "0.3.2", optional = true }
futures-core = { version = "0.3.17", optional = true }
futures-util = { version = "0.3.17", optional = true }

[dev-dependencies]
insta = { version = "1.7.2", features = ["redactions"] }
tokio = { version = "1", features = ["test-util", "rt-multi-thread"] }
http-client = { version = "6.5.1", features = ["curl_client", "rustls"] }
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Allan Calix

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# rplaid

[![crates.io](https://img.shields.io/crates/v/rplaid.svg)](https://crates.io/crates/rplaid)
[![Released API docs](https://docs.rs/rplaid/badge.svg)](https://docs.rs/rplaid)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
[![GHA Build Status](https://github.com/allancalix/rplaid/actions/workflows/test.yaml/badge.svg?branch=main)](https://github.com/allancalix/rplaid/actions?query=workflow%3ATEST)

**rplaid** is an async client for the [Plaid API](https://plaid.com/docs/api/).
With minimal features, the client is meant to be extensible and lightweight.
Additional features can be enabled to improve ergonomics of the API at the
cost of additional dependencies.

The goal is to provide expressive bindings that provide sensible defaults where
possible for ease of use.

See official [API docs](https://plaid.com/docs/) for more information about
endpoints or specific products.

__These are not official Plaid bindings.__

```rust
use rplaid::client::{Builder, Credentials};
use rplaid::model::*;

#[tokio::main]
async fn main() {
let client = Builder::new()
.with_credentials(Credentials {
client_id: std::env::var("PLAID_CLIENT_ID").unwrap(),
secret: std::env::var("PLAID_SECRET").unwrap(),
})
.build();
let institutions = client
.get_institutions(&InstitutionsGetRequest {
count: 10,
offset: 0,
country_codes: &["US"],
options: None,
})
.await
.unwrap();

println!("{:?}", institutions);
}
```

## Glossary
* Item - A Item represents a connection to a single financial instution.
Typically links are associated with a pair of credentials and an
`access_token`. Items are associated to one or more accounts.

* Link - Link is a client-side component that Plaid provides to link to accounts.
See https://plaid.com/docs/link/#introduction-to-link for more
information.

* Account - An account is a financial account that is linked to an Item. An item,
or financial institution, may have multiple accounts for a single
user (e.g. a checking account and a credit account).

* Product - Entities with services offered by Plaid, see
https://plaid.com/docs/api/products/ for more information.

## Features
* Idiomatic futures generator for easily reading multiple pages of transactions.
* Extensible HttpClient interfaces supports multiple HTTP clients with minimal
effort (surf, H1, and reqwest). The trait can also be implemented to have full
control over the HTTP client used.
* Rust types, including variant types, for most API return types.

## Limitations
Some endpoints are production specific or beta products and are not yet
supported by the client.

For a breakdown of endpoint support visit:
https://docs.google.com/spreadsheets/d/1xqUXdfllo37Rx5MVrQODbVqNQvuktiCVL5Uh8y9mYYw

## License
[MIT](LICENSE)
23 changes: 23 additions & 0 deletions examples/builder.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use rplaid::client::{Builder, Credentials};
use rplaid::model::*;

#[tokio::main]
async fn main() {
let client = Builder::new()
.with_credentials(Credentials {
client_id: std::env::var("PLAID_CLIENT_ID").unwrap(),
secret: std::env::var("PLAID_SECRET").unwrap(),
})
.build();
let institutions = client
.get_institutions(&InstitutionsGetRequest {
count: 10,
offset: 0,
country_codes: &["US"],
options: None,
})
.await
.unwrap();

println!("{:?}", institutions);
}
25 changes: 25 additions & 0 deletions examples/curl_client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use http_client::isahc::IsahcClient;
use rplaid::client::{Builder, Credentials};
use rplaid::model::*;

#[tokio::main]
async fn main() {
let client = Builder::new()
.with_credentials(Credentials {
client_id: std::env::var("PLAID_CLIENT_ID").unwrap(),
secret: std::env::var("PLAID_SECRET").unwrap(),
})
.with_http_client(IsahcClient::new())
.build();
let institutions = client
.get_institutions(&InstitutionsGetRequest {
count: 10,
offset: 0,
country_codes: &["US"],
options: None,
})
.await
.unwrap();

println!("{:?}", institutions);
}
Loading

0 comments on commit bd451f9

Please sign in to comment.