Class: IntuitIdsAggcat::Client::Services
- Inherits:
-
Object
- Object
- IntuitIdsAggcat::Client::Services
- Defined in:
- lib/intuit_ids_aggcat/client/services.rb
Class Method Summary collapse
-
.challenge_response(institution_id, username, response, challenge_session_id, challenge_node_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Given a username, response text, challenge session ID and challenge node ID, passes the credentials to Intuit to begin aggregation.
-
.delete_account(username, account_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Deletes the a specific account for a customer from aggregation at Intuit.
-
.delete_customer(username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Deletes the customer’s accounts from aggregation at Intuit.
-
.discover_account_data_to_hash(daa) ⇒ Object
Helper method for parsing discover account response data.
-
.discover_and_add_accounts_with_credentials(institution_id, username, creds_hash, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 30) ⇒ Object
Discovers and adds accounts using credentials institution_id is the ID of the institution, username is the ID for this customer’s accounts at Intuit and must be used for future requests, creds_hash is a hash object of key value pairs used for authentication If oauth_token is not provided, new tokens will be provisioned using the username provided Returns a hash produced by discover_account_data_to_hash with the following keys: discover_response : hash including the following keys: response_code: HTTP response code from Intuit response_xml : XML returned by Intuit accounts : Ruby hash with accounts if returned by discover call challenge_type : text description of the type of challenge requested, if applicable “none” | “choice” | “image” | “text” challenge : Ruby hash with the detail of the challenge if applicable challenge_session_id: challenge session ID to pass to challenge_response if this is a challenge challenge_node_id : challenge node ID to pass to challenge_response if this is a challenge description : text description of the result of the discover request.
-
.get_account(username, account_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Get a specific account for a customer from aggregation at Intuit.
-
.get_account_transactions(username, account_id, start_date, end_date = nil, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Get transactions for a specific account and timeframe.
-
.get_customer_accounts(username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Gets all accounts for a customer.
-
.get_institution_detail(id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens("default"), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Gets the institution details for id.
-
.get_institutions(oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens("default"), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Gets all institutions supported by Intuit.
-
.get_login_accounts(login_id, username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Gets accounts for a specific customer login_id.
- .initialize ⇒ Object
-
.oauth_delete_request(url, oauth_token_info, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120) ⇒ Object
Helper method to issue delete requests.
-
.oauth_get_request(url, oauth_token_info, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120) ⇒ Object
Helper method to issue get requests.
-
.oauth_post_request(url, body, oauth_token_info, headers = {}, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120) ⇒ Object
Helper method to issue post requests.
-
.oauth_put_request(url, oauth_token_info, body = nil, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120) ⇒ Object
Helper method to issue put requests.
-
.update_credentials_data_to_hash(daa) ⇒ Object
Helper method for parsing discover credential update response data.
-
.update_institution_login_explicit_refresh(login_id, username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Explicitly refreshes the customer account with new credentials at an institution.
-
.update_institution_login_with_credentials(login_id, username, creds_hash, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Updates an existing customer account with new credentials at an institution Response can include an MFA challenge; see the return values for discover_and_add_accounts_with_credentials for more information on possible responses.
Class Method Details
.challenge_response(institution_id, username, response, challenge_session_id, challenge_node_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Given a username, response text, challenge session ID and challenge node ID, passes the credentials to Intuit to begin aggregation
104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 104 def challenge_response institution_id, username, response, challenge_session_id, challenge_node_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret url = "https://financialdatafeed.platform.intuit.com/rest-war/v1/institutions/#{institution_id}/logins" if !(response.kind_of?(Array) || response.respond_to?('each')) response = [response] end cr = IntuitIdsAggcat::ChallengeResponses.new cr.response = response il = IntuitIdsAggcat::InstitutionLogin.new il.challenge_responses = cr daa = oauth_post_request url, il.save_to_xml.to_s, oauth_token_info, { "challengeSessionId" => challenge_session_id, "challengeNodeId" => challenge_node_id } discover_account_data_to_hash daa end |
.delete_account(username, account_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Deletes the a specific account for a customer from aggregation at Intuit. username and account ID must be provided, if no oauth_token_info is provided, new tokens will be provisioned using username
61 62 63 64 65 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 61 def delete_account username, account_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret puts "in gem, username = #{username}, account = #{account_id}." url = "https://financialdatafeed.platform.intuit.com/rest-war/v1/accounts/#{account_id}" oauth_delete_request url, oauth_token_info end |
.delete_customer(username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Deletes the customer’s accounts from aggregation at Intuit. username must be provided, if no oauth_token_info is provided, new tokens will be provisioned using username
53 54 55 56 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 53 def delete_customer username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret url = "https://financialdatafeed.platform.intuit.com/rest-war/v1/customers/" oauth_delete_request url, oauth_token_info end |
.discover_account_data_to_hash(daa) ⇒ Object
Helper method for parsing discover account response data
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 213 def discover_account_data_to_hash daa challenge_type = "none" if daa[:response_code] == "201" # return account list accounts = AccountList.load_from_xml(daa[:response_xml].root) { discover_response: daa, accounts: accounts, challenge_type: challenge_type, challenge: nil, description: "Account information retrieved." } elsif daa[:response_code] == "401" && daa[:challenge_session_id] # return challenge challenge = Challenges.load_from_xml(daa[:response_xml].root) challenge_type = "unknown" if challenge.save_to_xml.to_s.include?("<choice>") challenge_type = "choice" elsif challenge.save_to_xml.to_s.include?("image") challenge_type ="image" else challenge_type = "text" end { discover_response: daa, accounts: nil, challenge_type: challenge_type, challenge: challenge, challenge_session_id: daa[:challenge_session_id], challenge_node_id: daa[:challenge_node_id], description: "Multi-factor authentication required to retrieve accounts." } elsif daa[:response_code] == "404" { discover_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Institution not found." } elsif daa[:response_code] == "408" { discover_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Multi-factor authentication session expired." } elsif daa[:response_code] == "500" { discover_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Internal server error." } elsif daa[:response_code] == "503" { discover_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Problem at the financial institution." } else { discover_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Unknown error." } end end |
.discover_and_add_accounts_with_credentials(institution_id, username, creds_hash, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 30) ⇒ Object
Discovers and adds accounts using credentials institution_id is the ID of the institution, username is the ID for this customer’s accounts at Intuit and must be used for future requests, creds_hash is a hash object of key value pairs used for authentication If oauth_token is not provided, new tokens will be provisioned using the username provided Returns a hash produced by discover_account_data_to_hash with the following keys:
discover_response : hash including the following keys:
response_code: HTTP response code from Intuit
response_xml : XML returned by Intuit
accounts : Ruby hash with accounts if returned by discover call
challenge_type : text description of the type of challenge requested, if applicable
"none" | "choice" | "image" | "text"
challenge : Ruby hash with the detail of the challenge if applicable
challenge_session_id: challenge session ID to pass to challenge_response if this is a challenge
challenge_node_id : challenge node ID to pass to challenge_response if this is a challenge
description : text description of the result of the discover request
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 84 def discover_and_add_accounts_with_credentials institution_id, username, creds_hash, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 30 url = "https://financialdatafeed.platform.intuit.com/rest-war/v1/institutions/#{institution_id}/logins" credentials_array = [] creds_hash.each do |k,v| c = Credential.new c.name = k c.value = v credentials_array.push c end creds = Credentials.new creds.credential = credentials_array il = InstitutionLogin.new il.credentials = creds daa = oauth_post_request url, il.save_to_xml.to_s, oauth_token_info discover_account_data_to_hash daa end |
.get_account(username, account_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Get a specific account for a customer from aggregation at Intuit. username and account ID must be provided, if no oauth_token_info is provided, new tokens will be provisioned using username
43 44 45 46 47 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 43 def get_account username, account_id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret url = "https://financialdatafeed.platform.intuit.com/rest-war/v1/accounts/#{account_id}" response = oauth_get_request url, oauth_token_info account = AccountList.load_from_xml(response[:response_xml].root) end |
.get_account_transactions(username, account_id, start_date, end_date = nil, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Get transactions for a specific account and timeframe
166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 166 def get_account_transactions username, account_id, start_date, end_date = nil, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret txn_start = start_date.strftime("%Y-%m-%d") url = "https://financialdatafeed.platform.intuit.com/rest-war/v1/accounts/#{account_id}/transactions?txnStartDate=#{txn_start}" if !end_date.nil? txn_end = end_date.strftime("%Y-%m-%d") url = "#{url}&txnEndDate=#{txn_end}" end response = oauth_get_request url, oauth_token_info xml = REXML::Document.new response[:response_xml].to_s tl = IntuitIdsAggcat::TransactionList.load_from_xml xml.root end |
.get_customer_accounts(username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Gets all accounts for a customer
120 121 122 123 124 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 120 def get_customer_accounts username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret url = "https://financialdatafeed.platform.intuit.com/v1/accounts/" response = oauth_get_request url, oauth_token_info accounts = AccountList.load_from_xml(response[:response_xml].root) end |
.get_institution_detail(id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens("default"), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Gets the institution details for id. If oauth_token_info isn’t provided, new tokens are provisioned using “default” user consumer_key and consumer_secret will be retrieved from the Configuration class if not provided
34 35 36 37 38 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 34 def get_institution_detail id, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens("default"), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret response = oauth_get_request "https://financialdatafeed.platform.intuit.com/rest-war/v1/institutions/#{id}", oauth_token_info, consumer_key, consumer_secret institutions = InstitutionDetail.load_from_xml(response[:response_xml].root) institutions end |
.get_institutions(oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens("default"), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Gets all institutions supported by Intuit. If oauth_token_info isn’t provided, new tokens are provisioned using “default” user consumer_key and consumer_secret will be retrieved from the Configuration class if not provided
21 22 23 24 25 26 27 28 29 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 21 def get_institutions oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens("default"), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret response = oauth_get_request "https://financialdatafeed.platform.intuit.com/rest-war/v1/institutions", oauth_token_info, consumer_key, consumer_secret if response[:response_code] == "200" institutions = Institutions.load_from_xml(response[:response_xml].root) institutions.institutions else return nil end end |
.get_login_accounts(login_id, username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Gets accounts for a specific customer login_id
128 129 130 131 132 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 128 def get_login_accounts login_id, username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret url = "https://financialdatafeed.platform.intuit.com/v1/logins/#{login_id}/accounts" response = oauth_get_request url, oauth_token_info accounts = AccountList.load_from_xml(response[:response_xml].root) end |
.initialize ⇒ Object
14 15 16 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 14 def initialize end |
.oauth_delete_request(url, oauth_token_info, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120) ⇒ Object
Helper method to issue delete requests
310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 310 def oauth_delete_request url, oauth_token_info, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120 oauth_token = oauth_token_info[:oauth_token] oauth_token_secret = oauth_token_info[:oauth_token_secret] = { :request_token_path => 'https://financialdatafeed.platform.intuit.com', :timeout => timeout } = .merge({ :proxy => IntuitIdsAggcat.config.proxy}) if !IntuitIdsAggcat.config.proxy.nil? consumer = OAuth::Consumer.new(consumer_key, consumer_secret, ) access_token = OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret) response = access_token.delete(url, { "Content-Type"=>'application/xml', 'Host' => 'financialdatafeed.platform.intuit.com' }) response_xml = REXML::Document.new response.body { :response_code => response.code, :response_xml => response_xml } end |
.oauth_get_request(url, oauth_token_info, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120) ⇒ Object
Helper method to issue get requests
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 269 def oauth_get_request url, oauth_token_info, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120 oauth_token = oauth_token_info[:oauth_token] oauth_token_secret = oauth_token_info[:oauth_token_secret] = { :request_token_path => 'https://financialdatafeed.platform.intuit.com', :timeout => timeout } = .merge({ :proxy => IntuitIdsAggcat.config.proxy}) if !IntuitIdsAggcat.config.proxy.nil? consumer = OAuth::Consumer.new(consumer_key, consumer_secret, ) access_token = OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret) begin response = access_token.get(url, { "Content-Type"=>'application/xml', 'Host' => 'financialdatafeed.platform.intuit.com' }) response_xml = REXML::Document.new response.body rescue REXML::ParseException => msg #Rails.logger.error "REXML Parse Exception" return nil end { :response_code => response.code, :response_xml => response_xml } end |
.oauth_post_request(url, body, oauth_token_info, headers = {}, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120) ⇒ Object
Helper method to issue post requests
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 246 def oauth_post_request url, body, oauth_token_info, headers = {}, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120 oauth_token = oauth_token_info[:oauth_token] oauth_token_secret = oauth_token_info[:oauth_token_secret] = { :request_token_path => 'https://financialdatafeed.platform.intuit.com', :timeout => timeout } = .merge({ :proxy => IntuitIdsAggcat.config.proxy}) if !IntuitIdsAggcat.config.proxy.nil? consumer = OAuth::Consumer.new(consumer_key, consumer_secret, ) access_token = OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret) response = access_token.post(url, body, { "Content-Type"=>'application/xml', 'Host' => 'financialdatafeed.platform.intuit.com' }.merge(headers)) response_xml = REXML::Document.new response.body # handle challenge responses from discoverAndAcccounts flow challenge_session_id = challenge_node_id = nil if !response["challengeSessionId"].nil? challenge_session_id = response["challengeSessionId"] challenge_node_id = response["challengeNodeId"] end { :challenge_session_id => challenge_session_id, :challenge_node_id => challenge_node_id, :response_code => response.code, :response_xml => response_xml } end |
.oauth_put_request(url, oauth_token_info, body = nil, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120) ⇒ Object
Helper method to issue put requests
289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 289 def oauth_put_request url, oauth_token_info, body = nil, consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret, timeout = 120 oauth_token = oauth_token_info[:oauth_token] oauth_token_secret = oauth_token_info[:oauth_token_secret] = { :request_token_path => 'https://financialdatafeed.platform.intuit.com', :timeout => timeout, :http_method => :put } = .merge({ :proxy => IntuitIdsAggcat.config.proxy}) if !IntuitIdsAggcat.config.proxy.nil? consumer = OAuth::Consumer.new(consumer_key, consumer_secret, ) access_token = OAuth::AccessToken.new(consumer, oauth_token, oauth_token_secret) begin response = access_token.put(url, body, { "Content-Type"=>'application/xml', 'Host' => 'financialdatafeed.platform.intuit.com' }) response_xml = REXML::Document.new response.body rescue REXML::ParseException => msg #Rails.logger.error "REXML Parse Exception" #Rails.logger.error msg return nil end { :response_code => response.code, :response_xml => response_xml } end |
.update_credentials_data_to_hash(daa) ⇒ Object
Helper method for parsing discover credential update response data
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 180 def update_credentials_data_to_hash daa challenge_type = "none" if daa[:response_code] == "200" # return account list accounts = AccountList.load_from_xml(daa[:response_xml].root) { update_response: daa, challenge_type: challenge_type, challenge: nil, description: "Account information updated." } elsif daa[:response_code] == "401" && daa[:challenge_session_id] # return challenge challenge = Challenges.load_from_xml(daa[:response_xml].root) challenge_type = "unknown" if challenge.save_to_xml.to_s.include?("<choice>") challenge_type = "choice" elsif challenge.save_to_xml.to_s.include?("image") challenge_type ="image" else challenge_type = "text" end { update_response: daa, accounts: nil, challenge_type: challenge_type, challenge: challenge, challenge_session_id: daa[:challenge_session_id], challenge_node_id: daa[:challenge_node_id], description: "Multi-factor authentication required to update credentials." } elsif daa[:response_code] == "404" { update_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Login ID not found." } elsif daa[:response_code] == "408" { update_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Timed out." } elsif daa[:response_code] == "500" { update_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Internal server error." } elsif daa[:response_code] == "503" { update_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Problem at the financial institution." } else { update_response: daa, accounts: nil, challenge_type: challenge_type, challenge: nil, description: "Unknown error." } end end |
.update_institution_login_explicit_refresh(login_id, username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Explicitly refreshes the customer account with new credentials at an institution
157 158 159 160 161 162 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 157 def update_institution_login_explicit_refresh login_id, username, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret url = "https://financialdatafeed.platform.intuit.com/v1/logins/#{login_id}?refresh=true" body = InstitutionLogin.new.save_to_xml.to_s response = oauth_put_request url, oauth_token_info, body return response end |
.update_institution_login_with_credentials(login_id, username, creds_hash, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret) ⇒ Object
Updates an existing customer account with new credentials at an institution Response can include an MFA challenge; see the return values for discover_and_add_accounts_with_credentials for more information on possible responses
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/intuit_ids_aggcat/client/services.rb', line 138 def update_institution_login_with_credentials login_id, username, creds_hash, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret url = "https://financialdatafeed.platform.intuit.com/v1/logins/#{login_id}?refresh=true" credentials_array = [] creds_hash.each do |k,v| c = Credential.new c.name = k c.value = v credentials_array.push c end creds = Credentials.new creds.credential = credentials_array il = InstitutionLogin.new il.credentials = creds response = oauth_put_request url, oauth_token_info, il.save_to_xml.to_s update_credentials_data_to_hash response end |