-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.fs
More file actions
54 lines (41 loc) · 1.19 KB
/
Program.fs
File metadata and controls
54 lines (41 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Learn more about F# at http://fsharp.org
open System
open Types
open Fns
let showResult result =
match result with
| Ok (productInfoList) ->
printfn "SUCCESS: %A" productInfoList
| Error errs ->
printfn "FAILURE: %A" errs
let setupTestData (api:ApiClient) =
//setup purchases
api.Set (CustId "C1") [ProductId "P1"; ProductId "P2"] |> ignore
api.Set (CustId "C2") [ProductId "PX"; ProductId "P2"] |> ignore
//setup product info
api.Set (ProductId "P1") {ProductName="P1-Name"} |> ignore
api.Set (ProductId "P2") {ProductName="P2-Name"} |> ignore
// P3 missing
// setupTestData is an api-consuming function
// so it can be put in an ApiAction
// and then that apiAction can be executed
let setupAction = ApiAction setupTestData
ApiAction.execute setupAction
[<EntryPoint>]
let main argv =
printfn ""
CustId "C1"
|> getPurchaseInfo
|> ApiAction.execute
|> showResult |> ignore
printfn ""
CustId "C2"
|> getPurchaseInfo
|> ApiAction.execute
|> showResult |> ignore
printfn ""
CustId "CX"
|> getPurchaseInfo
|> ApiAction.execute
|> showResult |> ignore
0 // return an integer exit code