@eventcatalog/create-eventcatalog 4.3.12-beta.1 → 4.3.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/CreateProduct/examples/index.mdx +194 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/DeleteProduct/examples/index.mdx +161 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/UpdateProduct/examples/index.mdx +182 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductCreated/examples/index.mdx +227 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductDeleted/examples/index.mdx +175 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductUpdated/examples/index.mdx +205 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/queries/GetProduct/examples/index.mdx +205 -0
- package/templates/default/domains/Catalog/systems/search-system/services/SearchAPI/queries/SearchProducts/examples/index.mdx +369 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/RegisterCustomer/examples/index.mdx +168 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/UpdateCustomer/examples/index.mdx +168 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerRegistered/examples/index.mdx +201 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerUpdated/examples/index.mdx +194 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/queries/GetCustomer/examples/index.mdx +194 -0
- package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/commands/AuthenticateCustomer/examples/index.mdx +198 -0
- package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/events/CustomerAuthenticated/examples/index.mdx +276 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentCreated/examples/index.mdx +184 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentDelivered/examples/index.mdx +173 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentFailed/examples/index.mdx +265 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/commands/ReleaseInventory/examples/index.mdx +246 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryReserved/examples/index.mdx +227 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryUnavailable/examples/index.mdx +229 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/queries/GetStockLevel/examples/index.mdx +186 -0
- package/templates/default/domains/Fulfilment/systems/shipping-system/services/CarrierAdapter/commands/CreateShipment/examples/index.mdx +206 -0
- package/templates/default/domains/Fulfilment/systems/warehouse-system/services/PickingWorker/events/OrderPacked/examples/index.mdx +172 -0
- package/templates/default/domains/Fulfilment/systems/warehouse-system/services/WarehouseService/events/OrderReadyForShipping/examples/index.mdx +208 -0
- package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/AuthorizePayment/examples/index.mdx +179 -0
- package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/ReserveInventory/examples/index.mdx +215 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CancelOrder/examples/index.mdx +163 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CreateOrder/examples/index.mdx +246 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCancelled/examples/index.mdx +267 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCompleted/examples/index.mdx +171 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCreated/examples/index.mdx +190 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/queries/GetOrder/examples/index.mdx +343 -0
- package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckFailed/examples/index.mdx +271 -0
- package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckPassed/examples/index.mdx +173 -0
- package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/PaymentRequested/examples/index.mdx +191 -0
- package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/RefundRequested/examples/index.mdx +194 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentFailed/examples/index.mdx +265 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentSucceeded/examples/index.mdx +190 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/RefundProcessed/examples/index.mdx +186 -0
- package/templates/default/domains/Reviews/services/RatingAggregator/events/rating-updated/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/flag-review/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/submit-review/examples/index.mdx +195 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/vote-review-helpful/examples/index.mdx +178 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-flagged/examples/index.mdx +186 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-helpful-voted/examples/index.mdx +177 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-submitted/examples/index.mdx +194 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/queries/get-product-reviews/examples/index.mdx +259 -0
- package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-published/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-rejected/examples/index.mdx +178 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/AddItemToCart/examples/index.mdx +171 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/CheckoutCart/examples/index.mdx +168 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/RemoveItemFromCart/examples/index.mdx +170 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/events/CartCheckedOut/examples/index.mdx +275 -0
- package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/commands/CalculateDiscount/examples/index.mdx +207 -0
- package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/events/DiscountCalculated/examples/index.mdx +190 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Publish a new UK order
|
|
6
|
+
|
|
7
|
+
The Order Service has handled `CreateOrder` for two T-shirts and a cap. It publishes this event so fulfilment can start and the customer gets a confirmation email.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `orderId` is the new order's ID, generated by the Order Service.
|
|
12
|
+
- `customerId` identifies who placed the order.
|
|
13
|
+
- `total` is in pence: 2 × 1,999 + 1 × 1,499.
|
|
14
|
+
- `currency` is `GBP`.
|
|
15
|
+
- `createdAt` is the ISO-8601 UTC time the order was stored.
|
|
16
|
+
|
|
17
|
+
The total is **5,497 pence (£54.97)**.
|
|
18
|
+
|
|
19
|
+
### Using this example
|
|
20
|
+
|
|
21
|
+
Consumers should start fulfilment and show £54.97 in the confirmation email, converting `total` from minor units.
|
|
22
|
+
|
|
23
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the OrderCreated schema. The package names and publish methods are illustrative.
|
|
24
|
+
|
|
25
|
+
</Column>
|
|
26
|
+
|
|
27
|
+
<Column>
|
|
28
|
+
|
|
29
|
+
<CodeGroup dropdown>
|
|
30
|
+
|
|
31
|
+
```typescript publish-order-created.ts
|
|
32
|
+
import { EventsClient } from '@acme/events';
|
|
33
|
+
import type { OrderCreated } from './schemas/order-created';
|
|
34
|
+
|
|
35
|
+
const client = new EventsClient({
|
|
36
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const event: OrderCreated = {
|
|
40
|
+
orderId: '4c7e9a2b-1d3f-4b5a-8e6c-2f9d0a1b3c5e',
|
|
41
|
+
customerId: '3f2b8c1e-7a4d-4e9b-9c6f-1d2e3a4b5c6d',
|
|
42
|
+
total: 5497,
|
|
43
|
+
currency: 'GBP',
|
|
44
|
+
createdAt: '2026-09-11T08:12:45Z',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
await client.publish('OrderCreated', event);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```python publish_order_created.py
|
|
51
|
+
import os
|
|
52
|
+
from acme_events import EventsClient
|
|
53
|
+
|
|
54
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
55
|
+
|
|
56
|
+
event = {
|
|
57
|
+
"orderId": "4c7e9a2b-1d3f-4b5a-8e6c-2f9d0a1b3c5e",
|
|
58
|
+
"customerId": "3f2b8c1e-7a4d-4e9b-9c6f-1d2e3a4b5c6d",
|
|
59
|
+
"total": 5497,
|
|
60
|
+
"currency": "GBP",
|
|
61
|
+
"createdAt": "2026-09-11T08:12:45Z",
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
client.publish("OrderCreated", event)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```java PublishOrderCreated.java
|
|
68
|
+
import com.acme.events.EventsClient;
|
|
69
|
+
import java.util.Map;
|
|
70
|
+
|
|
71
|
+
public class PublishOrderCreated {
|
|
72
|
+
public static void main(String[] args) {
|
|
73
|
+
var client = new EventsClient(
|
|
74
|
+
System.getenv("ACME_API_KEY")
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
var event = Map.of(
|
|
78
|
+
"orderId", "4c7e9a2b-1d3f-4b5a-8e6c-2f9d0a1b3c5e",
|
|
79
|
+
"customerId", "3f2b8c1e-7a4d-4e9b-9c6f-1d2e3a4b5c6d",
|
|
80
|
+
"total", 5497,
|
|
81
|
+
"currency", "GBP",
|
|
82
|
+
"createdAt", "2026-09-11T08:12:45Z"
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
client.publish("OrderCreated", event);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
</CodeGroup>
|
|
91
|
+
|
|
92
|
+
</Column>
|
|
93
|
+
|
|
94
|
+
</Columns>
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
<Columns cols={2}>
|
|
99
|
+
|
|
100
|
+
<Column>
|
|
101
|
+
|
|
102
|
+
## 2. Publish a new euro order
|
|
103
|
+
|
|
104
|
+
A customer in Ireland orders one hoodie priced in euros. The event has the same shape, but amounts are in euro cents.
|
|
105
|
+
|
|
106
|
+
### Payload details
|
|
107
|
+
|
|
108
|
+
- `orderId` and `customerId` identify the order and the customer.
|
|
109
|
+
- `total` is in cents: 1 × 5,799 for the hoodie.
|
|
110
|
+
- `currency` is `EUR`.
|
|
111
|
+
- `createdAt` is the ISO-8601 UTC time the order was stored.
|
|
112
|
+
|
|
113
|
+
The total is **5,799 cents (€57.99)**.
|
|
114
|
+
|
|
115
|
+
### Using this example
|
|
116
|
+
|
|
117
|
+
Use this to check that consumers format `total` with the event's `currency` and do not assume pounds.
|
|
118
|
+
|
|
119
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the OrderCreated schema. The package names and publish methods are illustrative.
|
|
120
|
+
|
|
121
|
+
</Column>
|
|
122
|
+
|
|
123
|
+
<Column>
|
|
124
|
+
|
|
125
|
+
<CodeGroup dropdown>
|
|
126
|
+
|
|
127
|
+
```typescript publish-order-created.ts
|
|
128
|
+
import { EventsClient } from '@acme/events';
|
|
129
|
+
import type { OrderCreated } from './schemas/order-created';
|
|
130
|
+
|
|
131
|
+
const client = new EventsClient({
|
|
132
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const event: OrderCreated = {
|
|
136
|
+
orderId: 'b5d8e1f2-6a3c-4d7b-9f0e-3a4b5c6d7e8f',
|
|
137
|
+
customerId: '8a7c6e5d-2b1f-4c3a-9e8d-7f6a5b4c3d2e',
|
|
138
|
+
total: 5799,
|
|
139
|
+
currency: 'EUR',
|
|
140
|
+
createdAt: '2026-09-14T17:03:10Z',
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
await client.publish('OrderCreated', event);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```python publish_order_created.py
|
|
147
|
+
import os
|
|
148
|
+
from acme_events import EventsClient
|
|
149
|
+
|
|
150
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
151
|
+
|
|
152
|
+
event = {
|
|
153
|
+
"orderId": "b5d8e1f2-6a3c-4d7b-9f0e-3a4b5c6d7e8f",
|
|
154
|
+
"customerId": "8a7c6e5d-2b1f-4c3a-9e8d-7f6a5b4c3d2e",
|
|
155
|
+
"total": 5799,
|
|
156
|
+
"currency": "EUR",
|
|
157
|
+
"createdAt": "2026-09-14T17:03:10Z",
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
client.publish("OrderCreated", event)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```java PublishOrderCreated.java
|
|
164
|
+
import com.acme.events.EventsClient;
|
|
165
|
+
import java.util.Map;
|
|
166
|
+
|
|
167
|
+
public class PublishOrderCreated {
|
|
168
|
+
public static void main(String[] args) {
|
|
169
|
+
var client = new EventsClient(
|
|
170
|
+
System.getenv("ACME_API_KEY")
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
var event = Map.of(
|
|
174
|
+
"orderId", "b5d8e1f2-6a3c-4d7b-9f0e-3a4b5c6d7e8f",
|
|
175
|
+
"customerId", "8a7c6e5d-2b1f-4c3a-9e8d-7f6a5b4c3d2e",
|
|
176
|
+
"total", 5799,
|
|
177
|
+
"currency", "EUR",
|
|
178
|
+
"createdAt", "2026-09-14T17:03:10Z"
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
client.publish("OrderCreated", event);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
</CodeGroup>
|
|
187
|
+
|
|
188
|
+
</Column>
|
|
189
|
+
|
|
190
|
+
</Columns>
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Fetch a newly created order
|
|
6
|
+
|
|
7
|
+
Right after checkout, the order confirmation page queries the Order Service for the new order. It is still `CREATED` because it has not been fulfilled yet.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `request.orderId` is the ID returned when the order was created.
|
|
12
|
+
- `status` is `CREATED`.
|
|
13
|
+
- `items` has 2 lines: 2 × T-shirt at 1,999 pence and 1 × cap at 1,499 pence.
|
|
14
|
+
- `total` and `currency` give the order value; `createdAt` is when it was stored.
|
|
15
|
+
|
|
16
|
+
The total is **5,497 pence (£54.97)**.
|
|
17
|
+
|
|
18
|
+
### Example response
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"orderId": "4c7e9a2b-1d3f-4b5a-8e6c-2f9d0a1b3c5e",
|
|
23
|
+
"customerId": "3f2b8c1e-7a4d-4e9b-9c6f-1d2e3a4b5c6d",
|
|
24
|
+
"status": "CREATED",
|
|
25
|
+
"items": [
|
|
26
|
+
{
|
|
27
|
+
"productId": "5e8f2a1b-3c4d-4e5f-8a6b-7c8d9e0f1a2b",
|
|
28
|
+
"quantity": 2,
|
|
29
|
+
"unitPrice": 1999
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"productId": "6f9a3b2c-4d5e-4f6a-9b7c-8d9e0f1a2b3c",
|
|
33
|
+
"quantity": 1,
|
|
34
|
+
"unitPrice": 1499
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"total": 5497,
|
|
38
|
+
"currency": "GBP",
|
|
39
|
+
"createdAt": "2026-09-11T08:12:45Z"
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Using this example
|
|
44
|
+
|
|
45
|
+
Check that the page lists both lines, shows £54.97 and that the returned `orderId` matches the one requested.
|
|
46
|
+
|
|
47
|
+
The examples use a **fictional Acme Events SDK** to query a payload matching the GetOrder schema. The package names and query methods are illustrative.
|
|
48
|
+
|
|
49
|
+
</Column>
|
|
50
|
+
|
|
51
|
+
<Column>
|
|
52
|
+
|
|
53
|
+
<CodeGroup dropdown>
|
|
54
|
+
|
|
55
|
+
```typescript query-get-order.ts
|
|
56
|
+
import { EventsClient } from '@acme/events';
|
|
57
|
+
import type { GetOrderRequest, GetOrderResponse } from './schemas/get-order';
|
|
58
|
+
|
|
59
|
+
const client = new EventsClient({
|
|
60
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const request: GetOrderRequest = {
|
|
64
|
+
orderId: '4c7e9a2b-1d3f-4b5a-8e6c-2f9d0a1b3c5e',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const order: GetOrderResponse = await client.query('GetOrder', request);
|
|
68
|
+
|
|
69
|
+
console.log(order.status, order.total);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```python query_get_order.py
|
|
73
|
+
import os
|
|
74
|
+
from acme_events import EventsClient
|
|
75
|
+
|
|
76
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
77
|
+
|
|
78
|
+
request = {
|
|
79
|
+
"orderId": "4c7e9a2b-1d3f-4b5a-8e6c-2f9d0a1b3c5e",
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
order = client.query("GetOrder", request)
|
|
83
|
+
|
|
84
|
+
print(order["status"], order["total"])
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```java QueryGetOrder.java
|
|
88
|
+
import com.acme.events.EventsClient;
|
|
89
|
+
import java.util.Map;
|
|
90
|
+
|
|
91
|
+
public class QueryGetOrder {
|
|
92
|
+
public static void main(String[] args) {
|
|
93
|
+
var client = new EventsClient(
|
|
94
|
+
System.getenv("ACME_API_KEY")
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
var request = Map.of(
|
|
98
|
+
"orderId", "4c7e9a2b-1d3f-4b5a-8e6c-2f9d0a1b3c5e"
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
var order = client.query("GetOrder", request);
|
|
102
|
+
|
|
103
|
+
System.out.println(
|
|
104
|
+
order.get("status") + " " + order.get("total")
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
</CodeGroup>
|
|
111
|
+
|
|
112
|
+
</Column>
|
|
113
|
+
|
|
114
|
+
</Columns>
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
<Columns cols={2}>
|
|
119
|
+
|
|
120
|
+
<Column>
|
|
121
|
+
|
|
122
|
+
## 2. Fetch a completed euro order
|
|
123
|
+
|
|
124
|
+
A support agent looks up an order from Ireland after the customer asks about a return. The order has been delivered, so its status is `COMPLETED`.
|
|
125
|
+
|
|
126
|
+
### Payload details
|
|
127
|
+
|
|
128
|
+
- `request.orderId` identifies the order being looked up.
|
|
129
|
+
- `status` is `COMPLETED`.
|
|
130
|
+
- `items` has one line: 1 × hoodie at 5,799 cents.
|
|
131
|
+
- `currency` is `EUR`, so `unitPrice` and `total` are in cents.
|
|
132
|
+
|
|
133
|
+
The total is **5,799 cents (€57.99)**.
|
|
134
|
+
|
|
135
|
+
### Example response
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"orderId": "b5d8e1f2-6a3c-4d7b-9f0e-3a4b5c6d7e8f",
|
|
140
|
+
"customerId": "8a7c6e5d-2b1f-4c3a-9e8d-7f6a5b4c3d2e",
|
|
141
|
+
"status": "COMPLETED",
|
|
142
|
+
"items": [
|
|
143
|
+
{
|
|
144
|
+
"productId": "7a0b4c3d-5e6f-4a7b-8c8d-9e0f1a2b3c4d",
|
|
145
|
+
"quantity": 1,
|
|
146
|
+
"unitPrice": 5799
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"total": 5799,
|
|
150
|
+
"currency": "EUR",
|
|
151
|
+
"createdAt": "2026-09-14T17:03:10Z"
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Using this example
|
|
156
|
+
|
|
157
|
+
Use this to check that support tooling shows the order as delivered and formats the total in euros.
|
|
158
|
+
|
|
159
|
+
The examples use a **fictional Acme Events SDK** to query a payload matching the GetOrder schema. The package names and query methods are illustrative.
|
|
160
|
+
|
|
161
|
+
</Column>
|
|
162
|
+
|
|
163
|
+
<Column>
|
|
164
|
+
|
|
165
|
+
<CodeGroup dropdown>
|
|
166
|
+
|
|
167
|
+
```typescript query-get-order.ts
|
|
168
|
+
import { EventsClient } from '@acme/events';
|
|
169
|
+
import type { GetOrderRequest, GetOrderResponse } from './schemas/get-order';
|
|
170
|
+
|
|
171
|
+
const client = new EventsClient({
|
|
172
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const request: GetOrderRequest = {
|
|
176
|
+
orderId: 'b5d8e1f2-6a3c-4d7b-9f0e-3a4b5c6d7e8f',
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const order: GetOrderResponse = await client.query('GetOrder', request);
|
|
180
|
+
|
|
181
|
+
console.log(order.status, order.total);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
```python query_get_order.py
|
|
185
|
+
import os
|
|
186
|
+
from acme_events import EventsClient
|
|
187
|
+
|
|
188
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
189
|
+
|
|
190
|
+
request = {
|
|
191
|
+
"orderId": "b5d8e1f2-6a3c-4d7b-9f0e-3a4b5c6d7e8f",
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
order = client.query("GetOrder", request)
|
|
195
|
+
|
|
196
|
+
print(order["status"], order["total"])
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```java QueryGetOrder.java
|
|
200
|
+
import com.acme.events.EventsClient;
|
|
201
|
+
import java.util.Map;
|
|
202
|
+
|
|
203
|
+
public class QueryGetOrder {
|
|
204
|
+
public static void main(String[] args) {
|
|
205
|
+
var client = new EventsClient(
|
|
206
|
+
System.getenv("ACME_API_KEY")
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
var request = Map.of(
|
|
210
|
+
"orderId", "b5d8e1f2-6a3c-4d7b-9f0e-3a4b5c6d7e8f"
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
var order = client.query("GetOrder", request);
|
|
214
|
+
|
|
215
|
+
System.out.println(
|
|
216
|
+
order.get("status") + " " + order.get("total")
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
</CodeGroup>
|
|
223
|
+
|
|
224
|
+
</Column>
|
|
225
|
+
|
|
226
|
+
</Columns>
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
<Columns cols={2}>
|
|
231
|
+
|
|
232
|
+
<Column>
|
|
233
|
+
|
|
234
|
+
## 3. Fetch a cancelled order
|
|
235
|
+
|
|
236
|
+
The customer opens their order history after cancelling a hoodie-and-caps order. The query returns the order with status `CANCELLED`, still showing what was ordered.
|
|
237
|
+
|
|
238
|
+
### Payload details
|
|
239
|
+
|
|
240
|
+
- `request.orderId` identifies the cancelled order.
|
|
241
|
+
- `status` is `CANCELLED`.
|
|
242
|
+
- `items` has 2 lines: 1 × hoodie at 4,999 pence and 2 × cap at 1,499 pence.
|
|
243
|
+
- `total` is still returned so the history shows the value of the cancelled order.
|
|
244
|
+
|
|
245
|
+
The total is **4,999 + 2,998 = 7,997 pence (£79.97)**.
|
|
246
|
+
|
|
247
|
+
### Example response
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"orderId": "e3f4a5b6-7c8d-4e9f-a0b1-c2d3e4f5a6b7",
|
|
252
|
+
"customerId": "3f2b8c1e-7a4d-4e9b-9c6f-1d2e3a4b5c6d",
|
|
253
|
+
"status": "CANCELLED",
|
|
254
|
+
"items": [
|
|
255
|
+
{
|
|
256
|
+
"productId": "7a0b4c3d-5e6f-4a7b-8c8d-9e0f1a2b3c4d",
|
|
257
|
+
"quantity": 1,
|
|
258
|
+
"unitPrice": 4999
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"productId": "6f9a3b2c-4d5e-4f6a-9b7c-8d9e0f1a2b3c",
|
|
262
|
+
"quantity": 2,
|
|
263
|
+
"unitPrice": 1499
|
|
264
|
+
}
|
|
265
|
+
],
|
|
266
|
+
"total": 7997,
|
|
267
|
+
"currency": "GBP",
|
|
268
|
+
"createdAt": "2026-09-12T19:45:22Z"
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Using this example
|
|
273
|
+
|
|
274
|
+
Use this to check that the order history marks the order as cancelled and does not offer tracking or returns for it.
|
|
275
|
+
|
|
276
|
+
The examples use a **fictional Acme Events SDK** to query a payload matching the GetOrder schema. The package names and query methods are illustrative.
|
|
277
|
+
|
|
278
|
+
</Column>
|
|
279
|
+
|
|
280
|
+
<Column>
|
|
281
|
+
|
|
282
|
+
<CodeGroup dropdown>
|
|
283
|
+
|
|
284
|
+
```typescript query-get-order.ts
|
|
285
|
+
import { EventsClient } from '@acme/events';
|
|
286
|
+
import type { GetOrderRequest, GetOrderResponse } from './schemas/get-order';
|
|
287
|
+
|
|
288
|
+
const client = new EventsClient({
|
|
289
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const request: GetOrderRequest = {
|
|
293
|
+
orderId: 'e3f4a5b6-7c8d-4e9f-a0b1-c2d3e4f5a6b7',
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
const order: GetOrderResponse = await client.query('GetOrder', request);
|
|
297
|
+
|
|
298
|
+
console.log(order.status, order.total);
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
```python query_get_order.py
|
|
302
|
+
import os
|
|
303
|
+
from acme_events import EventsClient
|
|
304
|
+
|
|
305
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
306
|
+
|
|
307
|
+
request = {
|
|
308
|
+
"orderId": "e3f4a5b6-7c8d-4e9f-a0b1-c2d3e4f5a6b7",
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
order = client.query("GetOrder", request)
|
|
312
|
+
|
|
313
|
+
print(order["status"], order["total"])
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
```java QueryGetOrder.java
|
|
317
|
+
import com.acme.events.EventsClient;
|
|
318
|
+
import java.util.Map;
|
|
319
|
+
|
|
320
|
+
public class QueryGetOrder {
|
|
321
|
+
public static void main(String[] args) {
|
|
322
|
+
var client = new EventsClient(
|
|
323
|
+
System.getenv("ACME_API_KEY")
|
|
324
|
+
);
|
|
325
|
+
|
|
326
|
+
var request = Map.of(
|
|
327
|
+
"orderId", "e3f4a5b6-7c8d-4e9f-a0b1-c2d3e4f5a6b7"
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
var order = client.query("GetOrder", request);
|
|
331
|
+
|
|
332
|
+
System.out.println(
|
|
333
|
+
order.get("status") + " " + order.get("total")
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
</CodeGroup>
|
|
340
|
+
|
|
341
|
+
</Column>
|
|
342
|
+
|
|
343
|
+
</Columns>
|