From ee3cc7d5441b953af88dabbe2790c5822bf84f7b Mon Sep 17 00:00:00 2001 From: Riddhi Agrawal Date: Tue, 16 Jan 2024 17:52:09 +0530 Subject: [PATCH 1/3] fix: changes for supporting form data type in api --- src/components/HSwitchFeedBackModal.res | 2 +- .../hyperswitch/HyperSwitchEntry.res | 2 +- .../WooCommerce/WooCommerceUIUtils.res | 2 +- src/hooks/AuthHooks.res | 17 ++++++++++++++--- src/screens/HyperSwitch/APIUtils/APIUtils.res | 11 +++++++++-- src/screens/HyperSwitch/Analytics/Analytics.res | 6 +++--- .../Analytics/DownloadReportModal.res | 2 +- .../HomePageOverviewComponent.res | 1 + .../RefundsAnalytics/RefundsAnalytics.res | 2 +- .../SystemMetrics/SystemMetricsAnalytics.res | 6 +++--- .../Connectors/ConnectorAccountDetails.res | 2 +- .../Connectors/ConnectorPaymentMethod.res | 2 +- .../HyperSwitch/Connectors/ConnectorPreview.res | 2 +- .../Wallets/ApplePayWalletIntegration.res | 2 +- .../Developer/APIKeys/KeyManagement.res | 4 ++-- .../PaymentSettings/PaymentSettings.res | 2 +- .../FraudAndRisk/FRMIntegrationFields.res | 4 ++-- .../HyperSwitch/FraudAndRisk/FRMSummary.res | 2 +- src/screens/HyperSwitch/HSwitchRemoteFilter.res | 2 +- .../CommonConnectorFlow/ConfigureConnector.res | 4 ++-- .../QuickStartConnectorFlow.res | 2 +- .../Home/CommonConnectorFlow/SetupConnector.res | 2 +- .../Home/DelayedVerificationBanner.res | 2 +- .../Home/ProdIntent/ProdVerifyModal.res | 2 +- .../HyperSwitch/Home/QuickStart/GoLive.res | 2 +- .../IntegrateYourApp/IntegrationDocsPage.res | 2 +- .../HyperSwitch/Hooks/EnumVariantHook.res | 2 +- .../HyperSwitch/Order/OrderRefundForm.res | 2 +- src/screens/HyperSwitch/Order/OrderUIUtils.res | 13 ++++++++++--- src/screens/HyperSwitch/Order/ShowOrder.res | 2 +- .../HyperSwitch/PaymentLogs/PaymentLogs.res | 2 +- .../PostLoginScreen/PostLoginScreen.res | 1 + src/screens/HyperSwitch/Recon/Recon.res | 2 +- src/screens/HyperSwitch/Refunds/RefundUtils.res | 10 ++++++++-- .../HyperSwitch/Routing/ActiveRouting.res | 2 +- .../HyperSwitch/Routing/DefaultRouting.res | 4 +++- .../HyperSwitch/Routing/PriorityRouting.res | 3 ++- .../HyperSwitch/Routing/VolumeSplitRouting.res | 6 +++--- .../RoutingRevamp/AdvancedRouting.res | 11 ++++++++--- .../HyperSwitch/SDKPayment/TestPayment.res | 2 +- .../HSwitchAgreementScreen.res | 2 +- .../LiveEndpointsSetup.res | 4 ++-- .../ProdOnboardingLanding.res | 2 +- .../SetupConnectorCredentials.res | 6 +++--- .../IntegrationDocs.res | 2 +- .../HSwitchSandboxOnboarding/UserOnboarding.res | 4 ++-- .../UserOnboardingUIUtils.res | 4 ++-- .../HyperSwitch/Settings/BusinessDetails.res | 1 + .../BusinessMapping/BusinessProfile.res | 2 +- .../Settings/HSwitchProfileSettings.res | 2 +- .../HyperSwitch/Settings/HSwitchSettings.res | 2 +- .../SetupAccount/HSwitchSetupAccount.res | 11 ++++++----- .../StripePlusPaypalUIUtils.res | 2 +- src/screens/HyperSwitch/Surcharge/Surcharge.res | 7 ++++++- .../SwitchMerchant/SwitchMerchant.res | 4 ++-- .../HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res | 7 ++++++- .../HyperSwitch/UserManagement/InviteUsers.res | 2 +- .../HyperSwitch/UserManagement/ShowUserData.res | 2 +- .../login/HSwitchLoginFlow/HyperSwitchAuth.res | 10 +++++----- .../HyperSwitchEmailVerifyScreen.res | 2 +- 60 files changed, 141 insertions(+), 88 deletions(-) diff --git a/src/components/HSwitchFeedBackModal.res b/src/components/HSwitchFeedBackModal.res index a4d1eb621..a9be6ae78 100644 --- a/src/components/HSwitchFeedBackModal.res +++ b/src/components/HSwitchFeedBackModal.res @@ -18,7 +18,7 @@ let make = ( [ ("Feedback", values->HSwitchUtils.getBodyForFeedBack(~modalType, ())->Js.Json.object_), ]->LogicUtils.getJsonFromArrayOfJson - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) let successMessage = switch modalType { | FeedBackModal => "Thanks for feedback" | RequestConnectorModal => "Request submitted succesfully" diff --git a/src/entryPoints/hyperswitch/HyperSwitchEntry.res b/src/entryPoints/hyperswitch/HyperSwitchEntry.res index 4fbf0b835..5c55a5df5 100644 --- a/src/entryPoints/hyperswitch/HyperSwitchEntry.res +++ b/src/entryPoints/hyperswitch/HyperSwitchEntry.res @@ -64,7 +64,7 @@ module HyperSwitchEntryComponent = { let url = `${HSwitchGlobalVars.hyperSwitchFEPrefix}/config/merchant-access` let typedResponse = ( - await postDetails(url, Dict.make()->Js.Json.object_, Post) + await postDetails(url, Dict.make()->Js.Json.object_, Post, ()) )->FeatureFlagUtils.featureFlagType setFeatureFlag(._ => typedResponse) setScreenState(_ => PageLoaderWrapper.Success) diff --git a/src/entryPoints/hyperswitch/WooCommerce/WooCommerceUIUtils.res b/src/entryPoints/hyperswitch/WooCommerce/WooCommerceUIUtils.res index 38c1c31b9..b50223c77 100644 --- a/src/entryPoints/hyperswitch/WooCommerce/WooCommerceUIUtils.res +++ b/src/entryPoints/hyperswitch/WooCommerce/WooCommerceUIUtils.res @@ -112,7 +112,7 @@ module SelectPaymentMethods = { let body = ConnectorUtils.constructConnectorRequestBody(obj, initialValues) let connectorUrl = APIUtils.getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=None, ()) - let response = await updateAPIHook(connectorUrl, body, Post) + let response = await updateAPIHook(connectorUrl, body, Post, ()) setInitialValues(_ => response) response->LogicUtils.getDictFromJsonObject->updateEnumForConnector->ignore setConnectorConfigureState(_ => Summary) diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res index e8ba39e87..0f558c915 100644 --- a/src/hooks/AuthHooks.res +++ b/src/hooks/AuthHooks.res @@ -10,7 +10,7 @@ type sessionStorage = { external dictToObj: Js.Dict.t<'a> => {..} = "%identity" @val external atob: string => string = "atob" -let getHeaders = (~uri, ~headers, ()) => { +let getHeaders = (~uri, ~headers, ~isFromFormData, ()) => { let hyperSwitchToken = LocalStorage.getItem("login")->Js.Nullable.toOption let isMixpanel = uri->String.includes("mixpanel") @@ -20,6 +20,12 @@ let getHeaders = (~uri, ~headers, ()) => { "accept": "application/json", } Fetch.HeadersInit.make(headerObj) + } else if isFromFormData { + let headerObj = { + "Authorization": `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`, + "api-key": headers->Dict.get("api-key")->Belt.Option.getWithDefault("hyperswitch"), + } + Fetch.HeadersInit.make(headerObj) } else { let headerObj = headers->Dict.get("api-key")->Belt.Option.getWithDefault("")->String.length > 0 @@ -81,6 +87,7 @@ let useApiFetcher = () => { ( uri, ~bodyStr: string="", + ~bodyFormData=None, ~headers=Dict.make(), ~bodyHeader as _=?, ~method_: Fetch.requestMethod, @@ -98,7 +105,11 @@ let useApiFetcher = () => { let body = switch method_ { | Get => resolve(None) - | _ => resolve(Some(Fetch.BodyInit.make(bodyStr))) + | _ => + switch bodyFormData { + | Some(formDataVal) => resolve(Some(Fetch.BodyInit.makeWithFormData(formDataVal))) + | None => resolve(Some(Fetch.BodyInit.make(bodyStr))) + } } body->then(body => { @@ -109,7 +120,7 @@ let useApiFetcher = () => { ~method_, ~body?, ~credentials=SameOrigin, - ~headers=getHeaders(~headers, ~uri, ()), + ~headers=getHeaders(~headers, ~uri, ~isFromFormData=bodyFormData->Option.isSome, ()), (), ), ) diff --git a/src/screens/HyperSwitch/APIUtils/APIUtils.res b/src/screens/HyperSwitch/APIUtils/APIUtils.res index 8ede12ac5..e01e542b0 100644 --- a/src/screens/HyperSwitch/APIUtils/APIUtils.res +++ b/src/screens/HyperSwitch/APIUtils/APIUtils.res @@ -202,6 +202,7 @@ let handleLogout = async ( ~fetchApi as _: ( Js.String2.t, ~bodyStr: string=?, + ~bodyFormData: option=?, ~headers: Js.Dict.t=?, ~bodyHeader: Js.Dict.t=?, ~method_: Fetch.requestMethod, @@ -386,9 +387,15 @@ let useUpdateMethod = (~showErrorToast=true, ()) => { }, }) - async (url, body, method) => { + async (url, body, method, ~bodyFormData=?, ()) => { try { - let res = await fetchApi(url, ~method_=method, ~bodyStr=body->Js.Json.stringify, ()) + let res = await fetchApi( + url, + ~method_=method, + ~bodyStr=body->Js.Json.stringify, + ~bodyFormData, + (), + ) await responseHandler( ~res, ~showErrorToast, diff --git a/src/screens/HyperSwitch/Analytics/Analytics.res b/src/screens/HyperSwitch/Analytics/Analytics.res index 00c99e32d..b0d4d47d2 100644 --- a/src/screens/HyperSwitch/Analytics/Analytics.res +++ b/src/screens/HyperSwitch/Analytics/Analytics.res @@ -252,7 +252,7 @@ module TableWrapper = { (), ) - fetchDetails(tableEntity.uri, weeklyTableReqBody, Post) + fetchDetails(tableEntity.uri, weeklyTableReqBody, Post, ()) ->thenResolve(json => { setTableData(_ => getUpdatedData(data, json, cols)) setTableDataLoading(_ => false) @@ -285,7 +285,7 @@ module TableWrapper = { (), ) - fetchDetails(tableEntity.uri, tableReqBody, Post) + fetchDetails(tableEntity.uri, tableReqBody, Post, ()) ->thenResolve(json => { switch weeklyTableMetricsCols { | Some(cols) => getWeeklyData(json, cols)->ignore @@ -612,7 +612,7 @@ let make = ( setFilterDataJson(_ => None) if startTimeVal->isStringNonEmpty && endTimeVal->isStringNonEmpty { try { - updateDetails(filterUri, filterBody->Js.Json.object_, Post) + updateDetails(filterUri, filterBody->Js.Json.object_, Post, ()) ->thenResolve(json => setFilterDataJson(_ => json->Some)) ->catch(_ => resolve()) ->ignore diff --git a/src/screens/HyperSwitch/Analytics/DownloadReportModal.res b/src/screens/HyperSwitch/Analytics/DownloadReportModal.res index a585ff153..1f9bf33e5 100644 --- a/src/screens/HyperSwitch/Analytics/DownloadReportModal.res +++ b/src/screens/HyperSwitch/Analytics/DownloadReportModal.res @@ -23,7 +23,7 @@ let make = (~reportModal, ~setReportModal, ~entityName) => { let downloadReport = async body => { try { let url = getURL(~entityName, ~methodType=Post, ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setReportModal(_ => false) showToast(~message="Email Sent", ~toastType=ToastSuccess, ()) } catch { diff --git a/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res b/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res index a4eb1c441..6d03e5fe0 100644 --- a/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res +++ b/src/screens/HyperSwitch/Analytics/HomePageOverview/HomePageOverviewComponent.res @@ -214,6 +214,7 @@ module OverviewInfo = { generateSampleDataUrl, [("record", 50.0->Js.Json.number)]->Dict.fromArray->Js.Json.object_, Post, + (), ) showToast(~message="Sample data generated successfully.", ~toastType=ToastSuccess, ()) Window.Location.reload() diff --git a/src/screens/HyperSwitch/Analytics/RefundsAnalytics/RefundsAnalytics.res b/src/screens/HyperSwitch/Analytics/RefundsAnalytics/RefundsAnalytics.res index bf33bda3e..ef386650c 100644 --- a/src/screens/HyperSwitch/Analytics/RefundsAnalytics/RefundsAnalytics.res +++ b/src/screens/HyperSwitch/Analytics/RefundsAnalytics/RefundsAnalytics.res @@ -33,7 +33,7 @@ let make = () => { let refundUrl = getURL(~entityName=REFUNDS, ~methodType=Post, ~id=Some("refund-post"), ()) let body = Dict.make() body->Dict.set("limit", 100->Belt.Int.toFloat->Js.Json.number) - let refundDetails = await updateDetails(refundUrl, body->Js.Json.object_, Post) + let refundDetails = await updateDetails(refundUrl, body->Js.Json.object_, Post, ()) let data = refundDetails->getDictFromJsonObject->getArrayFromDict("data", []) if data->Array.length < 1 { diff --git a/src/screens/HyperSwitch/Analytics/SystemMetrics/SystemMetricsAnalytics.res b/src/screens/HyperSwitch/Analytics/SystemMetrics/SystemMetricsAnalytics.res index e9a382017..bd911bfcc 100644 --- a/src/screens/HyperSwitch/Analytics/SystemMetrics/SystemMetricsAnalytics.res +++ b/src/screens/HyperSwitch/Analytics/SystemMetrics/SystemMetricsAnalytics.res @@ -134,7 +134,7 @@ module HSiwtchPaymentConfirmLatency = { } let getOverallLatency = async () => { - updateDetails(url, singleStatBodyEntity->singleStatBodyMake("Payment"), Fetch.Post) + updateDetails(url, singleStatBodyEntity->singleStatBodyMake("Payment"), Fetch.Post, ()) ->thenResolve(json => { setOverallrLatency(_ => json->parseJson) }) @@ -146,7 +146,7 @@ module HSiwtchPaymentConfirmLatency = { } let getConnectorLatency = () => { - updateDetails(url, singleStatBodyEntity->singleStatBodyMake("OutgoingEvent"), Fetch.Post) + updateDetails(url, singleStatBodyEntity->singleStatBodyMake("OutgoingEvent"), Fetch.Post, ()) ->thenResolve(json => { setConnectorLatency(_ => json->parseJson) setIsLoading(_ => false) @@ -275,7 +275,7 @@ module SystemMetricsAnalytics = { setFilterDataJson(_ => None) if startTimeVal->isStringNonEmpty && endTimeVal->isStringNonEmpty { try { - updateDetails(filterUri, filterBody->Js.Json.object_, Post) + updateDetails(filterUri, filterBody->Js.Json.object_, Post, ()) ->thenResolve(json => setFilterDataJson(_ => json->Some)) ->catch(_ => resolve()) ->ignore diff --git a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res index 1bb5880a4..2c8d25d8e 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorAccountDetails.res @@ -154,7 +154,7 @@ let make = (~setCurrentStep, ~setInitialValues, ~initialValues, ~isUpdateFlow, ~ ~connector=Some(connector), (), ) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setShowVerifyModal(_ => false) onSubmitMain(values)->ignore } catch { diff --git a/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res b/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res index 45732743d..623a80d9c 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorPaymentMethod.res @@ -55,7 +55,7 @@ let make = ( ConnectorUtils.connectorIgnoredField, ) let connectorUrl = getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=connectorID, ()) - let response = await updateAPIHook(connectorUrl, body, Post) + let response = await updateAPIHook(connectorUrl, body, Post, ()) setInitialValues(_ => response) setScreenState(_ => Success) setCurrentStep(_ => ConnectorTypes.SummaryAndTest) diff --git a/src/screens/HyperSwitch/Connectors/ConnectorPreview.res b/src/screens/HyperSwitch/Connectors/ConnectorPreview.res index 96f99b343..12a0f3e00 100644 --- a/src/screens/HyperSwitch/Connectors/ConnectorPreview.res +++ b/src/screens/HyperSwitch/Connectors/ConnectorPreview.res @@ -248,7 +248,7 @@ let make = ( isConnectorDisabled, ) let url = getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=Some(connectorID), ()) - let _ = await updateDetails(url, disableConnectorPayload->Js.Json.object_, Post) + let _ = await updateDetails(url, disableConnectorPayload->Js.Json.object_, Post, ()) showToast(~message=`Successfully Saved the Changes`, ~toastType=ToastSuccess, ()) RescriptReactRouter.push("/connectors") } catch { diff --git a/src/screens/HyperSwitch/Connectors/Wallets/ApplePayWalletIntegration.res b/src/screens/HyperSwitch/Connectors/Wallets/ApplePayWalletIntegration.res index 47e4e01f9..b066435ea 100644 --- a/src/screens/HyperSwitch/Connectors/Wallets/ApplePayWalletIntegration.res +++ b/src/screens/HyperSwitch/Connectors/Wallets/ApplePayWalletIntegration.res @@ -91,7 +91,7 @@ module Simplified = { try { let (body, domainName) = values->constructVerifyApplePayReq(connectorID) let verifyAppleUrl = getURL(~entityName=VERIFY_APPLE_PAY, ~methodType=Post, ()) - let _ = await updateAPIHook(`${verifyAppleUrl}/${merchantId}`, body, Post) + let _ = await updateAPIHook(`${verifyAppleUrl}/${merchantId}`, body, Post, ()) let updatedValue = values->constructApplePayMetadata(metadataInputs, #simplified) update(updatedValue) diff --git a/src/screens/HyperSwitch/Developer/APIKeys/KeyManagement.res b/src/screens/HyperSwitch/Developer/APIKeys/KeyManagement.res index bbd300d97..dbbe35899 100644 --- a/src/screens/HyperSwitch/Developer/APIKeys/KeyManagement.res +++ b/src/screens/HyperSwitch/Developer/APIKeys/KeyManagement.res @@ -71,7 +71,7 @@ module ApiEditModal = { | _ => APIUtils.getURL(~entityName=API_KEYS, ~methodType=Post, ()) } - let json = await updateDetails(url, body->Js.Json.object_, Post) + let json = await updateDetails(url, body->Js.Json.object_, Post, ()) let keyDict = json->LogicUtils.getDictFromJsonObject setApiKey(_ => keyDict->LogicUtils.getString("api_key", "")) @@ -222,7 +222,7 @@ module TableActionsCell = { ~id=Some(keyId), (), ) - (await deleteDetails(deleteUrl, body->Js.Json.object_, Delete))->ignore + (await deleteDetails(deleteUrl, body->Js.Json.object_, Delete, ()))->ignore getAPIKeyDetails()->ignore } catch { | Js.Exn.Error(e) => diff --git a/src/screens/HyperSwitch/Developer/PaymentSettings/PaymentSettings.res b/src/screens/HyperSwitch/Developer/PaymentSettings/PaymentSettings.res index f70cfc574..107af63a9 100644 --- a/src/screens/HyperSwitch/Developer/PaymentSettings/PaymentSettings.res +++ b/src/screens/HyperSwitch/Developer/PaymentSettings/PaymentSettings.res @@ -50,7 +50,7 @@ let make = (~webhookOnly=false, ~showFormOnly=false, ~profileId="") => { setScreenState(_ => PageLoaderWrapper.Loading) let url = getURL(~entityName=BUSINESS_PROFILE, ~methodType=Post, ~id=Some(id), ()) let body = values->getBusinessProfilePayload->Js.Json.object_ - let res = await updateDetails(url, body, Post) + let res = await updateDetails(url, body, Post, ()) let profileTypeInfo = res->businessProfileTypeMapper setProfileInfo(_ => profileTypeInfo) showToast(~message=`Details updated`, ~toastType=ToastState.ToastSuccess, ()) diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res index 078a776f7..afb6dd27f 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMIntegrationFields.res @@ -247,7 +247,7 @@ let make = ( ->Js.Json.object_ let url = getURL(~entityName=MERCHANT_ACCOUNT, ~methodType=Post, ()) try { - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) } catch { | _ => () } @@ -255,7 +255,7 @@ let make = ( } let setFRMValues = async body => { - fetchApi(frmUrl, body, Fetch.Post) + fetchApi(frmUrl, body, Fetch.Post, ()) ->thenResolve(res => { setCurrentStep(prev => prev->getNextStep) let _ = updateMerchantDetails() diff --git a/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res b/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res index 94f440c2a..f1854bba5 100644 --- a/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res +++ b/src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res @@ -77,7 +77,7 @@ let make = (~initialValues, ~currentStep, ~setCurrentStep) => { let frmID = initialValues->getDictFromJsonObject->getString("merchant_connector_id", "") let disableFRMPayload = initialValues->FRMTypes.getDisableConnectorPayload(isFRMDisabled) let url = getURL(~entityName=FRAUD_RISK_MANAGEMENT, ~methodType=Post, ~id=Some(frmID), ()) - let _ = await updateDetails(url, disableFRMPayload->Js.Json.object_, Post) + let _ = await updateDetails(url, disableFRMPayload->Js.Json.object_, Post, ()) showToast(~message=`Successfully Saved the Changes`, ~toastType=ToastSuccess, ()) RescriptReactRouter.push("/fraud-risk-management") } catch { diff --git a/src/screens/HyperSwitch/HSwitchRemoteFilter.res b/src/screens/HyperSwitch/HSwitchRemoteFilter.res index 05b0ad11b..8c46bdad6 100644 --- a/src/screens/HyperSwitch/HSwitchRemoteFilter.res +++ b/src/screens/HyperSwitch/HSwitchRemoteFilter.res @@ -211,7 +211,7 @@ module RemoteTableFilters = { setFilterDataJson(_ => None) if startTimeVal->isStringNonEmpty && endTimeVal->isStringNonEmpty { try { - updateDetails(filterUrl, filterBody->Js.Json.object_, Post) + updateDetails(filterUrl, filterBody->Js.Json.object_, Post, ()) ->thenResolve(json => setFilterDataJson(_ => json->Some)) ->catch(_ => resolve()) ->ignore diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res index 4267a689d..1301b0b4a 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/ConfigureConnector.res @@ -79,7 +79,7 @@ let make = (~connectProcessorValue: connectProcessor) => { firstProcessorRoutingPayload, secondProcessorRoutingPayload, ) - let routingResponse = await updateDetails(routingUrl, body, Post) + let routingResponse = await updateDetails(routingUrl, body, Post, ()) let activatingId = routingResponse->getDictFromJsonObject->getString("id", "") let activateRuleURL = getURL( ~entityName=ROUTING, @@ -87,7 +87,7 @@ let make = (~connectProcessorValue: connectProcessor) => { ~id=Some(activatingId), (), ) - let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post) + let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post, ()) let _ = await updateEnumForRouting(activatingId) setButtonState(_ => Normal) } catch { diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/QuickStartConnectorFlow.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/QuickStartConnectorFlow.res index 72216d207..7f29ecf89 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/QuickStartConnectorFlow.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/QuickStartConnectorFlow.res @@ -85,7 +85,7 @@ let make = ( ~json=connectorName->Window.getConnectorConfig, ~profileId=activeBusinessProfile.profile_id, ) - let res = await updateDetails(url, testConnectorBody, Post) + let res = await updateDetails(url, testConnectorBody, Post, ()) connectorArray->Array.push(connectorName) setConnectorArray(_ => connectorArray) setInitialValues(_ => res) diff --git a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res index 8478df27e..ad471f576 100644 --- a/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res +++ b/src/screens/HyperSwitch/Home/CommonConnectorFlow/SetupConnector.res @@ -208,7 +208,7 @@ module SelectPaymentMethods = { let body = ConnectorUtils.constructConnectorRequestBody(obj, initialValues) let connectorUrl = APIUtils.getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=None, ()) - let response = await updateAPIHook(connectorUrl, body, Post) + let response = await updateAPIHook(connectorUrl, body, Post, ()) setInitialValues(_ => response) connectorArray->Array.push(connectorName) diff --git a/src/screens/HyperSwitch/Home/DelayedVerificationBanner.res b/src/screens/HyperSwitch/Home/DelayedVerificationBanner.res index 18286a98e..89dd32211 100644 --- a/src/screens/HyperSwitch/Home/DelayedVerificationBanner.res +++ b/src/screens/HyperSwitch/Home/DelayedVerificationBanner.res @@ -29,7 +29,7 @@ let make = React.memo((~merchantId="", ~verificationDays) => { let body = email->HyperSwitchAuthUtils.getEmailBody() try { let url = getURL(~entityName=USERS, ~userType=#VERIFY_EMAIL_REQUEST, ~methodType=Post, ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) showToast(~message=`Email Send Successfully!`, ~toastType=ToastSuccess, ()) } catch { | _ => diff --git a/src/screens/HyperSwitch/Home/ProdIntent/ProdVerifyModal.res b/src/screens/HyperSwitch/Home/ProdIntent/ProdVerifyModal.res index 8f387e6eb..b5363a352 100644 --- a/src/screens/HyperSwitch/Home/ProdIntent/ProdVerifyModal.res +++ b/src/screens/HyperSwitch/Home/ProdIntent/ProdVerifyModal.res @@ -15,7 +15,7 @@ let make = (~showModal, ~setShowModal, ~initialValues=Dict.make(), ~getProdVerif let url = getURL(~entityName=USERS, ~userType=#USER_DATA, ~methodType=Post, ()) let bodyValues = values->getBody->Js.Json.object_ let body = [("ProdIntent", bodyValues)]->LogicUtils.getJsonFromArrayOfJson - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) showToast( ~toastType=ToastSuccess, ~message="Successfully sent for verification!", diff --git a/src/screens/HyperSwitch/Home/QuickStart/GoLive.res b/src/screens/HyperSwitch/Home/QuickStart/GoLive.res index 0d6eb6f8c..f8b3215c9 100644 --- a/src/screens/HyperSwitch/Home/QuickStart/GoLive.res +++ b/src/screens/HyperSwitch/Home/QuickStart/GoLive.res @@ -70,7 +70,7 @@ let make = (~goLive) => { let url = getURL(~entityName=USERS, ~userType=#USER_DATA, ~methodType=Post, ()) let bodyValues = values->getBody->Js.Json.object_ let body = [("ProdIntent", bodyValues)]->LogicUtils.getJsonFromArrayOfJson - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) getProdVerifyDetails()->ignore } catch { diff --git a/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrationDocsPage.res b/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrationDocsPage.res index 722220ff6..bccef55a4 100644 --- a/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrationDocsPage.res +++ b/src/screens/HyperSwitch/Home/QuickStart/IntegrateYourApp/IntegrationDocsPage.res @@ -24,7 +24,7 @@ module RequestPage = { ->Js.Json.object_ let body = [("Feedback", requestedBody)]->LogicUtils.getJsonFromArrayOfJson - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) showToast( ~toastType=ToastSuccess, ~message="Request submitted successfully!", diff --git a/src/screens/HyperSwitch/Hooks/EnumVariantHook.res b/src/screens/HyperSwitch/Hooks/EnumVariantHook.res index 6150886da..047e4f5c5 100644 --- a/src/screens/HyperSwitch/Hooks/EnumVariantHook.res +++ b/src/screens/HyperSwitch/Hooks/EnumVariantHook.res @@ -71,7 +71,7 @@ let usePostEnumDetails = () => { try { let url = getURL(~entityName=USERS, ~userType=#MERCHANT_DATA, ~methodType=Post, ()) let bodyValForApi = enumVariant->QuickStartUtils.generateBodyBasedOnType(body) - let _ = await updateDetails(url, bodyValForApi, Post) + let _ = await updateDetails(url, bodyValForApi, Post, ()) let updatedRecoilValueDict = updateEnumInRecoil([(body, enumVariant)]) Js.Nullable.return(updatedRecoilValueDict) diff --git a/src/screens/HyperSwitch/Order/OrderRefundForm.res b/src/screens/HyperSwitch/Order/OrderRefundForm.res index 6e86e4516..2656f9e28 100644 --- a/src/screens/HyperSwitch/Order/OrderRefundForm.res +++ b/src/screens/HyperSwitch/Order/OrderRefundForm.res @@ -26,7 +26,7 @@ let make = ( let updateRefundDetails = async body => { try { let refundsUrl = getURL(~entityName=REFUNDS, ~methodType=Post, ()) - let res = await updateDetails(refundsUrl, body, Post) + let res = await updateDetails(refundsUrl, body, Post, ()) let refundStatus = res->LogicUtils.getDictFromJsonObject->LogicUtils.getString("status", "") refetch() switch refundStatus->statusVariantMapper { diff --git a/src/screens/HyperSwitch/Order/OrderUIUtils.res b/src/screens/HyperSwitch/Order/OrderUIUtils.res index 0465df385..a07abd5ea 100644 --- a/src/screens/HyperSwitch/Order/OrderUIUtils.res +++ b/src/screens/HyperSwitch/Order/OrderUIUtils.res @@ -48,6 +48,7 @@ module GenerateSampleDataButton = { generateSampleDataUrl, [("record", 50.0->Js.Json.number)]->Dict.fromArray->Js.Json.object_, Post, + (), ) showToast(~message="Sample data generated successfully.", ~toastType=ToastSuccess, ()) getOrdersList()->ignore @@ -212,7 +213,13 @@ let setData = ( let getOrdersList = async ( filterValueJson, - ~updateDetails, + ~updateDetails: ( + string, + Js.Json.t, + Fetch.requestMethod, + ~bodyFormData: Fetch.formData=?, + unit, + ) => promise, ~setOrdersData, ~previewOnly, ~setScreenState, @@ -226,7 +233,7 @@ let getOrdersList = async ( try { let ordersUrl = getURL(~entityName=ORDERS, ~methodType=Post, ()) - let res = await updateDetails(ordersUrl, filterValueJson->Js.Json.object_, Fetch.Post) + let res = await updateDetails(ordersUrl, filterValueJson->Js.Json.object_, Fetch.Post, ()) let data = res->LogicUtils.getDictFromJsonObject->LogicUtils.getArrayFromDict("data", []) let total = res->getDictFromJsonObject->getInt("total_count", 0) @@ -242,7 +249,7 @@ let getOrdersList = async ( let newID = payment_id->String.replaceRegExp(%re("/_[0-9]$/g"), "") filterValueJson->Dict.set("payment_id", newID->Js.Json.string) - let res = await updateDetails(ordersUrl, filterValueJson->Js.Json.object_, Fetch.Post) + let res = await updateDetails(ordersUrl, filterValueJson->Js.Json.object_, Fetch.Post, ()) let data = res->LogicUtils.getDictFromJsonObject->LogicUtils.getArrayFromDict("data", []) let total = res->getDictFromJsonObject->getInt("total_count", 0) diff --git a/src/screens/HyperSwitch/Order/ShowOrder.res b/src/screens/HyperSwitch/Order/ShowOrder.res index 7467c9df7..606105a7c 100644 --- a/src/screens/HyperSwitch/Order/ShowOrder.res +++ b/src/screens/HyperSwitch/Order/ShowOrder.res @@ -508,7 +508,7 @@ module FraudRiskBannerDetails = { (), )}/${decision->String.toLowerCase}` - let _ = await updateDetails(ordersDecisionUrl, Dict.make()->Js.Json.object_, Post) + let _ = await updateDetails(ordersDecisionUrl, Dict.make()->Js.Json.object_, Post, ()) showToast(~message="Details Updated", ~toastType=ToastSuccess, ()) refetch() } catch { diff --git a/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res b/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res index a84e29d02..c3af088ef 100644 --- a/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res +++ b/src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res @@ -287,7 +287,7 @@ let make = (~paymentId, ~createdAt) => { ->Dict.fromArray ->Js.Json.object_ let sdkLogsArray = - (await fetchPostDetils(url, body, Post)) + (await fetchPostDetils(url, body, Post, ())) ->getArrayFromJson([]) ->Array.map(event => { let eventDict = event->getDictFromJsonObject diff --git a/src/screens/HyperSwitch/PostLoginScreen/PostLoginScreen.res b/src/screens/HyperSwitch/PostLoginScreen/PostLoginScreen.res index bfd877eb0..c9154d200 100644 --- a/src/screens/HyperSwitch/PostLoginScreen/PostLoginScreen.res +++ b/src/screens/HyperSwitch/PostLoginScreen/PostLoginScreen.res @@ -102,6 +102,7 @@ let make = () => { postLoginSurveyUrl, values->generateSurveyJson->Js.Json.object_, Post, + (), ) HSwitchUtils.setUserDetails("is_metadata_filled", "true"->Js.Json.string) setDashboardPageState(_ => #AUTO_CONNECTOR_INTEGRATION) diff --git a/src/screens/HyperSwitch/Recon/Recon.res b/src/screens/HyperSwitch/Recon/Recon.res index 0e8406f40..2723bf88f 100644 --- a/src/screens/HyperSwitch/Recon/Recon.res +++ b/src/screens/HyperSwitch/Recon/Recon.res @@ -14,7 +14,7 @@ let make = () => { let onClickForReconRequest = async () => { try { let url = getURL(~entityName=RECON, ~reconType=#REQUEST, ~methodType=Get, ()) - let _ = await updateDetails(url, Js.Json.null, Post) + let _ = await updateDetails(url, Js.Json.null, Post, ()) let _ = await fetchMerchantAccountDetails() showToast( ~message=`Thank you for your interest in our reconciliation module. We are currently reviewing your request for access. We will follow up with you soon regarding next steps.`, diff --git a/src/screens/HyperSwitch/Refunds/RefundUtils.res b/src/screens/HyperSwitch/Refunds/RefundUtils.res index cfe903c54..a31b15530 100644 --- a/src/screens/HyperSwitch/Refunds/RefundUtils.res +++ b/src/screens/HyperSwitch/Refunds/RefundUtils.res @@ -1,6 +1,12 @@ let getRefundsList = async ( filterValueJson, - ~updateDetails, + ~updateDetails: ( + string, + Js.Json.t, + Fetch.requestMethod, + ~bodyFormData: Fetch.formData=?, + unit, + ) => promise, ~setRefundsData, ~setScreenState, ~offset, @@ -12,7 +18,7 @@ let getRefundsList = async ( setScreenState(_ => PageLoaderWrapper.Loading) try { let refundsUrl = getURL(~entityName=REFUNDS, ~methodType=Post, ~id=Some("refund-post"), ()) - let res = await updateDetails(refundsUrl, filterValueJson->Js.Json.object_, Fetch.Post) + let res = await updateDetails(refundsUrl, filterValueJson->Js.Json.object_, Fetch.Post, ()) let data = res->getDictFromJsonObject->getArrayFromDict("data", []) let total = res->getDictFromJsonObject->getInt("total_count", 0) diff --git a/src/screens/HyperSwitch/Routing/ActiveRouting.res b/src/screens/HyperSwitch/Routing/ActiveRouting.res index de756eeef..513f58ea5 100644 --- a/src/screens/HyperSwitch/Routing/ActiveRouting.res +++ b/src/screens/HyperSwitch/Routing/ActiveRouting.res @@ -50,7 +50,7 @@ module ActionButtons = { (), ) let body = [("Feedback", requestedBody)]->LogicUtils.getJsonFromArrayOfJson - let _ = await updateDetails(feedbackUrl, body, Post) + let _ = await updateDetails(feedbackUrl, body, Post, ()) showToast( ~toastType=ToastSuccess, ~message="Request submitted successfully!", diff --git a/src/screens/HyperSwitch/Routing/DefaultRouting.res b/src/screens/HyperSwitch/Routing/DefaultRouting.res index 250001539..045809f0c 100644 --- a/src/screens/HyperSwitch/Routing/DefaultRouting.res +++ b/src/screens/HyperSwitch/Routing/DefaultRouting.res @@ -76,7 +76,9 @@ let make = () => { ~methodType=Post, (), )}/profile/${profile}` - (await updateDetails(defaultFallbackUpdateUrl, defaultPayload->Js.Json.array, Post))->ignore + ( + await updateDetails(defaultFallbackUpdateUrl, defaultPayload->Js.Json.array, Post, ()) + )->ignore RescriptReactRouter.replace(`/routing/default`) setScreenState(_ => PageLoaderWrapper.Success) } catch { diff --git a/src/screens/HyperSwitch/Routing/PriorityRouting.res b/src/screens/HyperSwitch/Routing/PriorityRouting.res index 20592a4a4..1d91c6ed4 100644 --- a/src/screens/HyperSwitch/Routing/PriorityRouting.res +++ b/src/screens/HyperSwitch/Routing/PriorityRouting.res @@ -46,6 +46,7 @@ module SimpleRoutingView = { "", )->Js.Json.object_, Post, + (), ) showToast( @@ -65,7 +66,7 @@ module SimpleRoutingView = { try { setScreenState(_ => Loading) let activateRuleURL = getURL(~entityName=ROUTING, ~methodType=Post, ~id=routingId, ()) - let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post) + let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post, ()) showToast( ~message="Successfully Activated Selected Configuration !", ~toastType=ToastState.ToastSuccess, diff --git a/src/screens/HyperSwitch/Routing/VolumeSplitRouting.res b/src/screens/HyperSwitch/Routing/VolumeSplitRouting.res index 53554b9e8..eca315bae 100644 --- a/src/screens/HyperSwitch/Routing/VolumeSplitRouting.res +++ b/src/screens/HyperSwitch/Routing/VolumeSplitRouting.res @@ -39,7 +39,7 @@ module VolumeRoutingView = { try { setScreenState(_ => PageLoaderWrapper.Loading) let activateRuleURL = getURL(~entityName=ROUTING, ~methodType=Post, ~id=activatingId, ()) - let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post) + let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post, ()) showToast(~message="Successfully Activated !", ~toastType=ToastState.ToastSuccess, ()) RescriptReactRouter.replace(`/routing?`) setScreenState(_ => Success) @@ -69,7 +69,7 @@ module VolumeRoutingView = { setScreenState(_ => Loading) let deactivateRoutingURL = `${getURL(~entityName=ROUTING, ~methodType=Post, ())}/deactivate` let body = [("profile_id", profile->Js.Json.string)]->Dict.fromArray->Js.Json.object_ - let _ = await updateDetails(deactivateRoutingURL, body, Post) + let _ = await updateDetails(deactivateRoutingURL, body, Post, ()) showToast(~message="Successfully Deactivated !", ~toastType=ToastState.ToastSuccess, ()) RescriptReactRouter.replace(`/routing?`) setScreenState(_ => Success) @@ -299,7 +299,7 @@ let make = (~routingRuleId, ~isActive) => { try { setScreenState(_ => PageLoaderWrapper.Loading) let updateUrl = getURL(~entityName=ROUTING, ~methodType=Post, ~id=None, ()) - let res = await updateDetails(updateUrl, values, Post) + let res = await updateDetails(updateUrl, values, Post, ()) showToast( ~message="Successfully Created a new Configuration !", ~toastType=ToastState.ToastSuccess, diff --git a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res index d1c0d0fd7..beb72f276 100644 --- a/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res +++ b/src/screens/HyperSwitch/RoutingRevamp/AdvancedRouting.res @@ -540,7 +540,7 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => { try { setScreenState(_ => Loading) let activateRuleURL = getURL(~entityName=ROUTING, ~methodType=Post, ~id=activatingId, ()) - let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post) + let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post, ()) showToast(~message="Successfully Activated !", ~toastType=ToastState.ToastSuccess, ()) RescriptReactRouter.replace(`/routing?`) setScreenState(_ => Success) @@ -569,7 +569,7 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => { setScreenState(_ => Loading) let deactivateRoutingURL = `${getURL(~entityName=ROUTING, ~methodType=Post, ())}/deactivate` let body = [("profile_id", profile->Js.Json.string)]->Dict.fromArray->Js.Json.object_ - let _ = await updateDetails(deactivateRoutingURL, body, Post) + let _ = await updateDetails(deactivateRoutingURL, body, Post, ()) showToast(~message="Successfully Deactivated !", ~toastType=ToastState.ToastSuccess, ()) RescriptReactRouter.replace(`/routing?`) setScreenState(_ => Success) @@ -629,7 +629,12 @@ let make = (~routingRuleId, ~isActive, ~setCurrentRouting) => { } let getActivateUrl = getURL(~entityName=ROUTING, ~methodType=Post, ~id=None, ()) - let response = await updateDetails(getActivateUrl, payload->Identity.genericTypeToJson, Post) + let response = await updateDetails( + getActivateUrl, + payload->Identity.genericTypeToJson, + Post, + (), + ) showToast( ~message="Successfully Created a new Configuration !", diff --git a/src/screens/HyperSwitch/SDKPayment/TestPayment.res b/src/screens/HyperSwitch/SDKPayment/TestPayment.res index eb1165f95..5e89f1fc2 100644 --- a/src/screens/HyperSwitch/SDKPayment/TestPayment.res +++ b/src/screens/HyperSwitch/SDKPayment/TestPayment.res @@ -53,7 +53,7 @@ let make = ( ->getTypedValueForPayment paymentData.currency = paymentData.currency->getCurrencyValue let body = paymentData->Identity.genericTypeToJson - let response = await updateDetails(url, body, Post) + let response = await updateDetails(url, body, Post, ()) let clientSecret = response->getDictFromJsonObject->getOptionString("client_secret") setPaymentId(_ => response->getDictFromJsonObject->getOptionString("payment_id")) setClientSecret(_ => clientSecret) diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/HSwitchAgreementScreen.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/HSwitchAgreementScreen.res index c6c671dce..7f2bfbabf 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/HSwitchAgreementScreen.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/HSwitchAgreementScreen.res @@ -19,7 +19,7 @@ let make = () => { try { let agreementUrl = getURL(~entityName=USERS, ~userType=#MERCHANT_DATA, ~methodType=Post, ()) let body = ProdOnboardingUtils.getProdApiBody(~parentVariant=#ProductionAgreement, ()) - let _ = await updateDetails(agreementUrl, body, Post) + let _ = await updateDetails(agreementUrl, body, Post, ()) setDashboardPageState(_ => #PROD_ONBOARDING) } catch { | _ => diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/LiveEndpointsSetup.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/LiveEndpointsSetup.res index 95480668e..121a2a217 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/LiveEndpointsSetup.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/LiveEndpointsSetup.res @@ -159,7 +159,7 @@ let make = (~pageView, ~setPageView, ~previewState: option pageView->ProdOnboardingUtils.getPageView) showToast(~message=`Details updated`, ~toastType=ToastState.ToastSuccess, ()) setButtonState(_ => Normal) @@ -175,7 +175,7 @@ let make = (~pageView, ~setPageView, ~previewState: optionJs.Json.string)]->Dict.fromArray->Js.Json.object_ let body = mercahantUpdateBody->MerchantAccountUtils.getSettingsPayload(merchantId) let url = getURL(~entityName=MERCHANT_ACCOUNT, ~methodType=Post, ()) - let merchantInfo = await updateDetails(url, body, Post) + let merchantInfo = await updateDetails(url, body, Post, ()) setMerchantDetailsValue(._ => merchantInfo->Js.Json.stringify) updateLiveEndpoint()->ignore } catch { diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res index 86a3adcd3..335f5bab5 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/ProdOnboardingLanding.res @@ -268,7 +268,7 @@ let make = () => { setButtonState(_ => Loading) let url = getURL(~entityName=USERS, ~userType=#MERCHANT_DATA, ~methodType=Post, ()) let body = ProdOnboardingUtils.getProdApiBody(~parentVariant=#SetupComplete, ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setButtonState(_ => Normal) setDashboardPageState(_ => #HOME) } catch { diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res index aaecf32f6..e0f7155ab 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchProdOnboarding/SetupConnectorCredentials.res @@ -157,7 +157,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { ~connectorId, (), ) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setPageView(_ => pageView->ProdOnboardingUtils.getPageView) } catch { | _ => () @@ -205,7 +205,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { let body = requestPayload->ConnectorUtils.constructConnectorRequestBody(payload) - let res = await updateDetails(url, body, Post) + let res = await updateDetails(url, body, Post, ()) let connectorId = res->getDictFromJsonObject->getString("merchant_connector_id", "") setConnectorID(_ => connectorId) connectorId->updateSetupConnectorCredentials->ignore @@ -268,7 +268,7 @@ let make = (~selectedConnector, ~pageView, ~setPageView, ~setConnectorID) => { )->ignoreFields(connectorID, verifyConnectorIgnoreField) let url = getURL(~entityName=CONNECTOR, ~methodType=Post, ~connector=Some(connectorName), ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setShowVerifyModal(_ => false) onSubmitMain(values)->ignore setIsLoading(_ => false) diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/IntegrationDocs.res b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/IntegrationDocs.res index 93f30524b..00e7e5a97 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/IntegrationDocs.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/IntegrationDocs.res @@ -25,7 +25,7 @@ module RequestPage = { ->Js.Json.object_ let body = [("Feedback", requestedBody)]->LogicUtils.getJsonFromArrayOfJson - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) showToast( ~toastType=ToastSuccess, ~message="Request submitted successfully!", diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboarding.res b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboarding.res index 41d200c24..6519f2578 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboarding.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboarding.res @@ -118,7 +118,7 @@ let make = () => { ~metadata=metaDataDict, (), ) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setIntegrationDetails(_ => body->ProviderHelper.getIntegrationDetails) } catch { | _ => () @@ -144,7 +144,7 @@ let make = () => { ->Js.Json.object_, (), ) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setIntegrationDetails(_ => body->ProviderHelper.getIntegrationDetails) setDashboardPageState(_ => #HOME) } catch { diff --git a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res index 0bfebfccb..3e456275c 100644 --- a/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res +++ b/src/screens/HyperSwitch/SelfServe/HSwitchSandboxOnboarding/UserOnboardingUIUtils.res @@ -62,7 +62,7 @@ module DownloadAPIKeyButton = { ("description", "Default Value of the API key"->Js.Json.string), ("expiration", "never"->Js.Json.string), ]->Dict.fromArray - let res = await updateDetails(url, body->Js.Json.object_, Post) + let res = await updateDetails(url, body->Js.Json.object_, Post, ()) let apiKey = res->LogicUtils.getDictFromJsonObject->LogicUtils.getString("api_key", "") DownloadUtils.downloadOld(~fileName=`apiKey.txt`, ~content=apiKey) Clipboard.writeText(apiKey) @@ -422,7 +422,7 @@ module LandingPageTileForIntegrateDocs = { ~metadata=metaDataDict, (), ) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setIntegrationDetails(_ => body->ProviderHelper.getIntegrationDetails) } catch { | _ => () diff --git a/src/screens/HyperSwitch/Settings/BusinessDetails.res b/src/screens/HyperSwitch/Settings/BusinessDetails.res index 7d46b2b58..12bd0d3d5 100644 --- a/src/screens/HyperSwitch/Settings/BusinessDetails.res +++ b/src/screens/HyperSwitch/Settings/BusinessDetails.res @@ -74,6 +74,7 @@ let make = () => { accountUrl, values->getSettingsPayload(uid->Belt.Option.getWithDefault("")), Post, + (), ) setFormState(_ => Preview) let merchantInfo = merchantDetails->getMerchantDetails->parseMerchantJson diff --git a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res index b1ef4381d..d3fb1db5b 100644 --- a/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res +++ b/src/screens/HyperSwitch/Settings/BusinessMapping/BusinessProfile.res @@ -139,7 +139,7 @@ let make = ( try { setScreenState(_ => PageLoaderWrapper.Loading) let url = getURL(~entityName=BUSINESS_PROFILE, ~methodType=Post, ()) - let response = await updateDetails(url, body, Post) + let response = await updateDetails(url, body, Post, ()) setUpdatedProfileId(_ => response->LogicUtils.getDictFromJsonObject->LogicUtils.getString("profile_id", "") ) diff --git a/src/screens/HyperSwitch/Settings/HSwitchProfileSettings.res b/src/screens/HyperSwitch/Settings/HSwitchProfileSettings.res index 62b0c7356..2a3456567 100644 --- a/src/screens/HyperSwitch/Settings/HSwitchProfileSettings.res +++ b/src/screens/HyperSwitch/Settings/HSwitchProfileSettings.res @@ -73,7 +73,7 @@ module ResetPassword = { setIsLoading(_ => true) try { let url = getURL(~entityName=USERS, ~userType=#FORGOT_PASSWORD, ~methodType=Post, ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) showToast(~message="Please check your registered e-mail", ~toastType=ToastSuccess, ()) setIsLoading(_ => false) } catch { diff --git a/src/screens/HyperSwitch/Settings/HSwitchSettings.res b/src/screens/HyperSwitch/Settings/HSwitchSettings.res index 8de37017a..a04bf50eb 100644 --- a/src/screens/HyperSwitch/Settings/HSwitchSettings.res +++ b/src/screens/HyperSwitch/Settings/HSwitchSettings.res @@ -28,7 +28,7 @@ module TileComponent = { let deleteSampleData = async () => { try { let generateSampleDataUrl = getURL(~entityName=GENERATE_SAMPLE_DATA, ~methodType=Delete, ()) - let _ = await updateDetails(generateSampleDataUrl, Dict.make()->Js.Json.object_, Delete) + let _ = await updateDetails(generateSampleDataUrl, Dict.make()->Js.Json.object_, Delete, ()) showToast(~message="Sample data deleted successfully", ~toastType=ToastSuccess, ()) } catch { | _ => () diff --git a/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccount.res b/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccount.res index 719d84cb5..caef4c3ec 100644 --- a/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccount.res +++ b/src/screens/HyperSwitch/SetupAccount/HSwitchSetupAccount.res @@ -39,7 +39,7 @@ let make = () => { ~profileId=activeBusinessProfile.profile_id, ) let stripeTestRes = - (await updateDetails(url, stripeTestBody, Post)) + (await updateDetails(url, stripeTestBody, Post, ())) ->getDictFromJsonObject ->ConnectorTableUtils.getProcessorPayloadType @@ -49,7 +49,7 @@ let make = () => { ~profileId=activeBusinessProfile.profile_id, ) let payPalTestRes = - (await updateDetails(url, paypalTestBody, Post)) + (await updateDetails(url, paypalTestBody, Post, ())) ->getDictFromJsonObject ->ConnectorTableUtils.getProcessorPayloadType let _ = await fetchConnectorListResponse() @@ -71,17 +71,18 @@ let make = () => { routingUrl, activeBusinessProfile.profile_id->routingPayload(stripTestRouting, payPalTestRouting), Post, + (), ) ) ->getDictFromJsonObject ->getOptionString("id") let activateRuleURL = getURL(~entityName=ROUTING, ~methodType=Post, ~id=activatingId, ()) - let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post) + let _ = await updateDetails(activateRuleURL, Dict.make()->Js.Json.object_, Post, ()) setStepCounter(_ => #ROUTING_ENABLED) // *GENERATE_SAMPLE_DATA let generateSampleDataUrl = getURL(~entityName=GENERATE_SAMPLE_DATA, ~methodType=Post, ()) - let _ = await updateDetails(generateSampleDataUrl, Dict.make()->Js.Json.object_, Post) + let _ = await updateDetails(generateSampleDataUrl, Dict.make()->Js.Json.object_, Post, ()) setStepCounter(_ => #GENERATE_SAMPLE_DATA) await delay(delayTime) setStepCounter(_ => #COMPLETED) @@ -95,7 +96,7 @@ let make = () => { (), ) let integrationUrl = getURL(~entityName=INTEGRATION_DETAILS, ~methodType=Post, ()) - let _ = await updateDetails(integrationUrl, body, Post) + let _ = await updateDetails(integrationUrl, body, Post, ()) setIntegrationDetails(_ => body->ProviderHelper.getIntegrationDetails) setDashboardPageState(_ => #INTEGRATION_DOC) } catch { diff --git a/src/screens/HyperSwitch/StripePlusPaypal/StripePlusPaypalUIUtils.res b/src/screens/HyperSwitch/StripePlusPaypal/StripePlusPaypalUIUtils.res index 9673d120c..2c437462a 100644 --- a/src/screens/HyperSwitch/StripePlusPaypal/StripePlusPaypalUIUtils.res +++ b/src/screens/HyperSwitch/StripePlusPaypal/StripePlusPaypalUIUtils.res @@ -87,7 +87,7 @@ module SelectPaymentMethods = { #MultipleProcessorWithSmartRouting->QuickStartUtils.connectorChoiceVariantToString, ) } - let response = await updateAPIHook(connectorUrl, body, Post) + let response = await updateAPIHook(connectorUrl, body, Post, ()) setInitialValues(_ => response) response->LogicUtils.getDictFromJsonObject->updateEnumForConnector->ignore setConnectorConfigureState(_ => Summary) diff --git a/src/screens/HyperSwitch/Surcharge/Surcharge.res b/src/screens/HyperSwitch/Surcharge/Surcharge.res index 677306a12..8b3a4ef55 100644 --- a/src/screens/HyperSwitch/Surcharge/Surcharge.res +++ b/src/screens/HyperSwitch/Surcharge/Surcharge.res @@ -169,7 +169,12 @@ let make = () => { try { let surchargePayload = values->buildSurchargePayloadBody let getActivateUrl = getURL(~entityName=SURCHARGE, ~methodType=Put, ()) - let _ = await updateDetails(getActivateUrl, surchargePayload->Identity.genericTypeToJson, Put) + let _ = await updateDetails( + getActivateUrl, + surchargePayload->Identity.genericTypeToJson, + Put, + (), + ) fetchDetails()->ignore setShowWarning(_ => true) RescriptReactRouter.replace(`/surcharge`) diff --git a/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res b/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res index 0c24b62f4..1b6cdfb65 100644 --- a/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res +++ b/src/screens/HyperSwitch/SwitchMerchant/SwitchMerchant.res @@ -33,7 +33,7 @@ module NewAccountCreationModal = { try { let url = getURL(~entityName=USERS, ~userType=#CREATE_MERCHANT, ~methodType=Fetch.Post, ()) let body = values - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) let _ = await fetchMerchantIDs() showToast( ~toastType=ToastSuccess, @@ -286,7 +286,7 @@ let make = (~userRole, ~isAddMerchantEnabled=false) => { let url = getURL(~entityName=USERS, ~userType=#SWITCH_MERCHANT, ~methodType=Post, ()) let body = Dict.make() body->Dict.set("merchant_id", value->Js.Json.string) - let res = await updateDetails(url, body->Js.Json.object_, Post) + let res = await updateDetails(url, body->Js.Json.object_, Post, ()) let responseDict = res->getDictFromJsonObject let token = responseDict->getString("token", "") let switchedMerchantId = responseDict->getString("merchant_id", "") diff --git a/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res b/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res index c6e897dce..b63b6f99b 100644 --- a/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res +++ b/src/screens/HyperSwitch/ThreeDSFlow/HSwitchThreeDS.res @@ -187,7 +187,12 @@ let make = () => { let threeDsPayload = values->buildThreeDsPayloadBody let getActivateUrl = getURL(~entityName=THREE_DS, ~methodType=Put, ()) - let _ = await updateDetails(getActivateUrl, threeDsPayload->Identity.genericTypeToJson, Put) + let _ = await updateDetails( + getActivateUrl, + threeDsPayload->Identity.genericTypeToJson, + Put, + (), + ) fetchDetails()->ignore setShowWarning(_ => true) RescriptReactRouter.replace(`/3ds`) diff --git a/src/screens/HyperSwitch/UserManagement/InviteUsers.res b/src/screens/HyperSwitch/UserManagement/InviteUsers.res index 9823d77ac..3c19a26bd 100644 --- a/src/screens/HyperSwitch/UserManagement/InviteUsers.res +++ b/src/screens/HyperSwitch/UserManagement/InviteUsers.res @@ -88,7 +88,7 @@ let make = () => { let inviteUserReq = async (body, index) => { try { let url = getURL(~entityName=USERS, ~userType=#INVITE, ~methodType=Post, ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) if index === 0 { showToast(~message=`Invite(s) sent successfully via Email`, ~toastType=ToastSuccess, ()) } diff --git a/src/screens/HyperSwitch/UserManagement/ShowUserData.res b/src/screens/HyperSwitch/UserManagement/ShowUserData.res index 51e1a4459..8e12cf3cc 100644 --- a/src/screens/HyperSwitch/UserManagement/ShowUserData.res +++ b/src/screens/HyperSwitch/UserManagement/ShowUserData.res @@ -16,7 +16,7 @@ module UserHeading = { try { let url = getURL(~entityName=USERS, ~userType=#RESEND_INVITE, ~methodType=Post, ()) let body = [("user_id", userId->Js.Json.string)]->Dict.fromArray->Js.Json.object_ - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) showToast(~message=`Invite resend. Please check your email.`, ~toastType=ToastSuccess, ()) } catch { | _ => () diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res index 84c29b58e..a4e3ee55c 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchAuth.res @@ -35,7 +35,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, let getUserWithEmail = async body => { try { let url = getURL(~entityName=USERS, ~userType=#CONNECT_ACCOUNT, ~methodType=Post, ()) - let res = await updateDetails(url, body, Post) + let res = await updateDetails(url, body, Post, ()) let valuesDict = res->getDictFromJsonObject let magicLinkSent = valuesDict->LogicUtils.getBool("is_email_sent", false) @@ -53,7 +53,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, let getUserWithEmailPassword = async (body, email, userType) => { try { let url = getURL(~entityName=USERS, ~userType, ~methodType=Post, ()) - let res = await updateDetails(url, body, Post) + let res = await updateDetails(url, body, Post, ()) let token = parseResponseJson(~json=res, ~email) // home @@ -78,7 +78,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, let setResetPassword = async body => { try { let url = getURL(~entityName=USERS, ~userType=#RESET_PASSWORD, ~methodType=Post, ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) RescriptReactRouter.push("/") showToast(~message=`Password Changed Successfully`, ~toastType=ToastSuccess, ()) setAuthType(_ => LoginWithEmail) @@ -92,7 +92,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, let setForgetPassword = async body => { try { let url = getURL(~entityName=USERS, ~userType=#FORGOT_PASSWORD, ~methodType=Post, ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setAuthType(_ => ForgetPasswordEmailSent) showToast(~message="Please check your registered e-mail", ~toastType=ToastSuccess, ()) } catch { @@ -104,7 +104,7 @@ let make = (~setAuthStatus: HyperSwitchAuthTypes.authStatus => unit, ~authType, let resendVerifyEmail = async body => { try { let url = getURL(~entityName=USERS, ~userType=#VERIFY_EMAIL_REQUEST, ~methodType=Post, ()) - let _ = await updateDetails(url, body, Post) + let _ = await updateDetails(url, body, Post, ()) setAuthType(_ => ResendVerifyEmailSent) showToast(~message="Please check your registered e-mail", ~toastType=ToastSuccess, ()) } catch { diff --git a/src/screens/login/HSwitchLoginFlow/HyperSwitchEmailVerifyScreen.res b/src/screens/login/HSwitchLoginFlow/HyperSwitchEmailVerifyScreen.res index dc412e9b3..6cc840513 100644 --- a/src/screens/login/HSwitchLoginFlow/HyperSwitchEmailVerifyScreen.res +++ b/src/screens/login/HSwitchLoginFlow/HyperSwitchEmailVerifyScreen.res @@ -24,7 +24,7 @@ let make = (~setAuthType, ~setAuthStatus, ~authType) => { let userType = authType == HyperSwitchAuthTypes.EmailVerify ? #VERIFY_EMAIL : #VERIFY_MAGIC_LINK let url = getURL(~entityName=USERS, ~methodType=Post, ~userType, ()) - let res = await updateDetails(url, body, Post) + let res = await updateDetails(url, body, Post, ()) let email = res ->Js.Json.decodeObject From 2854558f010fcbbd0967d6d817a258d75d7afbcb Mon Sep 17 00:00:00 2001 From: Riddhi Agrawal Date: Wed, 17 Jan 2024 12:20:50 +0530 Subject: [PATCH 2/3] fix: removed unused code --- src/hooks/AuthHooks.res | 1 - src/screens/HyperSwitch/Routing/DefaultRouting.res | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res index 0f558c915..abdf6a712 100644 --- a/src/hooks/AuthHooks.res +++ b/src/hooks/AuthHooks.res @@ -23,7 +23,6 @@ let getHeaders = (~uri, ~headers, ~isFromFormData, ()) => { } else if isFromFormData { let headerObj = { "Authorization": `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`, - "api-key": headers->Dict.get("api-key")->Belt.Option.getWithDefault("hyperswitch"), } Fetch.HeadersInit.make(headerObj) } else { diff --git a/src/screens/HyperSwitch/Routing/DefaultRouting.res b/src/screens/HyperSwitch/Routing/DefaultRouting.res index 045809f0c..23dbd9e14 100644 --- a/src/screens/HyperSwitch/Routing/DefaultRouting.res +++ b/src/screens/HyperSwitch/Routing/DefaultRouting.res @@ -76,6 +76,7 @@ let make = () => { ~methodType=Post, (), )}/profile/${profile}` + ( await updateDetails(defaultFallbackUpdateUrl, defaultPayload->Js.Json.array, Post, ()) )->ignore From 31bdb2ca7c900f499dc378dc153a96a4420fec08 Mon Sep 17 00:00:00 2001 From: Riddhi Agrawal Date: Tue, 23 Jan 2024 12:18:43 +0530 Subject: [PATCH 3/3] fix: update useApiFetcher function --- src/hooks/AuthHooks.res | 16 +++------------- src/screens/HyperSwitch/APIUtils/APIUtils.res | 11 ++--------- src/screens/HyperSwitch/Order/OrderUIUtils.res | 8 +------- src/screens/HyperSwitch/Refunds/RefundUtils.res | 8 +------- 4 files changed, 7 insertions(+), 36 deletions(-) diff --git a/src/hooks/AuthHooks.res b/src/hooks/AuthHooks.res index 15b66147a..bd4440a0b 100644 --- a/src/hooks/AuthHooks.res +++ b/src/hooks/AuthHooks.res @@ -10,7 +10,7 @@ type sessionStorage = { external dictToObj: Js.Dict.t<'a> => {..} = "%identity" @val external atob: string => string = "atob" -let getHeaders = (~uri, ~headers, ~isFromFormData, ()) => { +let getHeaders = (~uri, ~headers, ()) => { let hyperSwitchToken = LocalStorage.getItem("login")->Js.Nullable.toOption let isMixpanel = uri->String.includes("mixpanel") @@ -20,11 +20,6 @@ let getHeaders = (~uri, ~headers, ~isFromFormData, ()) => { "accept": "application/json", } Fetch.HeadersInit.make(headerObj) - } else if isFromFormData { - let headerObj = { - "Authorization": `Bearer ${hyperSwitchToken->Belt.Option.getWithDefault("")}`, - } - Fetch.HeadersInit.make(headerObj) } else { let headerObj = headers->Dict.get("api-key")->Option.getWithDefault("")->String.length > 0 @@ -86,7 +81,6 @@ let useApiFetcher = () => { ( uri, ~bodyStr: string="", - ~bodyFormData=None, ~headers=Dict.make(), ~bodyHeader as _=?, ~method_: Fetch.requestMethod, @@ -104,11 +98,7 @@ let useApiFetcher = () => { let body = switch method_ { | Get => resolve(None) - | _ => - switch bodyFormData { - | Some(formDataVal) => resolve(Some(Fetch.BodyInit.makeWithFormData(formDataVal))) - | None => resolve(Some(Fetch.BodyInit.make(bodyStr))) - } + | _ => resolve(Some(Fetch.BodyInit.make(bodyStr))) } body->then(body => { @@ -119,7 +109,7 @@ let useApiFetcher = () => { ~method_, ~body?, ~credentials=SameOrigin, - ~headers=getHeaders(~headers, ~uri, ~isFromFormData=bodyFormData->Option.isSome, ()), + ~headers=getHeaders(~headers, ~uri, ()), (), ), ) diff --git a/src/screens/HyperSwitch/APIUtils/APIUtils.res b/src/screens/HyperSwitch/APIUtils/APIUtils.res index 43ff2696e..b466c8d4a 100644 --- a/src/screens/HyperSwitch/APIUtils/APIUtils.res +++ b/src/screens/HyperSwitch/APIUtils/APIUtils.res @@ -203,7 +203,6 @@ let handleLogout = async ( ~fetchApi as _: ( Js.String2.t, ~bodyStr: string=?, - ~bodyFormData: option=?, ~headers: Js.Dict.t=?, ~bodyHeader: Js.Dict.t=?, ~method_: Fetch.requestMethod, @@ -388,15 +387,9 @@ let useUpdateMethod = (~showErrorToast=true, ()) => { }, }) - async (url, body, method, ~bodyFormData=?, ()) => { + async (url, body, method, ()) => { try { - let res = await fetchApi( - url, - ~method_=method, - ~bodyStr=body->Js.Json.stringify, - ~bodyFormData, - (), - ) + let res = await fetchApi(url, ~method_=method, ~bodyStr=body->Js.Json.stringify, ()) await responseHandler( ~res, ~showErrorToast, diff --git a/src/screens/HyperSwitch/Order/OrderUIUtils.res b/src/screens/HyperSwitch/Order/OrderUIUtils.res index 1bf64ac13..a0b9174f5 100644 --- a/src/screens/HyperSwitch/Order/OrderUIUtils.res +++ b/src/screens/HyperSwitch/Order/OrderUIUtils.res @@ -213,13 +213,7 @@ let setData = ( let getOrdersList = async ( filterValueJson, - ~updateDetails: ( - string, - Js.Json.t, - Fetch.requestMethod, - ~bodyFormData: Fetch.formData=?, - unit, - ) => promise, + ~updateDetails: (string, Js.Json.t, Fetch.requestMethod, unit) => promise, ~setOrdersData, ~previewOnly, ~setScreenState, diff --git a/src/screens/HyperSwitch/Refunds/RefundUtils.res b/src/screens/HyperSwitch/Refunds/RefundUtils.res index a31b15530..c7b786427 100644 --- a/src/screens/HyperSwitch/Refunds/RefundUtils.res +++ b/src/screens/HyperSwitch/Refunds/RefundUtils.res @@ -1,12 +1,6 @@ let getRefundsList = async ( filterValueJson, - ~updateDetails: ( - string, - Js.Json.t, - Fetch.requestMethod, - ~bodyFormData: Fetch.formData=?, - unit, - ) => promise, + ~updateDetails: (string, Js.Json.t, Fetch.requestMethod, unit) => promise, ~setRefundsData, ~setScreenState, ~offset,