Skip to content

Commit

Permalink
refactor: unused routing Types and utils
Browse files Browse the repository at this point in the history
  • Loading branch information
jainlokesh318 committed Jan 15, 2024
1 parent e1144ac commit 1fa96c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
18 changes: 0 additions & 18 deletions src/screens/HyperSwitch/Routing/RoutingTypes.res
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,6 @@ type condition = {

type routingOutputType = {override_3ds: string}

type rule = {
gateways: array<gateway>,
conditions: array<condition>,
routingOutput?: routingOutputType,
}

type ruleInfoType = {
rules: array<rule>,
default_gateways: array<string>,
}

type historyData = {
id: string,
name: string,
Expand All @@ -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,
}
15 changes: 8 additions & 7 deletions src/screens/HyperSwitch/Routing/RoutingUtils.res
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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_
Expand Down

0 comments on commit 1fa96c1

Please sign in to comment.