Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Use apifetcher function update #283

Merged
merged 12 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/HSwitchFeedBackModal.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/entryPoints/hyperswitch/HyperSwitchEntry.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ let useUpdateMethod = (~showErrorToast=true, ()) => {
},
})

async (url, body, method) => {
async (url, body, method, ()) => {
try {
let res = await fetchApi(url, ~method_=method, ~bodyStr=body->Js.Json.stringify, ())
await responseHandler(
Expand Down
6 changes: 3 additions & 3 deletions src/screens/HyperSwitch/Analytics/Analytics.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Connectors/ConnectorPreview.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/screens/HyperSwitch/Developer/APIKeys/KeyManagement.res
Original file line number Diff line number Diff line change
Expand Up @@ -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", ""))
Expand Down Expand Up @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, ())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ 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 {
| _ => ()
}
Js.Nullable.null
}

let setFRMValues = async body => {
fetchApi(frmUrl, body, Fetch.Post)
fetchApi(frmUrl, body, Fetch.Post, ())
->thenResolve(res => {
setCurrentStep(prev => prev->getNextStep)
let _ = updateMerchantDetails()
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/FraudAndRisk/FRMSummary.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/HSwitchRemoteFilter.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ 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,
~methodType=Post,
~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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
| _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Home/QuickStart/GoLive.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!",
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Hooks/EnumVariantHook.res
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Order/OrderRefundForm.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions src/screens/HyperSwitch/Order/OrderUIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -212,7 +213,7 @@ let setData = (

let getOrdersList = async (
filterValueJson,
~updateDetails,
~updateDetails: (string, Js.Json.t, Fetch.requestMethod, unit) => promise<Js.Json.t>,
~setOrdersData,
~previewOnly,
~setScreenState,
Expand All @@ -226,7 +227,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)

Expand All @@ -242,7 +243,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)

Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Order/ShowOrder.res
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/PaymentLogs/PaymentLogs.res
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Recon/Recon.res
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
Expand Down
4 changes: 2 additions & 2 deletions src/screens/HyperSwitch/Refunds/RefundUtils.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let getRefundsList = async (
filterValueJson,
~updateDetails,
~updateDetails: (string, Js.Json.t, Fetch.requestMethod, unit) => promise<Js.Json.t>,
~setRefundsData,
~setScreenState,
~offset,
Expand All @@ -12,7 +12,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)

Expand Down
Loading
Loading