bypotatoes / plaid-ruby

Ruby bindings for Plaid

Home Page:https://plaid.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

plaid-ruby

Ruby gem wrapper for the Plaid API. For more details, please see the full API documentation.

Installation

Plaid is available through Rubygems and can be installed via:

$ gem install plaid

or add it to your Gemfile like this:

gem 'plaid'

Usage

require 'plaid'

Global Configuration

Pop this into your environment file.

Plaid.config do |config|
  config.customer_id = keys[CUSTOMER_ID]
  config.secret = keys[SECRET]
end

Now create a YML file that has your CUSTOMER_ID and your SECRET provided by Plaid.

There are two different requests one can make using the gem: Call and Customer.

Call Methods

Call is anything that does not require an access_token.

  1. add_account_auth( type, username, password, email)
    Returns a hash with keys: code, access_token, accounts, transactions all with embedded json from Plaid. The account information is detailed and has full account and routing numbers, however, you will not receive transactions
# if(code == 200) {returns {[:code => 'x'],[:access_token => 'y'],[:accounts => 'z']}
# Note: 'x','y','z' are all formatted as json.


2) add_account_connect( type , username , password , email ) <br>
    Returns a hash with keys: code, access_token, accounts, transactions all with embedded json from Plaid.
    The account information returned doesn't contain full account and routing numbers
```ruby
# if(code == 200) {returns {[:code => 'x'],[:access_token => 'y'],[:accounts => 'z'],[:transactions => 'a']}
# Note: 'x','y','z','a' are all formatted as json. 

Ex)
  new_account = Plaid.call.add_account_connect("amex","plaid_test","plaid_good","test@gmail.com") 
  puts new_account[:code]
  "200"
  1. get_place( id )
    Returns a hash with keys: entity and location all with embedded json from Plaid.
# if(code == 200) {returns {[:entity => 'x'],[:location => 'y']}
# Note: 'x','y' are formatted as json. 

Ex)
  location_deets = Plaid.call.get_place("52a77fea4a2eab775f004109") 
  puts new_account[:location]["address"]
  "125 Main St"

Customer Methods

Customer defines anything that requires an access_token.

  1. mfa_auth_step( access_token , code )
    Returns a hash with keys: code, access_token, accounts, transactions all with embedded json from Plaid.
# if(code == 200) {returns {[:code => 'x'],[:access_token => 'y'],[:accounts => 'z'],[:transactions => 'a']}
# Note: 'x','y','z','a' are all formatted as json. 

Ex)
  new_account = Plaid.customer.mfa_step("test","tomato") 
  puts new_account[:code]
  "200"
  1. mfa_connect_step( access_token , code )
    Returns a hash with keys: code, access_token, accounts, transactions all with embedded json from Plaid.
# if(code == 200) {returns {[:code => 'x'],[:access_token => 'y'],[:accounts => 'z'],[:transactions => 'a']}
# Note: 'x','y','z','a' are all formatted as json. 

Ex)
  new_account = Plaid.customer.mfa_auth_step("test","tomato") 
  puts new_account[:code]
  "200"

To attain transactions you have to use mfa_connect, and mfa_connect_step 3) get_transactions( access_token )
Returns a hash with key transaction

# if(code == 200) {returns {[:transaction => 'x']}
# Note: 'x' is formatted as json. 

Ex)
  transactions = Plaid.customer.get_transactions("test") 
  puts transactions[:transactions][1]["amount"]
  1334.99
  1. delete_account( access_token )
    Returns a hash with key code
Ex)
  message = Plaid.customer.delete_account("test") 
  puts message[:code]
  "200"

Requirements

  • Ruby 2.0.0 or higher

About

Ruby bindings for Plaid

https://plaid.com

License:MIT License


Languages

Language:Ruby 100.0%