Skip to content

Commit

Permalink
fix: code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Riddhiagrawal001 committed Dec 20, 2023
1 parent cc0df02 commit 55da022
Showing 1 changed file with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ let paypalAPICall = async (~updateDetails, ~connectorId, ~profileId) => {
("connector", "paypal"->Js.Json.string),
("connector_id", connectorId->Js.Json.string),
("profile_id", profileId->Js.Json.string),
]
->Js.Dict.fromArray
->Js.Json.object_
]->LogicUtils.getJsonFromArrayOfJson

let url = `${getURL(~entityName=PAYPAL_ONBOARDING, ~methodType=Post, ())}/sync`
let response = await updateDetails(url, paypalBody, Fetch.Post)
let responseValue =
response->LogicUtils.getDictFromJsonObject->LogicUtils.getJsonObjectFromDict("paypal")
responseValue

response->LogicUtils.getDictFromJsonObject->LogicUtils.getJsonObjectFromDict("paypal")
} catch {
| _ => Js.Json.null
}
Expand Down Expand Up @@ -128,15 +126,14 @@ let handleObjectResponse = (

let getBodyType = (isUpdateFlow, configuartionType, setupAccountStatus) => {
open PayPalFlowTypes
let bodyType = switch (isUpdateFlow, setupAccountStatus) {
switch (isUpdateFlow, setupAccountStatus) {
| (false, _) | (true, Account_not_found) => "TemporaryAuth"
| (true, _) =>
switch configuartionType {
| Manual => "BodyKey"
| Automatic | NotSelected => "SignatureKey"
}
}
bodyType
}

let generateConnectorPayloadPayPal = (
Expand All @@ -158,17 +155,13 @@ let generateConnectorPayloadPayPal = (
("test_mode", true->Js.Json.boolean),
("status", "inactive"->Js.Json.string),
("connector_label", connectorLabel->Js.Json.string),
]
->Js.Dict.fromArray
->Js.Json.object_
]->LogicUtils.getJsonFromArrayOfJson

let body =
generateInitialValuesDict(
~values={initialValues},
~connector,
~bodyType=getBodyType(isUpdateFlow, configuartionType, setupAccountStatus),
~isPayoutFlow=false,
(),
)->ignoreFields(connectorId, connectorIgnoredField)
body
generateInitialValuesDict(
~values={initialValues},
~connector,
~bodyType=getBodyType(isUpdateFlow, configuartionType, setupAccountStatus),
~isPayoutFlow=false,
(),
)->ignoreFields(connectorId, connectorIgnoredField)
}

0 comments on commit 55da022

Please sign in to comment.