-
Notifications
You must be signed in to change notification settings - Fork 84
/
PlaceOrder.PublicTypes.fs
129 lines (95 loc) · 2.95 KB
/
PlaceOrder.PublicTypes.fs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// We are defining types and submodules, so we can use a namespace
// rather than a module at the top level
namespace OrderTaking.PlaceOrder
open OrderTaking.Common
// ==================================
// This file contains the definitions of PUBLIC types (exposed at the boundary of the bounded context)
// related to the PlaceOrder workflow
// ==================================
// ==================================
// PlaceOrder workflow
// ==================================
// ------------------------------------
// inputs to the workflow
type UnvalidatedCustomerInfo = {
FirstName : string
LastName : string
EmailAddress : string
VipStatus : string
}
type UnvalidatedAddress = {
AddressLine1 : string
AddressLine2 : string
AddressLine3 : string
AddressLine4 : string
City : string
ZipCode : string
State: string
Country: string
}
type UnvalidatedOrderLine = {
OrderLineId : string
ProductCode : string
Quantity : decimal
}
type UnvalidatedOrder = {
OrderId : string
CustomerInfo : UnvalidatedCustomerInfo
ShippingAddress : UnvalidatedAddress
BillingAddress : UnvalidatedAddress
Lines : UnvalidatedOrderLine list
PromotionCode : string
}
// ------------------------------------
// outputs from the workflow (success case)
/// Event will be created if the Acknowledgment was successfully posted
type OrderAcknowledgmentSent = {
OrderId : OrderId
EmailAddress : EmailAddress
}
/// Event to send to shipping context
type OrderPlaced = PricedOrder
type ShippableOrderLine = {
ProductCode : ProductCode
Quantity : OrderQuantity
}
type ShippableOrderPlaced = {
OrderId : OrderId
ShippingAddress : Address
ShipmentLines : ShippableOrderLine list
Pdf : PdfAttachment
}
/// Event to send to billing context
/// Will only be created if the AmountToBill is not zero
type BillableOrderPlaced = {
OrderId : OrderId
BillingAddress: Address
AmountToBill : BillingAmount
}
/// The possible events resulting from the PlaceOrder workflow
/// Not all events will occur, depending on the logic of the workflow
type PlaceOrderEvent =
| ShippableOrderPlaced of ShippableOrderPlaced
| BillableOrderPlaced of BillableOrderPlaced
| AcknowledgmentSent of OrderAcknowledgmentSent
// ------------------------------------
// error outputs
/// All the things that can go wrong in this workflow
type ValidationError = ValidationError of string
type PricingError = PricingError of string
type ServiceInfo = {
Name : string
Endpoint: System.Uri
}
type RemoteServiceError = {
Service : ServiceInfo
Exception : System.Exception
}
type PlaceOrderError =
| Validation of ValidationError
| Pricing of PricingError
| RemoteService of RemoteServiceError
// ------------------------------------
// the workflow itself
type PlaceOrder =
UnvalidatedOrder -> AsyncResult<PlaceOrderEvent list,PlaceOrderError>