Skip to content

Instantly share code, notes, and snippets.

@generalzhou
Created February 17, 2016 00:48
Show Gist options
  • Select an option

  • Save generalzhou/91232ab55f961b8c1192 to your computer and use it in GitHub Desktop.

Select an option

Save generalzhou/91232ab55f961b8c1192 to your computer and use it in GitHub Desktop.
require 'httparty'
require 'awesome_print'
public_token = ""
class PlaidAdapter
CLIENT_ID = ''
CLIENT_SECRET = ''
attr_reader :public_token
def initialize(public_token)
@public_token = public_token
end
def access_token
@access_token ||= begin
body = {
client_id: CLIENT_ID,
secret: CLIENT_SECRET,
public_token: public_token
}
HTTParty.post("https://tartan.plaid.com/exchange_token", body: body)["access_token"]
end
end
def transactions(account: nil)
body = {
client_id: CLIENT_ID,
secret: CLIENT_SECRET,
access_token: access_token
}
body.merge!(options: { account: account} ) if account
HTTParty.post("https://tartan.plaid.com/connect/get", body: body)
end
def upgrade(product: "auth") # if you got a token for the auth product instead of connect
body = {
client_id: CLIENT_ID,
secret: CLIENT_SECRET,
access_token: access_token,
upgrade_to: product
}
HTTParty.post("https://tartan.plaid.com/upgrade", body: body)
end
def auth_data
body = {
client_id: CLIENT_ID,
secret: CLIENT_SECRET,
access_token: access_token,
}
HTTParty.post("https://tartan.plaid.com/auth/get", body: body)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment