Created
September 28, 2020 20:15
-
-
Save kurt-mueller-osumc/d6ae5092f4aa0e7f590fea699e2535b2 to your computer and use it in GitHub Desktop.
Creating JSON bodies, using anonymous F# records, for API requests
This file contains hidden or 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
type Request = { | |
ApiToken: ApiToken | |
ProjectId: ProjectId | |
StartingAt: ObjectId option | |
} | |
module Request = | |
let toJson request = | |
let (ProjectId projectId) = request.ProjectId | |
let baseJson = {| scope = {| project = projectId | |
recurse = true |} | |
describe = true |} | |
match request.StartingAt with | |
| Some (ObjectId objectId) -> | |
{| baseJson with starting = {| project = projectId | |
id = objectId |} |} | |
| None -> | |
baseJson |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The F# compiler gives me the following errors for line 20: