From bde487e62d9bfb38f3bfb3390cc0ebb56211c3db Mon Sep 17 00:00:00 2001 From: Amy Tang Date: Wed, 7 Oct 2020 12:09:16 -0700 Subject: [PATCH 1/2] iOS: Return error in Exit --- ios/RNLinksdk.m | 79 ++++--------------------------------------------- 1 file changed, 5 insertions(+), 74 deletions(-) diff --git a/ios/RNLinksdk.m b/ios/RNLinksdk.m index 8765779e..925fb55c 100644 --- a/ios/RNLinksdk.m +++ b/ios/RNLinksdk.m @@ -120,7 +120,7 @@ - (void)stopObserving { if (strongSelf.completionCallback) { NSDictionary *exitMetadata = [RNLinksdk dictionaryFromExit:exit]; if (exit.error) { - strongSelf.completionCallback(@[RCTMakeError(exit.error.localizedDescription, nil, nil), exitMetadata]); + strongSelf.completionCallback(@[exitMetadata[@"error"], exitMetadata]); } else { strongSelf.completionCallback(@[[NSNull null], exitMetadata]); } @@ -625,7 +625,7 @@ + (NSString *)errorTypeStringFromError:(PLKExitError *)error { return @""; } - NSString *normalizedErrorDomain = errorDomain.lowercaseString; + NSString *normalizedErrorDomain = errorDomain; return @{ kPLKExitErrorInvalidRequestDomain: @"INVALID_REQUEST", @@ -643,83 +643,14 @@ + (NSString *)errorTypeStringFromError:(PLKExitError *)error { + (NSString *)errorCodeStringFromError:(PLKExitError *)error { NSString *errorDomain = error.domain; + if (!error || !errorDomain) { return @""; } NSString *normalizedErrorDomain = error.domain; - return @{ - kPLKExitErrorInvalidRequestDomain: @{ - @(PLKApiErrorCodeInternalServerError): @"INTERNAL_SERVER_ERROR", - @(PLKApiErrorCodePlannedMaintenance): @"PLANNED_MAINTENANCE", - }, - kPLKExitErrorInvalidInputDomain: @{ - @(PLKInvalidInputErrorCodeInvalidApiKeys): @"INVALID_API_KEYS", - @(PLKInvalidInputErrorCodeUnauthorizedEnvironment): @"UNAUTHORIZED_ENVIRONMENT", - @(PLKInvalidInputErrorCodeInvalidAccessToken): @"INVALID_ACCESS_TOKEN", - @(PLKInvalidInputErrorCodeInvalidPublicToken): @"INVALID_PUBLIC_TOKEN", - @(PLKInvalidInputErrorCodeInvalidProduct): @"INVALID_PRODUCT", - @(PLKInvalidInputErrorCodeInvalidAccountId): @"INVALID_ACCOUNT_ID", - @(PLKInvalidInputErrorCodeInvalidInstitution): @"INVALID_INSTITUTION", - @(PLKInvalidInputErrorCodeTooManyVerificationAttempts): @"TOO_MANY_VERIFICATION_ATTEMPTS", - }, - kPLKExitErrorInstitutionErrorDomain: @{ - @(PLKInstitutionErrorCodeInstitutionDown): @"INSTITUTION_DOWN", - @(PLKInstitutionErrorCodeInstitutionNotResponding): @"INSTITUTION_NOT_RESPONDING", - @(PLKInstitutionErrorCodeInstitutionNotAvailable): @"INSTITUTION_NOT_AVAILABLE", - @(PLKInstitutionErrorCodeInstitutionNoLongerSupported): @"INSTITUTION_NO_LONGER_SUPPORTED", - }, - kPLKExitErrorRateLimitExceededDomain: @{ - @(PLKRateLimitErrorCodeAccountsLimit): @"ACCOUNTS_LIMIT", - @(PLKRateLimitErrorCodeAdditionLimit): @"ADDITION_LIMIT", - @(PLKRateLimitErrorCodeAuthLimit): @"AUTH_LIMIT", - @(PLKRateLimitErrorCodeIdentityLimit): @"IDENTITY_LIMIT", - @(PLKRateLimitErrorCodeIncomeLimit): @"INCOME_LIMIT", - @(PLKRateLimitErrorCodeItemGetLimit): @"ITEM_GET_LIMIT", - @(PLKRateLimitErrorCodeRateLimit): @"RATE_LIMIT", - @(PLKRateLimitErrorCodeTransactionsLimit): @"TRANSACTIONS_LIMIT", - }, - kPLKExitErrorApiDomain: @{ - @(PLKApiErrorCodeInternalServerError): @"INTERNAL_SERVER_ERROR", - @(PLKApiErrorCodePlannedMaintenance): @"PLANNED_MAINTENANCE", - }, - kPLKExitErrorItemDomain: @{ - @(PLKItemErrorCodeInsufficientCredentials): @"INSUFFICIENT_CREDENTIALS", - @(PLKItemErrorCodeInvalidCredentials): @"INVALID_CREDENTIALS", - @(PLKItemErrorCodeInvalidMfa): @"INVALID_MFA", - @(PLKItemErrorCodeInvalidSendMethod): @"INVALID_SEND_METHOD", - @(PLKItemErrorCodeInvalidUpdatedUsername): @"INVALID_UPDATED_USERNAME", - @(PLKItemErrorCodeItemLocked): @"ITEM_LOCKED", - @(PLKItemErrorCodeItemLoginRequired): @"ITEM_LOGIN_REQUIRED", - @(PLKItemErrorCodeItemNoError): @"ITEM_NO_ERROR", - @(PLKItemErrorCodeItemNotSupported): @"ITEM_NOT_SUPPORTED", - @(PLKItemErrorCodeIncorrectDepositAmounts): @"INCORRECT_DEPOSIT_AMOUNTS", - @(PLKItemErrorCodeUserSetupRequired): @"USER_SETUP_REQUIRED", - @(PLKItemErrorCodeMfaNotSupported): @"MFA_NOT_SUPPORTED", - @(PLKItemErrorCodeNoAccounts): @"NO_ACCOUNTS", - @(PLKItemErrorCodeNoAuthAccounts): @"NO_AUTH_ACCOUNTS", - @(PLKItemErrorCodeNoInvestmentAccounts): @"NO_INVESTMENT_ACCOUNTS", - @(PLKItemErrorCodeNoLiabilityAccounts): @"NO_LIABILITY_ACCOUNTS", - @(PLKItemErrorCodeProductNotReady): @"PRODUCT_NOT_READY", - @(PLKItemErrorCodeProductsNotSupported): @"PRODUCTS_NOT_SUPPORTED", - @(PLKItemErrorCodeInstantMatchFailed): @"INSTANT_MATCH_FAILED", - }, - kPLKExitErrorAuthDomain: @{ - @(PLKAuthErrorCodeProductNotReady): @"PRODUCT_NOT_READY", - @(PLKAuthErrorCodeVerificationExpired): @"VERIFICATION_EXPIRED", - }, - kPLKExitErrorAssetReportDomain: @{ - @(PLKAssetReportErrorCodeProductNotEnabled): @"PRODUCT_NOT_ENABLED", - @(PLKAssetReportErrorCodeDataUnavailable): @"DATA_UNAVAILABLE", - @(PLKAssetReportErrorCodeProductNotReady): @"PRODUCT_NOT_READY", - @(PLKAssetReportErrorCodeAssetReportGenerationFailed): @"ASSET_REPORT_GENERATION_FAILED", - @(PLKAssetReportErrorCodeInvalidParent): @"INVALID_PARENT", - @(PLKAssetReportErrorCodeInsightsNotEnabled): @"INSIGHTS_NOT_ENABLED", - @(PLKAssetReportErrorCodeInsightsPreviouslyNotEnabled): @"INSIGHTS_PREVIOUSLY_NOT_ENABLED", - }, - kPLKExitErrorInternalDomain: error.userInfo[kPLKExitErrorCodeKey] ?: @"UNKNOWN", - kPLKExitErrorUnknownDomain: error.userInfo[kPLKExitErrorCodeKey] ?: @"UNKNOWN", - }[normalizedErrorDomain] ?: @"UNKNOWN"; + NSInteger code = error.code; + return error.userInfo[@"kPLKExitErrorCodeKey"]; } + (NSString *)errorMessageFromError:(PLKExitError *)error { From 9f0107c1bc1e0e60170cae0650e62df2752727c6 Mon Sep 17 00:00:00 2001 From: Amy Tang Date: Wed, 7 Oct 2020 13:44:56 -0700 Subject: [PATCH 2/2] change to key --- ios/RNLinksdk.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNLinksdk.m b/ios/RNLinksdk.m index 925fb55c..79c7a4c4 100644 --- a/ios/RNLinksdk.m +++ b/ios/RNLinksdk.m @@ -650,7 +650,7 @@ + (NSString *)errorCodeStringFromError:(PLKExitError *)error { NSString *normalizedErrorDomain = error.domain; NSInteger code = error.code; - return error.userInfo[@"kPLKExitErrorCodeKey"]; + return error.userInfo[kPLKExitErrorCodeKey]; } + (NSString *)errorMessageFromError:(PLKExitError *)error {