Last active
January 28, 2016 20:29
-
-
Save AugustoPedraza/f56779a531f59df1dea9 to your computer and use it in GitHub Desktop.
Yodlee API Integration
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 Yodlee:Api::V1::RequestBuilder | |
METADATA_REQUESTS = | |
{ | |
get_user_info: { method: :get, path: '/user' }, | |
list_accounts: { method: :get, path: '/accounts' }, | |
create_user: { method: :post, path: '/user/register' } | |
} | |
attr_accessor :cobrand_session, :user_session | |
def method_missing(method, *args, &block) | |
super unless METADATA_REQUESTS.has_key?(method) | |
#Add here code to make a generic HTTP request, using the values of METADATA_REQUESTS and the value of headers. | |
end | |
def headers | |
#uses @cobrand_session and @user_session is needed | |
end | |
end | |
class Yodlee::Api::V1::Base | |
def for_user_session(user_id) | |
user_login unless SessionManager.valid?(user_id) | |
RequestBuilder.new.tap do |r| | |
r.cobrand_session = SessionManager.get | |
r.user_session = SessionManager.get_for_user(user_id) | |
end | |
end | |
def for_session | |
cobran_login unless SessionManager.still_alive? | |
RequestBuilder.new.tap do |r| | |
r.cobrand_session = SessionManager.get | |
end | |
end | |
private | |
def cobrand_login | |
#Similiar to #user_login method. | |
end | |
def user_login(user_id) | |
cobrand_login unless SessionManager.still_alive? | |
User.yodlee_data(user_id) #[user_id, user_pass] | |
response = for_session.login_user(user_id, user_pass) | |
SessionManager.set(user_id, response[:session]) | |
end | |
end | |
class Yodlee::Api::V1::User < Yodlee::Api::V1::Base | |
def get_info(user_id) | |
for_user_session(user_id).get_user_info(name: 'Visa') | |
end | |
def create | |
end | |
end | |
class Yodlee::Api::V1::Institution < Yodlee::Api::V1::Base | |
def list | |
for_session.get_institutions | |
end | |
end | |
class Yodlee::Api::V1::Account < Yodlee::Api::V1::Base | |
def list(user_id) | |
end | |
def get_info(user_id, account_id) | |
end | |
end | |
class Yodlee::Api::V1::Transaction < Yodlee::Api::V1::Base | |
def list(user_id) | |
end | |
def get_info(user_id, account_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment