-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: moved part of LoggerUtils to shared code base
- Loading branch information
1 parent
e0194e4
commit baaef9d
Showing
4 changed files
with
68 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
type apiLogType = Request | Response | NoResponse | Err | Method | ||
|
||
let getApiLogValues = ( | ||
apiLogType: apiLogType, | ||
url, | ||
statusCode, | ||
data, | ||
~paymentMethod=?, | ||
~result=?, | ||
) => { | ||
switch apiLogType { | ||
| Request => ([("url", url->JSON.Encode.string)], []) | ||
| Response => ( | ||
[("url", url->JSON.Encode.string), ("statusCode", statusCode->JSON.Encode.string)], | ||
[("response", data)], | ||
) | ||
| NoResponse => ( | ||
[ | ||
("url", url->JSON.Encode.string), | ||
("statusCode", "504"->JSON.Encode.string), | ||
("response", data), | ||
], | ||
[("response", data)], | ||
) | ||
| Err => ( | ||
[ | ||
("url", url->JSON.Encode.string), | ||
("statusCode", statusCode->JSON.Encode.string), | ||
("response", data), | ||
], | ||
[("response", data)], | ||
) | ||
| Method => { | ||
let methodValue = switch paymentMethod { | ||
| Some(method) => method->JSON.Encode.string | ||
| None => ""->JSON.Encode.string | ||
} | ||
let resultValue = switch result { | ||
| Some(res) => res | ||
| None => Dict.make()->JSON.Encode.object | ||
} | ||
([("method", methodValue)], [("result", resultValue)]) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters