Skip to content

Instantly share code, notes, and snippets.

@davidlesches
Last active January 1, 2016 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidlesches/c019f794fd099e1977f5 to your computer and use it in GitHub Desktop.
Save davidlesches/c019f794fd099e1977f5 to your computer and use it in GitHub Desktop.
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