Created
March 11, 2016 02:10
-
-
Save eamonpenland/6bdb0fb008303bc2a233 to your computer and use it in GitHub Desktop.
This is the rails api endpoint of a YodleeAPI integration. All calls are restricted with jwt before_filter :authenticate_user_from_token in application controller still have some work to-do to finish up.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YodleeController < ApplicationController | |
# return json schema for bank login requirements | |
def login_requirements | |
# bank info saved in db search by param passed from front-end application | |
bank = Bank.find(params[:content_service_id]) | |
# use bank to make yodlee api call to return json schema | |
login_requirements = bank.yodlee.login_requirements | |
render json: login_requirements | |
end | |
#return banks 1-10 | |
def bank_info | |
bank = Bank.limit(10) | |
render json: bank | |
end | |
#use yodlee to login to users bank account and store data | |
def send_bank_info | |
user = current_user | |
# front-end application passes which bank user would like to create account with | |
bank = Bank.find(params[:content_service_id]) | |
#create new account with yodlee to auto gen yodlee username and password | |
account = Account.create!(user: user, bank: bank) | |
#bank credentials stored to variable to send to yodlee | |
bank_credentials = params['bankCredentials'] | |
#make yodlee account call to get users bank information | |
account.yodlee.create(bank_credentials) | |
end | |
# get users bank data | |
def retrieve_bank_data | |
user = current_user | |
account = user.accounts.first | |
#make yodlee call to return data to db | |
data = account.yodlee.transaction_data | |
#save data in jsonb datatype in postgres | |
yodlee_datum = YodleeDatum.create!({ | |
data: data | |
}) | |
yodlee_datum.reload | |
render json: yodlee_datum | |
end | |
## todo ## | |
# create sql queries to analyse data | |
# create new action to render lending decision | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment