@chanaka_nakandala/integration-agent 1.0.0
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/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/cache/file-cache.d.ts +10 -0
- package/dist/cache/file-cache.d.ts.map +1 -0
- package/dist/cache/file-cache.js +79 -0
- package/dist/cache/file-cache.js.map +1 -0
- package/dist/cli/init-command.d.ts +2 -0
- package/dist/cli/init-command.d.ts.map +1 -0
- package/dist/cli/init-command.js +115 -0
- package/dist/cli/init-command.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +493 -0
- package/dist/index.js.map +1 -0
- package/dist/scrapers/docs-scraper.d.ts +28 -0
- package/dist/scrapers/docs-scraper.d.ts.map +1 -0
- package/dist/scrapers/docs-scraper.js +200 -0
- package/dist/scrapers/docs-scraper.js.map +1 -0
- package/dist/search/keyword-search.d.ts +39 -0
- package/dist/search/keyword-search.d.ts.map +1 -0
- package/dist/search/keyword-search.js +127 -0
- package/dist/search/keyword-search.js.map +1 -0
- package/dist/tools/code-generation-tool.d.ts +33 -0
- package/dist/tools/code-generation-tool.d.ts.map +1 -0
- package/dist/tools/code-generation-tool.js +62 -0
- package/dist/tools/code-generation-tool.js.map +1 -0
- package/dist/tools/search-result-formatter.d.ts +27 -0
- package/dist/tools/search-result-formatter.d.ts.map +1 -0
- package/dist/tools/search-result-formatter.js +89 -0
- package/dist/tools/search-result-formatter.js.map +1 -0
- package/dist/tools/search-tool.d.ts +9 -0
- package/dist/tools/search-tool.d.ts.map +1 -0
- package/dist/tools/search-tool.js +32 -0
- package/dist/tools/search-tool.js.map +1 -0
- package/dist/tools/template-loader.d.ts +54 -0
- package/dist/tools/template-loader.d.ts.map +1 -0
- package/dist/tools/template-loader.js +148 -0
- package/dist/tools/template-loader.js.map +1 -0
- package/dist/types/search.d.ts +21 -0
- package/dist/types/search.d.ts.map +1 -0
- package/dist/types/search.js +2 -0
- package/dist/types/search.js.map +1 -0
- package/package.json +63 -0
- package/templates/README.md +98 -0
- package/templates/authenticate/curl.template +97 -0
- package/templates/authenticate/java.template +155 -0
- package/templates/authenticate/python.template +111 -0
- package/templates/authenticate/typescript.template +98 -0
- package/templates/create_menu/curl.template +145 -0
- package/templates/create_menu/java.template +285 -0
- package/templates/create_menu/python.template +159 -0
- package/templates/create_menu/typescript.template +184 -0
- package/templates/receive_order/curl.template +138 -0
- package/templates/receive_order/java.template +263 -0
- package/templates/receive_order/python.template +157 -0
- package/templates/receive_order/typescript.template +194 -0
- package/templates/update_item_availability/curl.template +143 -0
- package/templates/update_item_availability/java.template +279 -0
- package/templates/update_item_availability/python.template +203 -0
- package/templates/update_item_availability/typescript.template +194 -0
- package/templates/update_order_status/curl.template +138 -0
- package/templates/update_order_status/java.template +202 -0
- package/templates/update_order_status/python.template +142 -0
- package/templates/update_order_status/typescript.template +139 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
"""
|
2
|
+
Grubtech Item Availability Update - Python
|
3
|
+
|
4
|
+
This example demonstrates how to update menu item availability in Grubtech
|
5
|
+
to keep items in sync with your inventory status.
|
6
|
+
|
7
|
+
Prerequisites:
|
8
|
+
- Python 3.8+
|
9
|
+
- requests library (pip install requests)
|
10
|
+
- Valid access token from authentication
|
11
|
+
|
12
|
+
Replace the following placeholders:
|
13
|
+
- {{AUTH_TOKEN}}: Access token from authentication step
|
14
|
+
- {{ITEM_ID}}: The menu item ID to update
|
15
|
+
- {{AVAILABLE_STATUS}}: Boolean availability status (True/False)
|
16
|
+
"""
|
17
|
+
|
18
|
+
import requests
|
19
|
+
import sys
|
20
|
+
from datetime import datetime
|
21
|
+
from typing import Dict, Any, List, Optional
|
22
|
+
|
23
|
+
AUTH_TOKEN = '{{AUTH_TOKEN}}'
|
24
|
+
BASE_URL = 'https://api.grubtech.io'
|
25
|
+
|
26
|
+
|
27
|
+
def update_item_availability(
|
28
|
+
item_id: str,
|
29
|
+
available: bool,
|
30
|
+
reason: Optional[str] = None
|
31
|
+
) -> Dict[str, Any]:
|
32
|
+
"""
|
33
|
+
Update single item availability
|
34
|
+
|
35
|
+
Args:
|
36
|
+
item_id: The menu item ID
|
37
|
+
available: True if in stock, False if out of stock
|
38
|
+
reason: Optional reason for status change
|
39
|
+
|
40
|
+
Returns:
|
41
|
+
Dict: Response from API
|
42
|
+
|
43
|
+
Raises:
|
44
|
+
Exception: If update fails
|
45
|
+
"""
|
46
|
+
try:
|
47
|
+
# Construct payload
|
48
|
+
payload = {
|
49
|
+
'itemId': item_id,
|
50
|
+
'available': available,
|
51
|
+
'timestamp': datetime.utcnow().isoformat() + 'Z',
|
52
|
+
}
|
53
|
+
|
54
|
+
if reason:
|
55
|
+
payload['reason'] = reason
|
56
|
+
|
57
|
+
print(f'Updating item {item_id}: available={available}')
|
58
|
+
|
59
|
+
# Make availability update request
|
60
|
+
url = f'{BASE_URL}/v1/items/{item_id}/availability'
|
61
|
+
headers = {
|
62
|
+
'Authorization': f'Bearer {AUTH_TOKEN}',
|
63
|
+
'Content-Type': 'application/json',
|
64
|
+
}
|
65
|
+
|
66
|
+
response = requests.put(url, json=payload, headers=headers, timeout=10)
|
67
|
+
|
68
|
+
# Check for errors
|
69
|
+
if not response.ok:
|
70
|
+
raise Exception(
|
71
|
+
f'Availability update failed: {response.status_code} - {response.text}'
|
72
|
+
)
|
73
|
+
|
74
|
+
# Parse response
|
75
|
+
data = response.json()
|
76
|
+
|
77
|
+
print(f'✅ Item availability updated successfully!')
|
78
|
+
print(f'Item ID: {data["itemId"]}')
|
79
|
+
print(f'Available: {available}')
|
80
|
+
|
81
|
+
return data
|
82
|
+
|
83
|
+
except requests.RequestException as e:
|
84
|
+
print(f'❌ Availability update error: {e}', file=sys.stderr)
|
85
|
+
raise
|
86
|
+
except Exception as e:
|
87
|
+
print(f'❌ Unexpected error: {e}', file=sys.stderr)
|
88
|
+
raise
|
89
|
+
|
90
|
+
|
91
|
+
def update_bulk_availability(
|
92
|
+
updates: List[Dict[str, Any]]
|
93
|
+
) -> Dict[str, Any]:
|
94
|
+
"""
|
95
|
+
Update multiple items availability in bulk
|
96
|
+
|
97
|
+
Args:
|
98
|
+
updates: List of item availability updates
|
99
|
+
[{'itemId': 'item-1', 'available': False, 'reason': '...'}]
|
100
|
+
|
101
|
+
Returns:
|
102
|
+
Dict: Response from API
|
103
|
+
|
104
|
+
Raises:
|
105
|
+
Exception: If update fails
|
106
|
+
"""
|
107
|
+
try:
|
108
|
+
# Construct bulk payload
|
109
|
+
payload = {
|
110
|
+
'updates': updates,
|
111
|
+
'timestamp': datetime.utcnow().isoformat() + 'Z',
|
112
|
+
}
|
113
|
+
|
114
|
+
print(f'Updating {len(updates)} items availability')
|
115
|
+
|
116
|
+
# Make bulk availability update request
|
117
|
+
url = f'{BASE_URL}/v1/items/availability/bulk'
|
118
|
+
headers = {
|
119
|
+
'Authorization': f'Bearer {AUTH_TOKEN}',
|
120
|
+
'Content-Type': 'application/json',
|
121
|
+
}
|
122
|
+
|
123
|
+
response = requests.put(url, json=payload, headers=headers, timeout=30)
|
124
|
+
|
125
|
+
# Check for errors
|
126
|
+
if not response.ok:
|
127
|
+
raise Exception(
|
128
|
+
f'Bulk availability update failed: {response.status_code} - {response.text}'
|
129
|
+
)
|
130
|
+
|
131
|
+
# Parse response
|
132
|
+
data = response.json()
|
133
|
+
|
134
|
+
print(f'✅ Bulk availability updated successfully!')
|
135
|
+
print(f'Updated: {data.get("updatedCount", 0)} items')
|
136
|
+
|
137
|
+
# Report any errors
|
138
|
+
errors = data.get('errors', [])
|
139
|
+
if errors:
|
140
|
+
print(f'⚠️ {len(errors)} items had errors:')
|
141
|
+
for err in errors:
|
142
|
+
print(f' - {err["itemId"]}: {err["error"]}')
|
143
|
+
|
144
|
+
return data
|
145
|
+
|
146
|
+
except requests.RequestException as e:
|
147
|
+
print(f'❌ Bulk availability update error: {e}', file=sys.stderr)
|
148
|
+
raise
|
149
|
+
except Exception as e:
|
150
|
+
print(f'❌ Unexpected error: {e}', file=sys.stderr)
|
151
|
+
raise
|
152
|
+
|
153
|
+
|
154
|
+
def mark_out_of_stock(item_id: str) -> Dict[str, Any]:
|
155
|
+
"""Mark item as out of stock"""
|
156
|
+
return update_item_availability(item_id, False, 'Out of stock')
|
157
|
+
|
158
|
+
|
159
|
+
def mark_in_stock(item_id: str) -> Dict[str, Any]:
|
160
|
+
"""Mark item as back in stock"""
|
161
|
+
return update_item_availability(item_id, True, 'Back in stock')
|
162
|
+
|
163
|
+
|
164
|
+
def sync_inventory(inventory: Dict[str, bool]) -> Dict[str, Any]:
|
165
|
+
"""
|
166
|
+
Sync inventory with Grubtech
|
167
|
+
|
168
|
+
Args:
|
169
|
+
inventory: Dict mapping item IDs to availability status
|
170
|
+
{'item-123': False, 'item-456': True}
|
171
|
+
"""
|
172
|
+
updates = [
|
173
|
+
{
|
174
|
+
'itemId': item_id,
|
175
|
+
'available': available,
|
176
|
+
'reason': 'In stock' if available else 'Out of stock',
|
177
|
+
}
|
178
|
+
for item_id, available in inventory.items()
|
179
|
+
]
|
180
|
+
|
181
|
+
return update_bulk_availability(updates)
|
182
|
+
|
183
|
+
|
184
|
+
if __name__ == '__main__':
|
185
|
+
try:
|
186
|
+
item_id = '{{ITEM_ID}}'
|
187
|
+
available = {{AVAILABLE_STATUS}} # True or False
|
188
|
+
|
189
|
+
# Example 1: Single item update
|
190
|
+
update_item_availability(item_id, available, 'Inventory sync')
|
191
|
+
|
192
|
+
# Example 2: Mark item out of stock
|
193
|
+
# mark_out_of_stock('item-123')
|
194
|
+
|
195
|
+
# Example 3: Bulk update from inventory
|
196
|
+
# sync_inventory({
|
197
|
+
# 'item-123': False, # Out of stock
|
198
|
+
# 'item-456': True, # In stock
|
199
|
+
# 'item-789': True, # In stock
|
200
|
+
# })
|
201
|
+
|
202
|
+
except Exception as e:
|
203
|
+
sys.exit(1)
|
@@ -0,0 +1,194 @@
|
|
1
|
+
/**
|
2
|
+
* Grubtech Item Availability Update - TypeScript
|
3
|
+
*
|
4
|
+
* This example demonstrates how to update menu item availability in Grubtech
|
5
|
+
* to keep items in sync with your inventory status.
|
6
|
+
*
|
7
|
+
* Prerequisites:
|
8
|
+
* - Node.js 18+ with fetch API
|
9
|
+
* - Valid access token from authentication
|
10
|
+
*
|
11
|
+
* Replace the following placeholders:
|
12
|
+
* - {{AUTH_TOKEN}}: Access token from authentication step
|
13
|
+
* - {{ITEM_ID}}: The menu item ID to update
|
14
|
+
* - {{AVAILABLE_STATUS}}: Boolean availability status (true/false)
|
15
|
+
*/
|
16
|
+
|
17
|
+
const AUTH_TOKEN = '{{AUTH_TOKEN}}';
|
18
|
+
const BASE_URL = 'https://api.grubtech.io';
|
19
|
+
|
20
|
+
interface ItemAvailabilityUpdate {
|
21
|
+
itemId: string;
|
22
|
+
available: boolean;
|
23
|
+
reason?: string;
|
24
|
+
}
|
25
|
+
|
26
|
+
interface BulkAvailabilityUpdate {
|
27
|
+
updates: ItemAvailabilityUpdate[];
|
28
|
+
timestamp: string;
|
29
|
+
}
|
30
|
+
|
31
|
+
interface AvailabilityResponse {
|
32
|
+
success: boolean;
|
33
|
+
itemId?: string;
|
34
|
+
updatedCount?: number;
|
35
|
+
message?: string;
|
36
|
+
errors?: Array<{ itemId: string; error: string }>;
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Update single item availability
|
41
|
+
*/
|
42
|
+
async function updateItemAvailability(
|
43
|
+
itemId: string,
|
44
|
+
available: boolean,
|
45
|
+
reason?: string
|
46
|
+
): Promise<AvailabilityResponse> {
|
47
|
+
try {
|
48
|
+
// Construct payload
|
49
|
+
const payload = {
|
50
|
+
itemId,
|
51
|
+
available,
|
52
|
+
timestamp: new Date().toISOString(),
|
53
|
+
reason,
|
54
|
+
};
|
55
|
+
|
56
|
+
console.log(`Updating item ${itemId}: available=${available}`);
|
57
|
+
|
58
|
+
// Make availability update request
|
59
|
+
const response = await fetch(`${BASE_URL}/v1/items/${itemId}/availability`, {
|
60
|
+
method: 'PUT',
|
61
|
+
headers: {
|
62
|
+
'Authorization': `Bearer ${AUTH_TOKEN}`,
|
63
|
+
'Content-Type': 'application/json',
|
64
|
+
},
|
65
|
+
body: JSON.stringify(payload),
|
66
|
+
});
|
67
|
+
|
68
|
+
// Check for errors
|
69
|
+
if (!response.ok) {
|
70
|
+
const errorBody = await response.text();
|
71
|
+
throw new Error(
|
72
|
+
`Availability update failed: ${response.status} - ${errorBody}`
|
73
|
+
);
|
74
|
+
}
|
75
|
+
|
76
|
+
// Parse response
|
77
|
+
const data: AvailabilityResponse = await response.json();
|
78
|
+
|
79
|
+
console.log('✅ Item availability updated successfully!');
|
80
|
+
console.log(`Item ID: ${data.itemId}`);
|
81
|
+
console.log(`Available: ${available}`);
|
82
|
+
|
83
|
+
return data;
|
84
|
+
} catch (error) {
|
85
|
+
console.error('❌ Availability update error:', error);
|
86
|
+
throw error;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Update multiple items availability in bulk
|
92
|
+
*/
|
93
|
+
async function updateBulkAvailability(
|
94
|
+
updates: ItemAvailabilityUpdate[]
|
95
|
+
): Promise<AvailabilityResponse> {
|
96
|
+
try {
|
97
|
+
// Construct bulk payload
|
98
|
+
const payload: BulkAvailabilityUpdate = {
|
99
|
+
updates,
|
100
|
+
timestamp: new Date().toISOString(),
|
101
|
+
};
|
102
|
+
|
103
|
+
console.log(`Updating ${updates.length} items availability`);
|
104
|
+
|
105
|
+
// Make bulk availability update request
|
106
|
+
const response = await fetch(`${BASE_URL}/v1/items/availability/bulk`, {
|
107
|
+
method: 'PUT',
|
108
|
+
headers: {
|
109
|
+
'Authorization': `Bearer ${AUTH_TOKEN}`,
|
110
|
+
'Content-Type': 'application/json',
|
111
|
+
},
|
112
|
+
body: JSON.stringify(payload),
|
113
|
+
});
|
114
|
+
|
115
|
+
// Check for errors
|
116
|
+
if (!response.ok) {
|
117
|
+
const errorBody = await response.text();
|
118
|
+
throw new Error(
|
119
|
+
`Bulk availability update failed: ${response.status} - ${errorBody}`
|
120
|
+
);
|
121
|
+
}
|
122
|
+
|
123
|
+
// Parse response
|
124
|
+
const data: AvailabilityResponse = await response.json();
|
125
|
+
|
126
|
+
console.log('✅ Bulk availability updated successfully!');
|
127
|
+
console.log(`Updated: ${data.updatedCount} items`);
|
128
|
+
|
129
|
+
// Report any errors
|
130
|
+
if (data.errors && data.errors.length > 0) {
|
131
|
+
console.warn(`⚠️ ${data.errors.length} items had errors:`);
|
132
|
+
data.errors.forEach(err => {
|
133
|
+
console.warn(` - ${err.itemId}: ${err.error}`);
|
134
|
+
});
|
135
|
+
}
|
136
|
+
|
137
|
+
return data;
|
138
|
+
} catch (error) {
|
139
|
+
console.error('❌ Bulk availability update error:', error);
|
140
|
+
throw error;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
/**
|
145
|
+
* Example: Mark item as out of stock
|
146
|
+
*/
|
147
|
+
async function markOutOfStock(itemId: string) {
|
148
|
+
return await updateItemAvailability(itemId, false, 'Out of stock');
|
149
|
+
}
|
150
|
+
|
151
|
+
/**
|
152
|
+
* Example: Mark item as back in stock
|
153
|
+
*/
|
154
|
+
async function markInStock(itemId: string) {
|
155
|
+
return await updateItemAvailability(itemId, true, 'Back in stock');
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Example: Sync inventory with Grubtech
|
160
|
+
*/
|
161
|
+
async function syncInventory(inventory: Record<string, boolean>) {
|
162
|
+
const updates: ItemAvailabilityUpdate[] = Object.entries(inventory).map(
|
163
|
+
([itemId, available]) => ({
|
164
|
+
itemId,
|
165
|
+
available,
|
166
|
+
reason: available ? 'In stock' : 'Out of stock',
|
167
|
+
})
|
168
|
+
);
|
169
|
+
|
170
|
+
return await updateBulkAvailability(updates);
|
171
|
+
}
|
172
|
+
|
173
|
+
// Main execution
|
174
|
+
(async () => {
|
175
|
+
try {
|
176
|
+
const itemId = '{{ITEM_ID}}';
|
177
|
+
const available = {{AVAILABLE_STATUS}}; // true or false
|
178
|
+
|
179
|
+
// Example 1: Single item update
|
180
|
+
await updateItemAvailability(itemId, available, 'Inventory sync');
|
181
|
+
|
182
|
+
// Example 2: Mark item out of stock
|
183
|
+
// await markOutOfStock('item-123');
|
184
|
+
|
185
|
+
// Example 3: Bulk update from inventory
|
186
|
+
// await syncInventory({
|
187
|
+
// 'item-123': false, // Out of stock
|
188
|
+
// 'item-456': true, // In stock
|
189
|
+
// 'item-789': true, // In stock
|
190
|
+
// });
|
191
|
+
} catch (error) {
|
192
|
+
process.exit(1);
|
193
|
+
}
|
194
|
+
})();
|
@@ -0,0 +1,138 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Grubtech Order Status Update - cURL
|
4
|
+
#
|
5
|
+
# This example demonstrates how to update order status in Grubtech.
|
6
|
+
#
|
7
|
+
# Prerequisites:
|
8
|
+
# - curl command-line tool
|
9
|
+
# - jq (for JSON parsing, optional)
|
10
|
+
# - Valid access token from authentication
|
11
|
+
#
|
12
|
+
# Replace the following placeholders:
|
13
|
+
# - {{AUTH_TOKEN}}: Access token from authentication step
|
14
|
+
# - {{ORDER_ID}}: The Grubtech order ID to update
|
15
|
+
# - {{NEW_STATUS}}: The new status value (accepted, preparing, ready, delivered, cancelled)
|
16
|
+
|
17
|
+
AUTH_TOKEN="{{AUTH_TOKEN}}"
|
18
|
+
ORDER_ID="{{ORDER_ID}}"
|
19
|
+
NEW_STATUS="{{NEW_STATUS}}" # One of: accepted, preparing, ready, delivered, cancelled
|
20
|
+
BASE_URL="https://api.grubtech.io"
|
21
|
+
|
22
|
+
# Valid status values
|
23
|
+
VALID_STATUSES=("accepted" "preparing" "ready" "delivered" "cancelled")
|
24
|
+
|
25
|
+
# Validate status
|
26
|
+
validate_status() {
|
27
|
+
local status=$1
|
28
|
+
for valid in "${VALID_STATUSES[@]}"; do
|
29
|
+
if [ "$status" == "$valid" ]; then
|
30
|
+
return 0
|
31
|
+
fi
|
32
|
+
done
|
33
|
+
echo "❌ Invalid status: $status"
|
34
|
+
echo "Valid statuses: ${VALID_STATUSES[*]}"
|
35
|
+
return 1
|
36
|
+
}
|
37
|
+
|
38
|
+
# Update order status
|
39
|
+
update_order_status() {
|
40
|
+
local order_id=$1
|
41
|
+
local new_status=$2
|
42
|
+
local notes=$3
|
43
|
+
|
44
|
+
# Validate status
|
45
|
+
if ! validate_status "$new_status"; then
|
46
|
+
return 1
|
47
|
+
fi
|
48
|
+
|
49
|
+
echo "Updating order ${order_id} to status: ${new_status}"
|
50
|
+
|
51
|
+
# Construct payload
|
52
|
+
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
53
|
+
PAYLOAD=$(cat <<EOF
|
54
|
+
{
|
55
|
+
"orderId": "${order_id}",
|
56
|
+
"status": "${new_status}",
|
57
|
+
"timestamp": "${TIMESTAMP}",
|
58
|
+
"notes": "${notes}"
|
59
|
+
}
|
60
|
+
EOF
|
61
|
+
)
|
62
|
+
|
63
|
+
# Make status update request
|
64
|
+
RESPONSE=$(curl -s -w "\n%{http_code}" -X PUT \
|
65
|
+
"${BASE_URL}/v1/orders/${order_id}/status" \
|
66
|
+
-H "Authorization: Bearer ${AUTH_TOKEN}" \
|
67
|
+
-H "Content-Type: application/json" \
|
68
|
+
-d "$PAYLOAD")
|
69
|
+
|
70
|
+
# Extract HTTP status code and body
|
71
|
+
HTTP_CODE=$(echo "$RESPONSE" | tail -n 1)
|
72
|
+
BODY=$(echo "$RESPONSE" | sed '$d')
|
73
|
+
|
74
|
+
# Check for errors
|
75
|
+
if [ "$HTTP_CODE" -ne 200 ]; then
|
76
|
+
echo "❌ Status update failed: HTTP $HTTP_CODE"
|
77
|
+
echo "Response: $BODY"
|
78
|
+
return 1
|
79
|
+
fi
|
80
|
+
|
81
|
+
# Parse response
|
82
|
+
if command -v jq &> /dev/null; then
|
83
|
+
ORDER_ID=$(echo "$BODY" | jq -r '.orderId')
|
84
|
+
STATUS=$(echo "$BODY" | jq -r '.status')
|
85
|
+
UPDATED_AT=$(echo "$BODY" | jq -r '.updatedAt')
|
86
|
+
|
87
|
+
echo "✅ Order status updated successfully!"
|
88
|
+
echo "Order ID: ${ORDER_ID}"
|
89
|
+
echo "New Status: ${STATUS}"
|
90
|
+
echo "Updated At: ${UPDATED_AT}"
|
91
|
+
else
|
92
|
+
echo "✅ Order status updated successfully!"
|
93
|
+
echo "Response: $BODY"
|
94
|
+
echo "Note: Install jq for better JSON parsing"
|
95
|
+
fi
|
96
|
+
}
|
97
|
+
|
98
|
+
# Example: Full order workflow
|
99
|
+
order_workflow_example() {
|
100
|
+
local order_id=$1
|
101
|
+
|
102
|
+
echo "Running full order workflow for: ${order_id}"
|
103
|
+
echo ""
|
104
|
+
|
105
|
+
# Step 1: Accept
|
106
|
+
echo "Step 1: Accepting order..."
|
107
|
+
update_order_status "$order_id" "accepted" "Order confirmed"
|
108
|
+
echo ""
|
109
|
+
|
110
|
+
# Step 2: Preparing
|
111
|
+
echo "Step 2: Preparing order..."
|
112
|
+
update_order_status "$order_id" "preparing" "Chef started cooking"
|
113
|
+
echo ""
|
114
|
+
|
115
|
+
# Step 3: Ready
|
116
|
+
echo "Step 3: Order ready..."
|
117
|
+
update_order_status "$order_id" "ready" "Order ready for pickup"
|
118
|
+
echo ""
|
119
|
+
|
120
|
+
# Step 4: Delivered
|
121
|
+
echo "Step 4: Order delivered..."
|
122
|
+
update_order_status "$order_id" "delivered" "Order delivered to customer"
|
123
|
+
echo ""
|
124
|
+
|
125
|
+
echo "✅ Order workflow completed!"
|
126
|
+
}
|
127
|
+
|
128
|
+
# Main execution
|
129
|
+
main() {
|
130
|
+
# Single status update
|
131
|
+
update_order_status "$ORDER_ID" "$NEW_STATUS" "Status update from POS"
|
132
|
+
|
133
|
+
# Or run through full workflow
|
134
|
+
# order_workflow_example "$ORDER_ID"
|
135
|
+
}
|
136
|
+
|
137
|
+
# Run main function
|
138
|
+
main
|