Updates for yodlee account status

This commit is contained in:
David Bomba 2023-08-10 12:17:37 +10:00
parent 9b187cc6fb
commit 45c5e2195b
3 changed files with 110 additions and 2 deletions

View File

@ -64,6 +64,7 @@ use App\Helpers\Bank\AccountTransformerInterface;
class AccountTransformer implements AccountTransformerInterface
{
public function transform($yodlee_account)
{
$data = [];
@ -93,13 +94,54 @@ class AccountTransformer implements AccountTransformerInterface
$account_currency = $account->balance->currency ?? '';
}
$account_status = $account->accountStatus;
if(property_exists($account, 'dataset')){
$dataset = $account->dataset[0];
$status = false;
$update = false;
match($dataset->additionalStatus ?? ''){
'LOGIN_IN_PROGRESS' => $status = 'Data retrieval in progress.',
'USER_INPUT_REQUIRED' => $status = 'Please reconnect your account, authentication required.',
'LOGIN_SUCCESS' => $status = 'Data retrieval in progress',
'ACCOUNT_SUMMARY_RETRIEVED' => $status = 'Account summary retrieval in progress.',
'NEVER_INITIATED' => $status = 'Upstream working on connecting to your account.',
'LOGIN_FAILED' => $status = 'Authentication failed, please try reauthenticating.',
'REQUEST_TIME_OUT' => $status = 'Timeout encountered retrieving data.',
'DATA_RETRIEVAL_FAILED' => $status = 'Login successful, but data retrieval failed.',
'PARTIAL_DATA_RETRIEVED' => $status = 'Partial data update failed.',
'PARTIAL_DATA_RETRIEVED_REM_SCHED' => $status = 'Partial data update failed.',
'SUCCESS' => $status = 'All accounts added or updated successfully.',
default => $status = false
};
if($status){
$account_status = $status;
}
match($dataset->updateEligibility ?? ''){
'ALLOW_UPDATE' => $update = 'Account connection stable.',
'ALLOW_UPDATE_WITH_CREDENTIALS' => $update = 'Please reconnect your account with updated credentials.',
'DISALLOW_UPDATE' => $update = 'Update not available due to technical issues.',
default => $update = false,
};
if($status && $update){
$account_status = $status . ' - ' . $update;
}
elseif($update){
$account_status = $update;
}
}
return [
'id' => $account->id,
'account_type' => $account->CONTAINER,
// 'account_name' => $account->accountName,
'account_name' => property_exists($account, 'accountName') ? $account->accountName : $account->nickname,
'account_status' => $account->accountStatus,
'account_status' => $account_status,
'account_number' => property_exists($account, 'accountNumber') ? '**** ' . substr($account?->accountNumber, -7) : '',
'provider_account_id' => $account->providerAccountId,
'provider_id' => $account->providerId,

View File

@ -297,4 +297,71 @@ class Yodlee
'secret' => $this->client_secret,
];
}
/**
* updateEligibility
*
* ALLOW_UPDATE
* ALLOW_UPDATE_WITH_CREDENTIALS
* DISALLOW_UPDATE
*/
/**
* additionalStatus
*
* LOGIN_IN_PROGRESS
* DATA_RETRIEVAL_IN_PROGRESS
* ACCT_SUMMARY_RECEIVED
* AVAILABLE_DATA_RETRIEVED
* PARTIAL_DATA_RETRIEVED
* DATA_RETRIEVAL_FAILED
* DATA_NOT_AVAILABLE
* ACCOUNT_LOCKED
* ADDL_AUTHENTICATION_REQUIRED
* BETA_SITE_DEV_IN_PROGRESS
* CREDENTIALS_UPDATE_NEEDED
* INCORRECT_CREDENTIALS
* PROPERTY_VALUE_NOT_AVAILABLE
* INVALID_ADDL_INFO_PROVIDED
* REQUEST_TIME_OUT
* SITE_BLOCKING_ERROR
* UNEXPECTED_SITE_ERROR
* SITE_NOT_SUPPORTED
* SITE_UNAVAILABLE
* TECH_ERROR
* USER_ACTION_NEEDED_AT_SITE
* SITE_SESSION_INVALIDATED
* NEW_AUTHENTICATION_REQUIRED
* DATASET_NOT_SUPPORTED
* ENROLLMENT_REQUIRED_FOR_DATASET
* CONSENT_REQUIRED
* CONSENT_EXPIRED
* CONSENT_REVOKED
* INCORRECT_OAUTH_TOKEN
* MIGRATION_IN_PROGRESS
*/
/**
* IN_PROGRESS LOGIN_IN_PROGRESS Provider login is in progress.
* IN_PROGRESS USER_INPUT_REQUIRED Provider site requires MFA-based authentication and needs user input for login.
* IN_PROGRESS LOGIN_SUCCESS Provider login is successful.
* IN_PROGRESS ACCOUNT_SUMMARY_RETRIEVED Account summary info may not have the complete info of accounts that are available in the provider site. This depends on the sites behaviour. Account summary info may not be available at all times.
* FAILED NEVER_INITIATED The add or update provider account was not triggered due to techincal reasons. This is a rare occurrence and usually resolves quickly.
* FAILED LOGIN_FAILED Provider login failed.
* FAILED REQUEST_TIME_OUT The process timed out.
* FAILED DATA_RETRIEVAL_FAILED All accounts under the provider account failed with same or different errors, though login was successful.
* FAILED No additional status or information will be provided when there are errors other than the ones listed above.
* PARTIAL_SUCCESS PARTIAL_DATA_RETRIEVED DATA_RETRIEVAL_FAILED_PARTIALLY One/few accounts data gathered and one/few accounts failed.
* PARTIAL_SUCCESS PARTIAL_DATA_RETRIEVED_REM_SCHED DATA_RETRIEVAL_FAILED_PARTIALLY One/few accounts data gathered One/few accounts failed
* SUCCESS All accounts under the provider was added or updated successfully.
*/
/**
* updateEligibility
*
* ALLOW_UPDATE The status indicates that the account is eligible for the next update and applies to both MFA and non-MFA accounts. For MFA-based accounts, the user may have to provide the MFA details during account refresh.
* ALLOW_UPDATE_WITH_CREDENTIALS The status indicates updating or refreshing the account by directing the user to edit the provided credentials.
* DISALLOW_UPDATE The status indicates the account is not eligible for the update or refresh process due to a site issue or a technical error.
*/
}

View File

@ -32,7 +32,6 @@ return new class extends Migration
$table->timestamp('last_login')->nullable();
});
}
/**