@chanaka_nakandala/integration-agent 1.1.0 → 2.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.
Files changed (65) hide show
  1. package/README.md +369 -60
  2. package/dist/index.js +22 -486
  3. package/dist/index.js.map +1 -1
  4. package/dist/{cli/init-command.d.ts → init-command.d.ts} +2 -2
  5. package/dist/init-command.d.ts.map +1 -0
  6. package/dist/{cli/init-command.js → init-command.js} +72 -46
  7. package/dist/init-command.js.map +1 -0
  8. package/package.json +5 -11
  9. package/agent-personas/ba-agent.yaml +0 -682
  10. package/agent-personas/developer-agent.yaml +0 -585
  11. package/dist/cache/file-cache.d.ts +0 -10
  12. package/dist/cache/file-cache.d.ts.map +0 -1
  13. package/dist/cache/file-cache.js +0 -79
  14. package/dist/cache/file-cache.js.map +0 -1
  15. package/dist/cli/init-command.d.ts.map +0 -1
  16. package/dist/cli/init-command.js.map +0 -1
  17. package/dist/scrapers/docs-scraper.d.ts +0 -28
  18. package/dist/scrapers/docs-scraper.d.ts.map +0 -1
  19. package/dist/scrapers/docs-scraper.js +0 -200
  20. package/dist/scrapers/docs-scraper.js.map +0 -1
  21. package/dist/search/keyword-search.d.ts +0 -39
  22. package/dist/search/keyword-search.d.ts.map +0 -1
  23. package/dist/search/keyword-search.js +0 -127
  24. package/dist/search/keyword-search.js.map +0 -1
  25. package/dist/tools/code-generation-tool.d.ts +0 -33
  26. package/dist/tools/code-generation-tool.d.ts.map +0 -1
  27. package/dist/tools/code-generation-tool.js +0 -62
  28. package/dist/tools/code-generation-tool.js.map +0 -1
  29. package/dist/tools/search-result-formatter.d.ts +0 -27
  30. package/dist/tools/search-result-formatter.d.ts.map +0 -1
  31. package/dist/tools/search-result-formatter.js +0 -89
  32. package/dist/tools/search-result-formatter.js.map +0 -1
  33. package/dist/tools/search-tool.d.ts +0 -9
  34. package/dist/tools/search-tool.d.ts.map +0 -1
  35. package/dist/tools/search-tool.js +0 -32
  36. package/dist/tools/search-tool.js.map +0 -1
  37. package/dist/tools/template-loader.d.ts +0 -54
  38. package/dist/tools/template-loader.d.ts.map +0 -1
  39. package/dist/tools/template-loader.js +0 -148
  40. package/dist/tools/template-loader.js.map +0 -1
  41. package/dist/types/search.d.ts +0 -21
  42. package/dist/types/search.d.ts.map +0 -1
  43. package/dist/types/search.js +0 -2
  44. package/dist/types/search.js.map +0 -1
  45. package/templates/README.md +0 -98
  46. package/templates/authenticate/curl.template +0 -97
  47. package/templates/authenticate/java.template +0 -155
  48. package/templates/authenticate/python.template +0 -111
  49. package/templates/authenticate/typescript.template +0 -98
  50. package/templates/create_menu/curl.template +0 -145
  51. package/templates/create_menu/java.template +0 -285
  52. package/templates/create_menu/python.template +0 -159
  53. package/templates/create_menu/typescript.template +0 -184
  54. package/templates/receive_order/curl.template +0 -138
  55. package/templates/receive_order/java.template +0 -263
  56. package/templates/receive_order/python.template +0 -157
  57. package/templates/receive_order/typescript.template +0 -194
  58. package/templates/update_item_availability/curl.template +0 -143
  59. package/templates/update_item_availability/java.template +0 -279
  60. package/templates/update_item_availability/python.template +0 -203
  61. package/templates/update_item_availability/typescript.template +0 -194
  62. package/templates/update_order_status/curl.template +0 -138
  63. package/templates/update_order_status/java.template +0 -202
  64. package/templates/update_order_status/python.template +0 -142
  65. package/templates/update_order_status/typescript.template +0 -139
@@ -1,194 +0,0 @@
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
- })();
@@ -1,138 +0,0 @@
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
@@ -1,202 +0,0 @@
1
- /**
2
- * Grubtech Order Status Update - Java (Spring Boot)
3
- *
4
- * This example demonstrates how to update order status in Grubtech.
5
- *
6
- * Prerequisites:
7
- * - Java 17+
8
- * - Spring Boot 3.x
9
- * - Spring WebFlux (for WebClient)
10
- *
11
- * Replace the following placeholders:
12
- * - {{AUTH_TOKEN}}: Access token from authentication step
13
- * - {{ORDER_ID}}: The Grubtech order ID to update
14
- * - {{NEW_STATUS}}: The new status value
15
- */
16
-
17
- package com.example.grubtech;
18
-
19
- import org.springframework.http.HttpHeaders;
20
- import org.springframework.http.MediaType;
21
- import org.springframework.stereotype.Service;
22
- import org.springframework.web.reactive.function.client.WebClient;
23
- import reactor.core.publisher.Mono;
24
-
25
- import java.time.Instant;
26
- import java.util.HashMap;
27
- import java.util.Map;
28
-
29
- @Service
30
- public class GrubtechOrderStatusService {
31
-
32
- private static final String AUTH_TOKEN = "{{AUTH_TOKEN}}";
33
- private static final String BASE_URL = "https://api.grubtech.io";
34
-
35
- private final WebClient webClient;
36
-
37
- /**
38
- * Valid order status values
39
- */
40
- public enum OrderStatus {
41
- ACCEPTED("accepted"),
42
- PREPARING("preparing"),
43
- READY("ready"),
44
- DELIVERED("delivered"),
45
- CANCELLED("cancelled");
46
-
47
- private final String value;
48
-
49
- OrderStatus(String value) {
50
- this.value = value;
51
- }
52
-
53
- public String getValue() {
54
- return value;
55
- }
56
- }
57
-
58
- public GrubtechOrderStatusService() {
59
- this.webClient = WebClient.builder()
60
- .baseUrl(BASE_URL)
61
- .build();
62
- }
63
-
64
- /**
65
- * Update order status in Grubtech
66
- *
67
- * @param orderId The Grubtech order ID
68
- * @param newStatus The new status value
69
- * @param notes Optional notes about the status change
70
- * @return Status update response
71
- */
72
- public StatusUpdateResponse updateOrderStatus(
73
- String orderId,
74
- OrderStatus newStatus,
75
- String notes
76
- ) {
77
- try {
78
- // Construct status update payload
79
- Map<String, Object> payload = new HashMap<>();
80
- payload.put("orderId", orderId);
81
- payload.put("status", newStatus.getValue());
82
- payload.put("timestamp", Instant.now().toString());
83
-
84
- if (notes != null && !notes.isEmpty()) {
85
- payload.put("notes", notes);
86
- }
87
-
88
- System.out.println("Updating order " + orderId + " to status: " + newStatus.getValue());
89
-
90
- // Make status update request
91
- StatusUpdateResponse response = webClient.put()
92
- .uri("/v1/orders/" + orderId + "/status")
93
- .header(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN)
94
- .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
95
- .bodyValue(payload)
96
- .retrieve()
97
- .onStatus(
98
- status -> !status.is2xxSuccessful(),
99
- clientResponse -> clientResponse.bodyToMono(String.class)
100
- .flatMap(errorBody -> Mono.error(
101
- new RuntimeException(
102
- "Status update failed: " +
103
- clientResponse.statusCode() +
104
- " - " + errorBody
105
- )
106
- ))
107
- )
108
- .bodyToMono(StatusUpdateResponse.class)
109
- .block();
110
-
111
- if (response == null) {
112
- throw new RuntimeException("No response received from status update");
113
- }
114
-
115
- System.out.println("✅ Order status updated successfully!");
116
- System.out.println("Order ID: " + response.getOrderId());
117
- System.out.println("New Status: " + response.getStatus());
118
- System.out.println("Updated At: " + response.getUpdatedAt());
119
-
120
- return response;
121
-
122
- } catch (Exception e) {
123
- System.err.println("❌ Status update error: " + e.getMessage());
124
- throw e;
125
- }
126
- }
127
-
128
- /**
129
- * Example: Update order through typical workflow
130
- *
131
- * @param orderId The Grubtech order ID
132
- */
133
- public void orderWorkflowExample(String orderId) {
134
- try {
135
- // Step 1: Accept the order
136
- updateOrderStatus(orderId, OrderStatus.ACCEPTED, "Order confirmed");
137
-
138
- // Step 2: Start preparing
139
- updateOrderStatus(orderId, OrderStatus.PREPARING, "Chef started cooking");
140
-
141
- // Step 3: Mark as ready
142
- updateOrderStatus(orderId, OrderStatus.READY, "Order ready for pickup");
143
-
144
- // Step 4: Mark as delivered
145
- updateOrderStatus(orderId, OrderStatus.DELIVERED, "Order delivered to customer");
146
-
147
- System.out.println("✅ Order workflow completed!");
148
-
149
- } catch (Exception e) {
150
- System.err.println("❌ Workflow error: " + e.getMessage());
151
-
152
- // If something goes wrong, cancel the order
153
- updateOrderStatus(orderId, OrderStatus.CANCELLED, "Unable to fulfill order");
154
- }
155
- }
156
-
157
- /**
158
- * Response model for status update
159
- */
160
- public static class StatusUpdateResponse {
161
- private boolean success;
162
- private String orderId;
163
- private String status;
164
- private String updatedAt;
165
- private String message;
166
-
167
- // Getters and setters
168
- public boolean isSuccess() { return success; }
169
- public void setSuccess(boolean success) { this.success = success; }
170
-
171
- public String getOrderId() { return orderId; }
172
- public void setOrderId(String orderId) { this.orderId = orderId; }
173
-
174
- public String getStatus() { return status; }
175
- public void setStatus(String status) { this.status = status; }
176
-
177
- public String getUpdatedAt() { return updatedAt; }
178
- public void setUpdatedAt(String updatedAt) { this.updatedAt = updatedAt; }
179
-
180
- public String getMessage() { return message; }
181
- public void setMessage(String message) { this.message = message; }
182
- }
183
-
184
- // Main method for testing
185
- public static void main(String[] args) {
186
- try {
187
- GrubtechOrderStatusService service = new GrubtechOrderStatusService();
188
-
189
- String orderId = "{{ORDER_ID}}";
190
- OrderStatus newStatus = OrderStatus.PREPARING; // Change to {{NEW_STATUS}}
191
-
192
- // Single status update
193
- service.updateOrderStatus(orderId, newStatus, "Status update from POS");
194
-
195
- // Or run through full workflow
196
- // service.orderWorkflowExample(orderId);
197
-
198
- } catch (Exception e) {
199
- System.exit(1);
200
- }
201
- }
202
- }
@@ -1,142 +0,0 @@
1
- """
2
- Grubtech Order Status Update - Python
3
-
4
- This example demonstrates how to update order status in Grubtech.
5
-
6
- Prerequisites:
7
- - Python 3.8+
8
- - requests library (pip install requests)
9
- - Valid access token from authentication
10
-
11
- Replace the following placeholders:
12
- - {{AUTH_TOKEN}}: Access token from authentication step
13
- - {{ORDER_ID}}: The Grubtech order ID to update
14
- - {{NEW_STATUS}}: The new status value
15
- """
16
-
17
- import requests
18
- import sys
19
- from datetime import datetime
20
- from enum import Enum
21
- from typing import Dict, Any, Optional
22
-
23
- AUTH_TOKEN = '{{AUTH_TOKEN}}'
24
- BASE_URL = 'https://api.grubtech.io'
25
-
26
-
27
- class OrderStatus(Enum):
28
- """Valid order status values"""
29
- ACCEPTED = 'accepted'
30
- PREPARING = 'preparing'
31
- READY = 'ready'
32
- DELIVERED = 'delivered'
33
- CANCELLED = 'cancelled'
34
-
35
-
36
- def update_order_status(
37
- order_id: str,
38
- new_status: OrderStatus,
39
- notes: Optional[str] = None
40
- ) -> Dict[str, Any]:
41
- """
42
- Update order status in Grubtech
43
-
44
- Args:
45
- order_id: The Grubtech order ID
46
- new_status: The new status value
47
- notes: Optional notes about the status change
48
-
49
- Returns:
50
- Dict: Response from API
51
-
52
- Raises:
53
- Exception: If status update fails
54
- """
55
- try:
56
- # Construct status update payload
57
- payload = {
58
- 'orderId': order_id,
59
- 'status': new_status.value,
60
- 'timestamp': datetime.utcnow().isoformat() + 'Z',
61
- }
62
-
63
- if notes:
64
- payload['notes'] = notes
65
-
66
- print(f'Updating order {order_id} to status: {new_status.value}')
67
-
68
- # Make status update request
69
- url = f'{BASE_URL}/v1/orders/{order_id}/status'
70
- headers = {
71
- 'Authorization': f'Bearer {AUTH_TOKEN}',
72
- 'Content-Type': 'application/json',
73
- }
74
-
75
- response = requests.put(url, json=payload, headers=headers, timeout=10)
76
-
77
- # Check for errors
78
- if not response.ok:
79
- raise Exception(
80
- f'Status update failed: {response.status_code} - {response.text}'
81
- )
82
-
83
- # Parse response
84
- data = response.json()
85
-
86
- print(f'✅ Order status updated successfully!')
87
- print(f'Order ID: {data["orderId"]}')
88
- print(f'New Status: {data["status"]}')
89
- print(f'Updated At: {data["updatedAt"]}')
90
-
91
- return data
92
-
93
- except requests.RequestException as e:
94
- print(f'❌ Status update error: {e}', file=sys.stderr)
95
- raise
96
- except Exception as e:
97
- print(f'❌ Unexpected error: {e}', file=sys.stderr)
98
- raise
99
-
100
-
101
- def order_workflow_example(order_id: str) -> None:
102
- """
103
- Example: Update order through typical workflow
104
-
105
- Args:
106
- order_id: The Grubtech order ID
107
- """
108
- try:
109
- # Step 1: Accept the order
110
- update_order_status(order_id, OrderStatus.ACCEPTED, 'Order confirmed')
111
-
112
- # Step 2: Start preparing
113
- update_order_status(order_id, OrderStatus.PREPARING, 'Chef started cooking')
114
-
115
- # Step 3: Mark as ready
116
- update_order_status(order_id, OrderStatus.READY, 'Order ready for pickup')
117
-
118
- # Step 4: Mark as delivered
119
- update_order_status(order_id, OrderStatus.DELIVERED, 'Order delivered to customer')
120
-
121
- print('✅ Order workflow completed!')
122
-
123
- except Exception as e:
124
- print(f'❌ Workflow error: {e}', file=sys.stderr)
125
-
126
- # If something goes wrong, cancel the order
127
- update_order_status(order_id, OrderStatus.CANCELLED, 'Unable to fulfill order')
128
-
129
-
130
- if __name__ == '__main__':
131
- try:
132
- order_id = '{{ORDER_ID}}'
133
- new_status = OrderStatus.PREPARING # Change to {{NEW_STATUS}}
134
-
135
- # Single status update
136
- update_order_status(order_id, new_status, 'Status update from POS')
137
-
138
- # Or run through full workflow
139
- # order_workflow_example(order_id)
140
-
141
- except Exception as e:
142
- sys.exit(1)