Skip to content

Commit

Permalink
fix: Warnings in API - Response removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja committed Dec 6, 2023
1 parent 1930bd2 commit 8420b37
Show file tree
Hide file tree
Showing 50 changed files with 71 additions and 487 deletions.
2 changes: 1 addition & 1 deletion src/entryPoints/hyperswitch/WooCommerce/WooCommerce.res
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ let make = () => {
try {
if forward && !(stepInView->enumToValueMapper(enums)) {
let currentStepVariant = stepInView->variantToEnumMapper
let _resp = await Boolean(true)->usePostEnumDetails(currentStepVariant)
let _ = await Boolean(true)->usePostEnumDetails(currentStepVariant)
}
} catch {
| _ => ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ module SelectPaymentMethods = {
let enumRecoilUpdateArr = []

if enums.firstProcessorConnected.processorID->Js.String2.length === 0 {
let _fPCResp = await body->postEnumDetails(#FirstProcessorConnected)
let _ = await body->postEnumDetails(#FirstProcessorConnected)
enumRecoilUpdateArr->Array.push((body, #FirstProcessorConnected))
}

if !enums.isMultipleConfiguration {
let _mCResp = await Boolean(true)->postEnumDetails(#IsMultipleConfiguration)
let _ = await Boolean(true)->postEnumDetails(#IsMultipleConfiguration)
enumRecoilUpdateArr->Array.push((Boolean(true), #IsMultipleConfiguration))
}

let _res = updateEnumInRecoil(enumRecoilUpdateArr)
let _ = updateEnumInRecoil(enumRecoilUpdateArr)
} catch {
| _ => setButtonState(_ => Button.Normal)
}
Expand Down
6 changes: 3 additions & 3 deletions src/screens/HyperSwitch/APIUtils/APIUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ let handleLogout = async (
~setAuthStatus,
) => {
let logoutUrl = getURL(~entityName=USERS, ~methodType=Post, ~userType=#SIGNOUT, ())
let _res = await fetchApi(logoutUrl, ~method_=Fetch.Post, ())
let _ = await fetchApi(logoutUrl, ~method_=Fetch.Post, ())
setAuthStatus(HyperSwitchAuthTypes.LoggedOut)
LocalStorage.clear()
RescriptReactRouter.push("/register")
Expand Down Expand Up @@ -399,7 +399,7 @@ let useGetMethod = (~showErrorToast=true, ()) => {
_ => {
hyperswitchMixPanel(~eventName=Some(`${urlPath}_tryplayground_register`), ())
hyperswitchMixPanel(~eventName=Some(`global_tryplayground_register`), ())
let _res = handleLogout(~fetchApi, ~setAuthStatus)
let _ = handleLogout(~fetchApi, ~setAuthStatus)
}
},
},
Expand Down Expand Up @@ -460,7 +460,7 @@ let useUpdateMethod = (~showErrorToast=true, ()) => {
_ => {
hyperswitchMixPanel(~eventName=Some(`${urlPath}_tryplayground_register`), ())
hyperswitchMixPanel(~eventName=Some(`global_tryplayground_register`), ())
let _res = handleLogout(~fetchApi, ~setAuthStatus)
let _ = handleLogout(~fetchApi, ~setAuthStatus)
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HyperSwitch/Analytics/DownloadReportModal.res
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let make = (~reportModal, ~setReportModal, ~entityName) => {
let downloadReport = async body => {
try {
let url = getURL(~entityName, ~methodType=Post, ())
let _res = 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,7 +214,7 @@ module OverviewInfo = {
let generateSampleData = async () => {
try {
let generateSampleDataUrl = getURL(~entityName=GENERATE_SAMPLE_DATA, ~methodType=Post, ())
let _generateSampleData = await updateDetails(
let _ = await updateDetails(
generateSampleDataUrl,
[("record", 50.0->Js.Json.number)]->Js.Dict.fromArray->Js.Json.object_,
Post,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,256 +74,6 @@ module APITableInfo = {
}
}

module ConnectorLatency = {
open DynamicSingleStat
open SystemMetricsAnalyticsUtils
open HSAnalyticsUtils
open AnalyticsTypes
@react.component
let make = () => {
let (_totalVolume, setTotalVolume) = React.useState(_ => 0)

let getStatData = (
singleStatData: systemMetricsObjectType,
timeSeriesData: array<systemMetricsSingleStateSeries>,
deltaTimestampData: DynamicSingleStat.deltaRange,
colType,
_mode,
) => {
switch colType {
| Latency | _ => {
title: "Payments Confirm Latency",
tooltipText: "Average time taken for the entire Payments Confirm API call.",
deltaTooltipComponent: AnalyticsUtils.singlestatDeltaTooltipFormat(
singleStatData.latency,
deltaTimestampData.currentSr,
),
value: singleStatData.latency /. 1000.0,
delta: {
singleStatData.latency
},
data: constructData("latency", timeSeriesData),
statType: "LatencyMs",
showDelta: false,
}
}
}

let defaultColumns: array<DynamicSingleStat.columns<systemMetricsSingleStateMetrics>> = [
{
sectionName: "",
columns: [Latency],
},
]

let singleStatBodyMake = (singleStatBodyEntity: singleStatBodyEntity) => {
let filters =
[
("api_name", ["PaymentsConfirm"->Js.Json.string]->Js.Json.array),
("status_code", [200.0->Js.Json.number]->Js.Json.array),
("flow_type", ["Payment"->Js.Json.string]->Js.Json.array),
]
->Js.Dict.fromArray
->Js.Json.object_

[
AnalyticsUtils.getFilterRequestBody(
~filter=filters->Some,
~metrics=singleStatBodyEntity.metrics,
~delta=?singleStatBodyEntity.delta,
~startDateTime=singleStatBodyEntity.startDateTime,
~endDateTime=singleStatBodyEntity.endDateTime,
~mode=singleStatBodyEntity.mode,
~customFilter=?singleStatBodyEntity.customFilter,
~source=?singleStatBodyEntity.source,
~granularity=singleStatBodyEntity.granularity,
~prefix=singleStatBodyEntity.prefix,
(),
)->Js.Json.object_,
]
->Js.Json.array
->Js.Json.stringify
}

let getStatEntity: 'a => DynamicSingleStat.entityType<'colType, 't, 't2> = metrics => {
urlConfig: [
{
uri: `${HSwitchGlobalVars.hyperSwitchApiPrefix}/analytics/v1/metrics/${domain}`,
metrics: metrics->getStringListFromArrayDict,
singleStatBody: singleStatBodyMake,
singleStatTimeSeriesBody: singleStatBodyMake,
},
],
getObjects: itemToObjMapper,
getTimeSeriesObject: timeSeriesObjMapper,
defaultColumns,
getData: getStatData,
totalVolumeCol: None,
matrixUriMapper: _ =>
`${HSwitchGlobalVars.hyperSwitchApiPrefix}/analytics/v1/metrics/${domain}`,
}

let metrics = [Latency->getStringFromVarient]->Js.Array2.map(key => {
[("name", key->Js.Json.string)]->Js.Dict.fromArray->Js.Json.object_
})

let singleStatEntity = getStatEntity(metrics)
let dateDict = HSwitchRemoteFilter.getDateFilteredObject()

<DynamicSingleStat
entity={singleStatEntity}
startTimeFilterKey
endTimeFilterKey
filterKeys={[ApiName, Status_code]->Js.Array2.map(getStringFromVarient)}
moduleName="SystemMetrics"
defaultStartDate={dateDict.start_time}
defaultEndDate={dateDict.end_time}
setTotalVolume
showPercentage=false
isHomePage=false
statSentiment={singleStatEntity.statSentiment->Belt.Option.getWithDefault(Js.Dict.empty())}
/>
}
}

module HSiwtchPaymentConfirmLatency = {
open DynamicSingleStat
open SystemMetricsAnalyticsUtils
open Promise
open LogicUtils
@react.component
let make = () => {
let url = `${HSwitchGlobalVars.hyperSwitchApiPrefix}/analytics/v1/metrics/${domain}`
let (isLoading, setIsLoading) = React.useState(_ => true)
let (latency, setLatency) = React.useState(_ => 0)
let (connectorLatency, setConnectorLatency) = React.useState(_ => 0)
let (overallLatency, setOverallrLatency) = React.useState(_ => 0)
let updateDetails = APIUtils.useUpdateMethod()
let dateDict = HSwitchRemoteFilter.getDateFilteredObject()

let singleStatBodyEntity = {
metrics: ["latency", "api_count", "status_code_count"],
startDateTime: dateDict.start_time,
endDateTime: dateDict.end_time,
}

let singleStatBodyMake = (singleStatBodyEntity: singleStatBodyEntity, flowType) => {
let filters =
[
("api_name", ["PaymentsConfirm"->Js.Json.string]->Js.Json.array),
("status_code", [200.0->Js.Json.number]->Js.Json.array),
("flow_type", [flowType->Js.Json.string]->Js.Json.array),
]
->Js.Dict.fromArray
->Js.Json.object_

[
AnalyticsUtils.getFilterRequestBody(
~filter=filters->Some,
~metrics=singleStatBodyEntity.metrics,
~delta=?singleStatBodyEntity.delta,
~startDateTime=singleStatBodyEntity.startDateTime,
~endDateTime=singleStatBodyEntity.endDateTime,
~mode=singleStatBodyEntity.mode,
~customFilter=?singleStatBodyEntity.customFilter,
~source=?singleStatBodyEntity.source,
~granularity=singleStatBodyEntity.granularity,
~prefix=singleStatBodyEntity.prefix,
(),
)->Js.Json.object_,
]->Js.Json.array
}

let parseJson = json => {
json
->getDictFromJsonObject
->getJsonObjectFromDict("queryData")
->getArrayFromJson([])
->Belt.Array.get(0)
->Belt.Option.getWithDefault(Js.Json.object_(Js.Dict.empty()))
->getDictFromJsonObject
->getInt("latency", 0)
}

let getOverallLatency = async () => {
updateDetails(url, singleStatBodyEntity->singleStatBodyMake("Payment"), Fetch.Post)
->thenResolve(json => {
setOverallrLatency(_ => json->parseJson)
})
->catch(_ => {
setIsLoading(_ => false)
resolve()
})
->ignore
}

let getConnectorLatency = () => {
updateDetails(url, singleStatBodyEntity->singleStatBodyMake("OutgoingEvent"), Fetch.Post)
->thenResolve(json => {
setConnectorLatency(_ => json->parseJson)
setIsLoading(_ => false)
})
->catch(_ => {
setIsLoading(_ => false)
resolve()
})
->ignore
}

React.useEffect2(() => {
let value = overallLatency - connectorLatency
setLatency(_ => value)

None
}, (overallLatency, connectorLatency))

React.useEffect0(() => {
getOverallLatency()->ignore
getConnectorLatency()->ignore

None
})

if isLoading {
<div className={`p-4 w-full`}>
<Shimmer styleClass="w-full h-28" />
</div>
} else {
<div className="mt-4 w-full">
<div
className={`h-full flex flex-col border rounded dark:border-jp-gray-850 bg-white dark:bg-jp-gray-lightgray_background overflow-hidden singlestatBox p-4 mr-4`}>
<div className="px-4 pb-4 pt-1 flex flex-col justify-between h-full gap-auto">
<div className="flex flex-row h-1/2 items-end">
<div className="font-bold text-3xl">
{latencyShortNum(
~labelValue=latency->Belt.Int.toFloat /. 1000.0,
~includeMilliseconds=true,
(),
)
->Js.String2.toLowerCase
->React.string}
</div>
</div>
<div
className={"flex gap-2 items-center pt-4 text-jp-gray-700 font-bold self-start h-1/2"}>
<div className="font-semibold text-base text-black dark:text-white">
{"Hyperswitch overhead for payment confirm"->React.string}
</div>
<ToolTip
description="Average time added by the Hyperswitch application to the overall Payments Confirm API latency"
toolTipFor={<div className="cursor-pointer">
<Icon name="info-vacent" size=13 />
</div>}
toolTipPosition=ToolTip.Top
/>
</div>
</div>
</div>
</div>
}
}
}

module SystemMetricsAnalytics = {
open AnalyticsTypes
open LogicUtils
Expand Down Expand Up @@ -397,14 +147,6 @@ module SystemMetricsAnalytics = {
let filterDataOrig = getFilterData(filterUri, Fetch.Post, filterBody)
let filterData = filterDataOrig->Belt.Option.getWithDefault(Js.Json.object_(Js.Dict.empty()))

let _hideFiltersDefaultValue =
filterValue
->Js.Dict.keys
->Js.Array2.filter(item =>
filteredTabKeys->Js.Array2.find(key => key == item)->Belt.Option.isSome
)
->Js.Array2.length < 1

<UIUtils.RenderIf condition={getModuleFilters->Js.Dict.entries->Js.Array2.length > 0}>
{switch chartEntity1 {
| Some(chartEntity) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ let make = (
~connector=Some(connector),
(),
)
let _response = await updateDetails(url, body, Post)
let _ = await updateDetails(url, body, Post)
setShowVerifyModal(_ => false)
onSubmitMain(values)->ignore
} catch {
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 @@ -257,7 +257,7 @@ let make = (
isConnectorDisabled,
)
let url = getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=Some(connectorID), ())
let _res = 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 _response = await updateAPIHook(`${verifyAppleUrl}/${merchantId}`, body, Post)
let _ = await updateAPIHook(`${verifyAppleUrl}/${merchantId}`, body, Post)

let updatedValue = values->constructApplePayMetadata(metadataInputs, #simplified)
update(updatedValue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ module ApiEditModal = {
}
}

let _res = getAPIKeyDetails()
let _ = getAPIKeyDetails()
} catch {
| Js.Exn.Error(e) =>
switch Js.Exn.message(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ let make = (
->Js.Json.object_
let url = getURL(~entityName=MERCHANT_ACCOUNT, ~methodType=Post, ())
try {
let _res = await updateDetails(url, body, Post)
let _ = await updateDetails(url, body, Post)
} catch {
| _ => ()
}
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 @@ -79,7 +79,7 @@ let make = (~initialValues, ~currentStep, ~setCurrentStep, ~isUpdateFlow) => {
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 _res = 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
Loading

0 comments on commit 8420b37

Please sign in to comment.