From 1fa96c117e4141a7f8408eecff3ea2605287ee63 Mon Sep 17 00:00:00 2001 From: Lokesh Jain Date: Mon, 15 Jan 2024 16:18:01 +0530 Subject: [PATCH] refactor: unused routing Types and utils --- .../HyperSwitch/Routing/RoutingTypes.res | 18 ------------------ .../HyperSwitch/Routing/RoutingUtils.res | 15 ++++++++------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/screens/HyperSwitch/Routing/RoutingTypes.res b/src/screens/HyperSwitch/Routing/RoutingTypes.res index 4852ee162..f3ada070f 100644 --- a/src/screens/HyperSwitch/Routing/RoutingTypes.res +++ b/src/screens/HyperSwitch/Routing/RoutingTypes.res @@ -67,17 +67,6 @@ type condition = { type routingOutputType = {override_3ds: string} -type rule = { - gateways: array, - conditions: array, - routingOutput?: routingOutputType, -} - -type ruleInfoType = { - rules: array, - default_gateways: array, -} - type historyData = { id: string, name: string, @@ -89,10 +78,3 @@ type historyData = { } type value = {"type": Js.Json.t, "value": Js.Json.t} - -type payloadCondition = { - lhs: string, - comparison: string, - value: value, - metadata: Js.Json.t, -} diff --git a/src/screens/HyperSwitch/Routing/RoutingUtils.res b/src/screens/HyperSwitch/Routing/RoutingUtils.res index 0a4f4067a..349d0714b 100644 --- a/src/screens/HyperSwitch/Routing/RoutingUtils.res +++ b/src/screens/HyperSwitch/Routing/RoutingUtils.res @@ -191,7 +191,7 @@ let getWasmGateway = wasm => { let advanceRoutingConditionMapper = (dict, wasm) => { let variantType = wasm->getWasmKeyType(dict->getString("field", "")) - let obj = { + let obj: AdvancedRoutingTypes.statement = { lhs: dict->getString("field", ""), comparison: switch dict->getString("operator", "")->operatorMapper { | IS => "equal" @@ -205,7 +205,7 @@ let advanceRoutingConditionMapper = (dict, wasm) => { | UnknownOperator(str) => str }, value: { - "type": switch variantType->variantTypeMapper { + \"type": switch variantType->variantTypeMapper { | Number => "number" | Enum_variant => switch dict->getString("operator", "")->operatorMapper { @@ -218,8 +218,8 @@ let advanceRoutingConditionMapper = (dict, wasm) => { | Metadata_value => "metadata_variant" | String_value => "str_value" | _ => "" - }->Js.Json.string, - "value": switch variantType->variantTypeMapper { + }, + value: switch variantType->variantTypeMapper { | Number => (dict->getString("value", "")->float_of_string *. 100.00)->Js.Json.number | Enum_variant => switch dict->getString("operator", "")->operatorMapper { @@ -240,15 +240,16 @@ let advanceRoutingConditionMapper = (dict, wasm) => { | _ => ""->Js.Json.string }, }, - metadata: Dict.make()->Js.Json.object_, } - let value = [("value", obj.value["value"]), ("type", obj.value["type"])]->Dict.fromArray + let value = + [("value", obj.value.value), ("type", obj.value.\"type"->Js.Json.string)]->Dict.fromArray + let dict = [ ("lhs", obj.lhs->Js.Json.string), ("comparison", obj.comparison->Js.Json.string), ("value", value->Js.Json.object_), - ("metadata", obj.metadata), + ("metadata", Dict.make()->Js.Json.object_), ]->Dict.fromArray dict->Js.Json.object_