Create a gist now

Instantly share code, notes, and snippets.

@davidlesches /importer.rb Secret
Last active Jan 1, 2016

What would you like to do?
Yodlee and Rails Implementation, Part 2: The Banks - app/models/yodlee/importer.rb
module Yodlee
class Importer < Base
def content_services *type
# types allowed: :all, OR a specific type, :bank, :credits, :miles, :loans etc
all_content_services.each do |bank|
container = bank.containerInfo.containerName.to_sym
next unless Array(type).include?(container) || type == :all
mfa = bank.key?('mfaType') ? bank.mfaType.typeName : 'none'
row = ::Bank.where(content_service_id: bank.contentServiceId).first_or_create
row.update_attributes!(
:content_service_id => bank.contentServiceId,
:home_url => bank.homeUrl,
:content_service_display_name => bank.contentServiceDisplayName,
:site_id => bank.siteId,
:site_display_name => bank.siteDisplayName,
:container => container,
:mfa => mfa
)
end
end
private
def all_content_services
query({
:endpoint => '/jsonsdk/ContentServiceTraversal/getAllContentServices',
:method => :POST,
:params => {
:cobSessionToken => cobrand_token,
:notrim => true
}
})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment