Create a gist now

Instantly share code, notes, and snippets.

@davidlesches /user.rb Secret
Created Dec 27, 2013

What would you like to do?
Yodlee and Rails Implementation, Part 4: User Management - app/models/yodlee/user.rb
module Yodlee
class User < Base
attr_reader :user
def initialize user
@user = user
end
def token
@token ||= login
end
def register
response = query({
:endpoint => '/jsonsdk/UserRegistration/register3',
:method => :POST,
:params => {
:cobSessionToken => cobrand_token,
:'userCredentials.loginName' => user.yodlee_username,
:'userCredentials.password' => user.yodlee_password,
:'userCredentials.objectInstanceType' => 'com.yodlee.ext.login.PasswordCredentials',
:'userProfile.emailAddress' => user.yodlee_username
}
})
@token = response.userContext.conversationCredentials.sessionToken
end
def login
response = query({
:endpoint => '/authenticate/login',
:method => :POST,
:params => {
:cobSessionToken => cobrand_token,
:login => user.yodlee_username,
:password => user.yodlee_password
}
})
@token = response.userContext.conversationCredentials.sessionToken
end
def destroy
response = query({
:endpoint => '/jsonsdk/UserRegistration/unregister',
:method => :POST,
:params => {
:cobSessionToken => cobrand_token,
:userSessionToken => token
}
})
@token = nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment