Repository navigation
Expand file tree
/
Copy pathrest-client.http
More file actions
65 lines (49 loc) · 1.96 KB
/
Copy pathrest-client.http
File metadata and controls
65 lines (49 loc) · 1.96 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
55
56
57
58
59
60
61
62
63
64
65
@baseUrl = http://localhost:8000
@readKey = REPLACE_WITH_READ_KEY
@writeKey = REPLACE_WITH_WRITE_KEY
@adminKey = REPLACE_WITH_ADMIN_KEY
@customerId = REPLACE_WITH_CUSTOMER_OBJECT_ID
@productId = REPLACE_WITH_PRODUCT_OBJECT_ID
@orderId = REPLACE_WITH_ORDER_OBJECT_ID
### Health
GET {{baseUrl}}/health/ready
### Create customer
POST {{baseUrl}}/api/customer
x-api-key: {{writeKey}}
Content-Type: application/json
{"customerName":"Alice","cemail":"alice@example.com","phone":"555-0100","address":"1 Main Road","city":"Karachi","postalCode":"74000","country":"PK"}
### Create product (prices in minor units)
POST {{baseUrl}}/api/product
x-api-key: {{writeKey}}
Content-Type: application/json
{"productName":"Widget","productvendor":"Example","productDescription":"Demo widget","quantityInStock":10,"buyPrice":100,"msrp":250}
### List products
GET {{baseUrl}}/api/product?offset=0&limit=20
x-api-key: {{readKey}}
### Create or replay an order; change the key for a new order
POST {{baseUrl}}/api/order
x-api-key: {{writeKey}}
Idempotency-Key: example-order-0001
Content-Type: application/json
{"customerId":"{{customerId}}","comments":"Demo","orderItems":[{"productId":"{{productId}}","quantity":2}]}
### Customer orders
GET {{baseUrl}}/api/order/customer/{{customerId}}?limit=20
x-api-key: {{readKey}}
### Replace items before payment/shipping (retains existing line prices)
PUT {{baseUrl}}/api/order/{{orderId}}
x-api-key: {{writeKey}}
Content-Type: application/json
{"orderItems":[{"productId":"{{productId}}","quantity":3}]}
### Confirm external settlement and ship (admin only)
PUT {{baseUrl}}/api/order/{{orderId}}
x-api-key: {{adminKey}}
Content-Type: application/json
{"paid":true,"status":"shipped"}
### Add available stock using a delta
POST {{baseUrl}}/api/product/{{productId}}/stock
x-api-key: {{writeKey}}
Content-Type: application/json
{"delta":5}
### Delete an unpaid, unshipped order; inventory is restored once
DELETE {{baseUrl}}/api/order/{{orderId}}
x-api-key: {{writeKey}}