@chanaka_nakandala/integration-agent 1.1.1 → 2.0.1
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 +22 -486
- package/dist/index.js.map +1 -1
- package/dist/{cli/init-command.d.ts → init-command.d.ts} +2 -2
- package/dist/init-command.d.ts.map +1 -0
- package/dist/{cli/init-command.js → init-command.js} +78 -44
- package/dist/init-command.js.map +1 -0
- package/package.json +6 -14
- package/agent-personas/ba-agent.yaml +0 -682
- package/agent-personas/developer-agent.yaml +0 -585
- package/dist/cache/file-cache.d.ts +0 -10
- package/dist/cache/file-cache.d.ts.map +0 -1
- package/dist/cache/file-cache.js +0 -79
- package/dist/cache/file-cache.js.map +0 -1
- package/dist/cli/init-command.d.ts.map +0 -1
- package/dist/cli/init-command.js.map +0 -1
- package/dist/scrapers/docs-scraper.d.ts +0 -28
- package/dist/scrapers/docs-scraper.d.ts.map +0 -1
- package/dist/scrapers/docs-scraper.js +0 -200
- package/dist/scrapers/docs-scraper.js.map +0 -1
- package/dist/search/keyword-search.d.ts +0 -39
- package/dist/search/keyword-search.d.ts.map +0 -1
- package/dist/search/keyword-search.js +0 -127
- package/dist/search/keyword-search.js.map +0 -1
- package/dist/tools/code-generation-tool.d.ts +0 -33
- package/dist/tools/code-generation-tool.d.ts.map +0 -1
- package/dist/tools/code-generation-tool.js +0 -62
- package/dist/tools/code-generation-tool.js.map +0 -1
- package/dist/tools/search-result-formatter.d.ts +0 -27
- package/dist/tools/search-result-formatter.d.ts.map +0 -1
- package/dist/tools/search-result-formatter.js +0 -89
- package/dist/tools/search-result-formatter.js.map +0 -1
- package/dist/tools/search-tool.d.ts +0 -9
- package/dist/tools/search-tool.d.ts.map +0 -1
- package/dist/tools/search-tool.js +0 -32
- package/dist/tools/search-tool.js.map +0 -1
- package/dist/tools/template-loader.d.ts +0 -54
- package/dist/tools/template-loader.d.ts.map +0 -1
- package/dist/tools/template-loader.js +0 -148
- package/dist/tools/template-loader.js.map +0 -1
- package/dist/types/search.d.ts +0 -21
- package/dist/types/search.d.ts.map +0 -1
- package/dist/types/search.js +0 -2
- package/dist/types/search.js.map +0 -1
- package/templates/README.md +0 -98
- package/templates/authenticate/curl.template +0 -97
- package/templates/authenticate/java.template +0 -155
- package/templates/authenticate/python.template +0 -111
- package/templates/authenticate/typescript.template +0 -98
- package/templates/create_menu/curl.template +0 -145
- package/templates/create_menu/java.template +0 -285
- package/templates/create_menu/python.template +0 -159
- package/templates/create_menu/typescript.template +0 -184
- package/templates/receive_order/curl.template +0 -138
- package/templates/receive_order/java.template +0 -263
- package/templates/receive_order/python.template +0 -157
- package/templates/receive_order/typescript.template +0 -194
- package/templates/update_item_availability/curl.template +0 -143
- package/templates/update_item_availability/java.template +0 -279
- package/templates/update_item_availability/python.template +0 -203
- package/templates/update_item_availability/typescript.template +0 -194
- package/templates/update_order_status/curl.template +0 -138
- package/templates/update_order_status/java.template +0 -202
- package/templates/update_order_status/python.template +0 -142
- package/templates/update_order_status/typescript.template +0 -139
@@ -1,111 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
@description Grubtech API Authentication - Python
|
3
|
-
@author Grubtech Integration Team
|
4
|
-
@version 1.0.0
|
5
|
-
|
6
|
-
This example demonstrates how to authenticate with the Grubtech API
|
7
|
-
using an API key to obtain an access token.
|
8
|
-
|
9
|
-
Prerequisites:
|
10
|
-
- Python 3.8+
|
11
|
-
- requests library (pip install requests)
|
12
|
-
- Valid Grubtech API key
|
13
|
-
|
14
|
-
Replace the following placeholders:
|
15
|
-
- {{API_KEY}}: Your Grubtech API key
|
16
|
-
- {{PARTNER_ID}}: Your partner identifier
|
17
|
-
"""
|
18
|
-
|
19
|
-
import requests
|
20
|
-
import sys
|
21
|
-
from typing import Dict, Any
|
22
|
-
|
23
|
-
API_KEY = '{{API_KEY}}'
|
24
|
-
PARTNER_ID = '{{PARTNER_ID}}'
|
25
|
-
BASE_URL = 'https://api.grubtech.io'
|
26
|
-
|
27
|
-
|
28
|
-
def authenticate() -> str:
|
29
|
-
"""
|
30
|
-
Authenticate with Grubtech API and obtain access token
|
31
|
-
|
32
|
-
Returns:
|
33
|
-
str: Access token for API requests
|
34
|
-
|
35
|
-
Raises:
|
36
|
-
Exception: If authentication fails
|
37
|
-
"""
|
38
|
-
try:
|
39
|
-
# Construct authentication request
|
40
|
-
url = f'{BASE_URL}/v1/auth/token'
|
41
|
-
headers = {
|
42
|
-
'Content-Type': 'application/json',
|
43
|
-
'x-api-key': API_KEY,
|
44
|
-
}
|
45
|
-
payload = {
|
46
|
-
'partnerId': PARTNER_ID,
|
47
|
-
'grantType': 'api_key',
|
48
|
-
}
|
49
|
-
|
50
|
-
# Make authentication request
|
51
|
-
response = requests.post(url, json=payload, headers=headers, timeout=10)
|
52
|
-
|
53
|
-
# Check for errors
|
54
|
-
if not response.ok:
|
55
|
-
raise Exception(
|
56
|
-
f'Authentication failed: {response.status_code} - {response.text}'
|
57
|
-
)
|
58
|
-
|
59
|
-
# Extract token from response
|
60
|
-
data: Dict[str, Any] = response.json()
|
61
|
-
token = data['token']
|
62
|
-
expires_in = data.get('expiresIn', 'unknown')
|
63
|
-
|
64
|
-
print(f'Authentication successful!')
|
65
|
-
print(f'Token expires in: {expires_in} seconds')
|
66
|
-
|
67
|
-
return token
|
68
|
-
|
69
|
-
except requests.RequestException as e:
|
70
|
-
print(f'Authentication error: {e}', file=sys.stderr)
|
71
|
-
raise
|
72
|
-
except Exception as e:
|
73
|
-
print(f'Unexpected error: {e}', file=sys.stderr)
|
74
|
-
raise
|
75
|
-
|
76
|
-
|
77
|
-
def example_api_call(token: str) -> Dict[str, Any]:
|
78
|
-
"""
|
79
|
-
Example: Use token in subsequent API requests
|
80
|
-
|
81
|
-
Args:
|
82
|
-
token: Access token from authenticate()
|
83
|
-
|
84
|
-
Returns:
|
85
|
-
API response data
|
86
|
-
"""
|
87
|
-
url = f'{BASE_URL}/v1/menus'
|
88
|
-
headers = {
|
89
|
-
'Authorization': f'Bearer {token}',
|
90
|
-
'Content-Type': 'application/json',
|
91
|
-
}
|
92
|
-
|
93
|
-
response = requests.get(url, headers=headers, timeout=10)
|
94
|
-
|
95
|
-
if not response.ok:
|
96
|
-
raise Exception(f'API call failed: {response.status_code}')
|
97
|
-
|
98
|
-
return response.json()
|
99
|
-
|
100
|
-
|
101
|
-
if __name__ == '__main__':
|
102
|
-
try:
|
103
|
-
# Authenticate and get token
|
104
|
-
access_token = authenticate()
|
105
|
-
|
106
|
-
# Use token for API calls
|
107
|
-
menus = example_api_call(access_token)
|
108
|
-
print(f'Menus: {menus}')
|
109
|
-
|
110
|
-
except Exception as e:
|
111
|
-
sys.exit(1)
|
@@ -1,98 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @description Grubtech API Authentication - TypeScript
|
3
|
-
* @author Grubtech Integration Team
|
4
|
-
* @version 1.0.0
|
5
|
-
*
|
6
|
-
* This example demonstrates how to authenticate with the Grubtech API
|
7
|
-
* using an API key to obtain an access token.
|
8
|
-
*
|
9
|
-
* Prerequisites:
|
10
|
-
* - Node.js 18+ with fetch API support
|
11
|
-
* - Valid Grubtech API key
|
12
|
-
*
|
13
|
-
* Replace the following placeholders:
|
14
|
-
* - {{API_KEY}}: Your Grubtech API key
|
15
|
-
* - {{PARTNER_ID}}: Your partner identifier
|
16
|
-
*/
|
17
|
-
|
18
|
-
const API_KEY = '{{API_KEY}}';
|
19
|
-
const PARTNER_ID = '{{PARTNER_ID}}';
|
20
|
-
const BASE_URL = 'https://api.grubtech.io';
|
21
|
-
|
22
|
-
interface AuthResponse {
|
23
|
-
token: string;
|
24
|
-
expiresIn: number;
|
25
|
-
tokenType: string;
|
26
|
-
}
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Authenticate with Grubtech API and obtain access token
|
30
|
-
*/
|
31
|
-
async function authenticate(): Promise<string> {
|
32
|
-
try {
|
33
|
-
// Construct authentication request
|
34
|
-
const response = await fetch(`${BASE_URL}/v1/auth/token`, {
|
35
|
-
method: 'POST',
|
36
|
-
headers: {
|
37
|
-
'Content-Type': 'application/json',
|
38
|
-
'x-api-key': API_KEY,
|
39
|
-
},
|
40
|
-
body: JSON.stringify({
|
41
|
-
partnerId: PARTNER_ID,
|
42
|
-
grantType: 'api_key',
|
43
|
-
}),
|
44
|
-
});
|
45
|
-
|
46
|
-
// Check for errors
|
47
|
-
if (!response.ok) {
|
48
|
-
const errorBody = await response.text();
|
49
|
-
throw new Error(
|
50
|
-
`Authentication failed: ${response.status} - ${errorBody}`
|
51
|
-
);
|
52
|
-
}
|
53
|
-
|
54
|
-
// Extract token from response
|
55
|
-
const data: AuthResponse = await response.json();
|
56
|
-
const token = data.token;
|
57
|
-
|
58
|
-
console.log('Authentication successful!');
|
59
|
-
console.log(`Token expires in: ${data.expiresIn} seconds`);
|
60
|
-
|
61
|
-
return token;
|
62
|
-
} catch (error) {
|
63
|
-
console.error('Authentication error:', error);
|
64
|
-
throw error;
|
65
|
-
}
|
66
|
-
}
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Example: Use token in subsequent API requests
|
70
|
-
*/
|
71
|
-
async function exampleApiCall(token: string) {
|
72
|
-
const response = await fetch(`${BASE_URL}/v1/menus`, {
|
73
|
-
method: 'GET',
|
74
|
-
headers: {
|
75
|
-
'Authorization': `Bearer ${token}`,
|
76
|
-
'Content-Type': 'application/json',
|
77
|
-
},
|
78
|
-
});
|
79
|
-
|
80
|
-
if (!response.ok) {
|
81
|
-
throw new Error(`API call failed: ${response.status}`);
|
82
|
-
}
|
83
|
-
|
84
|
-
return response.json();
|
85
|
-
}
|
86
|
-
|
87
|
-
// Main execution
|
88
|
-
(async () => {
|
89
|
-
try {
|
90
|
-
const token = await authenticate();
|
91
|
-
|
92
|
-
// Use token for API calls
|
93
|
-
const menus = await exampleApiCall(token);
|
94
|
-
console.log('Menus:', menus);
|
95
|
-
} catch (error) {
|
96
|
-
process.exit(1);
|
97
|
-
}
|
98
|
-
})();
|
@@ -1,145 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# Grubtech Menu Sync - cURL
|
4
|
-
#
|
5
|
-
# This example demonstrates how to push menu data to Grubtech API.
|
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
|
-
# - {{MENU_DATA}}: Your menu data in the required format
|
15
|
-
|
16
|
-
AUTH_TOKEN="{{AUTH_TOKEN}}"
|
17
|
-
BASE_URL="https://api.grubtech.io"
|
18
|
-
|
19
|
-
# Example menu data (replace with your actual menu)
|
20
|
-
MENU_DATA='{
|
21
|
-
"name": "Restaurant Menu",
|
22
|
-
"description": "Main menu with categories and items",
|
23
|
-
"categories": [
|
24
|
-
{
|
25
|
-
"id": "cat-1",
|
26
|
-
"name": "Appetizers",
|
27
|
-
"description": "Start your meal right",
|
28
|
-
"sortOrder": 1,
|
29
|
-
"items": [
|
30
|
-
{
|
31
|
-
"id": "item-1",
|
32
|
-
"name": "Spring Rolls",
|
33
|
-
"description": "Crispy vegetable spring rolls",
|
34
|
-
"price": 8.99,
|
35
|
-
"available": true,
|
36
|
-
"modifiers": [
|
37
|
-
{
|
38
|
-
"id": "mod-1",
|
39
|
-
"name": "Extra Sauce",
|
40
|
-
"price": 1.50,
|
41
|
-
"available": true
|
42
|
-
}
|
43
|
-
]
|
44
|
-
}
|
45
|
-
]
|
46
|
-
},
|
47
|
-
{
|
48
|
-
"id": "cat-2",
|
49
|
-
"name": "Main Courses",
|
50
|
-
"description": "Delicious entrees",
|
51
|
-
"sortOrder": 2,
|
52
|
-
"items": [
|
53
|
-
{
|
54
|
-
"id": "item-2",
|
55
|
-
"name": "Grilled Chicken",
|
56
|
-
"description": "Tender chicken with herbs",
|
57
|
-
"price": 15.99,
|
58
|
-
"available": true,
|
59
|
-
"modifiers": []
|
60
|
-
}
|
61
|
-
]
|
62
|
-
}
|
63
|
-
]
|
64
|
-
}'
|
65
|
-
|
66
|
-
# Push menu data to Grubtech API
|
67
|
-
create_menu() {
|
68
|
-
echo "Creating menu in Grubtech..."
|
69
|
-
|
70
|
-
# Make menu creation request
|
71
|
-
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
72
|
-
"${BASE_URL}/v1/menus" \
|
73
|
-
-H "Authorization: Bearer ${AUTH_TOKEN}" \
|
74
|
-
-H "Content-Type: application/json" \
|
75
|
-
-d "${MENU_DATA}")
|
76
|
-
|
77
|
-
# Extract HTTP status code and body
|
78
|
-
HTTP_CODE=$(echo "$RESPONSE" | tail -n 1)
|
79
|
-
BODY=$(echo "$RESPONSE" | sed '$d')
|
80
|
-
|
81
|
-
# Check for errors
|
82
|
-
if [ "$HTTP_CODE" -ne 200 ] && [ "$HTTP_CODE" -ne 201 ]; then
|
83
|
-
echo "❌ Menu creation failed: HTTP $HTTP_CODE"
|
84
|
-
echo "Response: $BODY"
|
85
|
-
return 1
|
86
|
-
fi
|
87
|
-
|
88
|
-
# Extract menu ID from response
|
89
|
-
if command -v jq &> /dev/null; then
|
90
|
-
MENU_ID=$(echo "$BODY" | jq -r '.menuId')
|
91
|
-
STATUS=$(echo "$BODY" | jq -r '.status')
|
92
|
-
|
93
|
-
echo "✅ Menu created successfully!"
|
94
|
-
echo "Menu ID: ${MENU_ID}"
|
95
|
-
echo "Status: ${STATUS}"
|
96
|
-
else
|
97
|
-
# Fallback: manual parsing
|
98
|
-
MENU_ID=$(echo "$BODY" | grep -o '"menuId":"[^"]*' | cut -d'"' -f4)
|
99
|
-
echo "✅ Menu created successfully!"
|
100
|
-
echo "Menu ID: ${MENU_ID}"
|
101
|
-
echo "Note: Install jq for better JSON parsing"
|
102
|
-
fi
|
103
|
-
|
104
|
-
echo "$MENU_ID"
|
105
|
-
}
|
106
|
-
|
107
|
-
# Update existing menu
|
108
|
-
update_menu() {
|
109
|
-
local MENU_ID=$1
|
110
|
-
|
111
|
-
echo "Updating menu ${MENU_ID}..."
|
112
|
-
|
113
|
-
curl -s -X PUT \
|
114
|
-
"${BASE_URL}/v1/menus/${MENU_ID}" \
|
115
|
-
-H "Authorization: Bearer ${AUTH_TOKEN}" \
|
116
|
-
-H "Content-Type: application/json" \
|
117
|
-
-d "${MENU_DATA}"
|
118
|
-
|
119
|
-
if [ $? -eq 0 ]; then
|
120
|
-
echo "✅ Menu updated successfully!"
|
121
|
-
else
|
122
|
-
echo "❌ Menu update failed"
|
123
|
-
return 1
|
124
|
-
fi
|
125
|
-
}
|
126
|
-
|
127
|
-
# Main execution
|
128
|
-
main() {
|
129
|
-
# Create menu
|
130
|
-
MENU_ID=$(create_menu)
|
131
|
-
|
132
|
-
if [ -z "$MENU_ID" ]; then
|
133
|
-
echo "Failed to create menu"
|
134
|
-
exit 1
|
135
|
-
fi
|
136
|
-
|
137
|
-
echo ""
|
138
|
-
echo "Menu created with ID: ${MENU_ID}"
|
139
|
-
|
140
|
-
# Optionally update the menu
|
141
|
-
# update_menu "$MENU_ID"
|
142
|
-
}
|
143
|
-
|
144
|
-
# Run main function
|
145
|
-
main
|
@@ -1,285 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Grubtech Menu Sync - Java (Spring Boot)
|
3
|
-
*
|
4
|
-
* This example demonstrates how to push menu data to Grubtech API.
|
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
|
-
* - {{MENU_DATA}}: Your menu data in the required format
|
14
|
-
*/
|
15
|
-
|
16
|
-
package com.example.grubtech;
|
17
|
-
|
18
|
-
import org.springframework.http.HttpHeaders;
|
19
|
-
import org.springframework.http.MediaType;
|
20
|
-
import org.springframework.web.reactive.function.client.WebClient;
|
21
|
-
import reactor.core.publisher.Mono;
|
22
|
-
|
23
|
-
import java.util.ArrayList;
|
24
|
-
import java.util.List;
|
25
|
-
import java.util.Map;
|
26
|
-
|
27
|
-
public class GrubtechMenuSync {
|
28
|
-
|
29
|
-
private static final String AUTH_TOKEN = "{{AUTH_TOKEN}}";
|
30
|
-
private static final String BASE_URL = "https://api.grubtech.io";
|
31
|
-
|
32
|
-
private final WebClient webClient;
|
33
|
-
|
34
|
-
public GrubtechMenuSync() {
|
35
|
-
this.webClient = WebClient.builder()
|
36
|
-
.baseUrl(BASE_URL)
|
37
|
-
.build();
|
38
|
-
}
|
39
|
-
|
40
|
-
/**
|
41
|
-
* Push menu data to Grubtech API
|
42
|
-
*
|
43
|
-
* @param menuData Menu data object
|
44
|
-
* @return Menu ID from response
|
45
|
-
*/
|
46
|
-
public String createMenu(MenuData menuData) {
|
47
|
-
try {
|
48
|
-
// Validate menu data
|
49
|
-
if (menuData.getCategories() == null || menuData.getCategories().isEmpty()) {
|
50
|
-
throw new IllegalArgumentException("Menu must have at least one category");
|
51
|
-
}
|
52
|
-
|
53
|
-
// Make menu creation request
|
54
|
-
MenuResponse response = webClient.post()
|
55
|
-
.uri("/v1/menus")
|
56
|
-
.header(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN)
|
57
|
-
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
58
|
-
.bodyValue(menuData)
|
59
|
-
.retrieve()
|
60
|
-
.onStatus(
|
61
|
-
status -> !status.is2xxSuccessful(),
|
62
|
-
clientResponse -> clientResponse.bodyToMono(String.class)
|
63
|
-
.flatMap(errorBody -> Mono.error(
|
64
|
-
new RuntimeException(
|
65
|
-
"Menu creation failed: " +
|
66
|
-
clientResponse.statusCode() +
|
67
|
-
" - " + errorBody
|
68
|
-
)
|
69
|
-
))
|
70
|
-
)
|
71
|
-
.bodyToMono(MenuResponse.class)
|
72
|
-
.block();
|
73
|
-
|
74
|
-
if (response == null || response.getMenuId() == null) {
|
75
|
-
throw new RuntimeException("No menu ID received from response");
|
76
|
-
}
|
77
|
-
|
78
|
-
System.out.println("✅ Menu created successfully!");
|
79
|
-
System.out.println("Menu ID: " + response.getMenuId());
|
80
|
-
System.out.println("Status: " + response.getStatus());
|
81
|
-
|
82
|
-
return response.getMenuId();
|
83
|
-
|
84
|
-
} catch (Exception e) {
|
85
|
-
System.err.println("❌ Menu creation error: " + e.getMessage());
|
86
|
-
throw e;
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Update existing menu
|
92
|
-
*
|
93
|
-
* @param menuId ID of the menu to update
|
94
|
-
* @param menuData Updated menu data
|
95
|
-
*/
|
96
|
-
public void updateMenu(String menuId, MenuData menuData) {
|
97
|
-
try {
|
98
|
-
webClient.put()
|
99
|
-
.uri("/v1/menus/" + menuId)
|
100
|
-
.header(HttpHeaders.AUTHORIZATION, "Bearer " + AUTH_TOKEN)
|
101
|
-
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
|
102
|
-
.bodyValue(menuData)
|
103
|
-
.retrieve()
|
104
|
-
.onStatus(
|
105
|
-
status -> !status.is2xxSuccessful(),
|
106
|
-
clientResponse -> Mono.error(
|
107
|
-
new RuntimeException("Menu update failed: " + clientResponse.statusCode())
|
108
|
-
)
|
109
|
-
)
|
110
|
-
.toBodilessEntity()
|
111
|
-
.block();
|
112
|
-
|
113
|
-
System.out.println("✅ Menu updated successfully!");
|
114
|
-
|
115
|
-
} catch (Exception e) {
|
116
|
-
System.err.println("❌ Menu update error: " + e.getMessage());
|
117
|
-
throw e;
|
118
|
-
}
|
119
|
-
}
|
120
|
-
|
121
|
-
/**
|
122
|
-
* Create example menu data
|
123
|
-
*/
|
124
|
-
private static MenuData createExampleMenuData() {
|
125
|
-
MenuData menu = new MenuData();
|
126
|
-
menu.setName("Restaurant Menu");
|
127
|
-
menu.setDescription("Main menu with categories and items");
|
128
|
-
|
129
|
-
List<MenuCategory> categories = new ArrayList<>();
|
130
|
-
|
131
|
-
// Appetizers category
|
132
|
-
MenuCategory appetizers = new MenuCategory();
|
133
|
-
appetizers.setId("cat-1");
|
134
|
-
appetizers.setName("Appetizers");
|
135
|
-
appetizers.setDescription("Start your meal right");
|
136
|
-
appetizers.setSortOrder(1);
|
137
|
-
|
138
|
-
MenuItem springRolls = new MenuItem();
|
139
|
-
springRolls.setId("item-1");
|
140
|
-
springRolls.setName("Spring Rolls");
|
141
|
-
springRolls.setDescription("Crispy vegetable spring rolls");
|
142
|
-
springRolls.setPrice(8.99);
|
143
|
-
springRolls.setAvailable(true);
|
144
|
-
|
145
|
-
Modifier extraSauce = new Modifier();
|
146
|
-
extraSauce.setId("mod-1");
|
147
|
-
extraSauce.setName("Extra Sauce");
|
148
|
-
extraSauce.setPrice(1.50);
|
149
|
-
extraSauce.setAvailable(true);
|
150
|
-
|
151
|
-
springRolls.setModifiers(List.of(extraSauce));
|
152
|
-
appetizers.setItems(List.of(springRolls));
|
153
|
-
|
154
|
-
// Main courses category
|
155
|
-
MenuCategory mainCourses = new MenuCategory();
|
156
|
-
mainCourses.setId("cat-2");
|
157
|
-
mainCourses.setName("Main Courses");
|
158
|
-
mainCourses.setDescription("Delicious entrees");
|
159
|
-
mainCourses.setSortOrder(2);
|
160
|
-
|
161
|
-
MenuItem chicken = new MenuItem();
|
162
|
-
chicken.setId("item-2");
|
163
|
-
chicken.setName("Grilled Chicken");
|
164
|
-
chicken.setDescription("Tender chicken with herbs");
|
165
|
-
chicken.setPrice(15.99);
|
166
|
-
chicken.setAvailable(true);
|
167
|
-
chicken.setModifiers(new ArrayList<>());
|
168
|
-
|
169
|
-
mainCourses.setItems(List.of(chicken));
|
170
|
-
|
171
|
-
categories.add(appetizers);
|
172
|
-
categories.add(mainCourses);
|
173
|
-
menu.setCategories(categories);
|
174
|
-
|
175
|
-
return menu;
|
176
|
-
}
|
177
|
-
|
178
|
-
// Data models
|
179
|
-
public static class MenuData {
|
180
|
-
private String name;
|
181
|
-
private String description;
|
182
|
-
private List<MenuCategory> categories;
|
183
|
-
|
184
|
-
// Getters and setters
|
185
|
-
public String getName() { return name; }
|
186
|
-
public void setName(String name) { this.name = name; }
|
187
|
-
public String getDescription() { return description; }
|
188
|
-
public void setDescription(String description) { this.description = description; }
|
189
|
-
public List<MenuCategory> getCategories() { return categories; }
|
190
|
-
public void setCategories(List<MenuCategory> categories) { this.categories = categories; }
|
191
|
-
}
|
192
|
-
|
193
|
-
public static class MenuCategory {
|
194
|
-
private String id;
|
195
|
-
private String name;
|
196
|
-
private String description;
|
197
|
-
private int sortOrder;
|
198
|
-
private List<MenuItem> items;
|
199
|
-
|
200
|
-
// Getters and setters omitted for brevity
|
201
|
-
public String getId() { return id; }
|
202
|
-
public void setId(String id) { this.id = id; }
|
203
|
-
public String getName() { return name; }
|
204
|
-
public void setName(String name) { this.name = name; }
|
205
|
-
public String getDescription() { return description; }
|
206
|
-
public void setDescription(String description) { this.description = description; }
|
207
|
-
public int getSortOrder() { return sortOrder; }
|
208
|
-
public void setSortOrder(int sortOrder) { this.sortOrder = sortOrder; }
|
209
|
-
public List<MenuItem> getItems() { return items; }
|
210
|
-
public void setItems(List<MenuItem> items) { this.items = items; }
|
211
|
-
}
|
212
|
-
|
213
|
-
public static class MenuItem {
|
214
|
-
private String id;
|
215
|
-
private String name;
|
216
|
-
private String description;
|
217
|
-
private double price;
|
218
|
-
private boolean available;
|
219
|
-
private List<Modifier> modifiers;
|
220
|
-
|
221
|
-
// Getters and setters omitted for brevity
|
222
|
-
public String getId() { return id; }
|
223
|
-
public void setId(String id) { this.id = id; }
|
224
|
-
public String getName() { return name; }
|
225
|
-
public void setName(String name) { this.name = name; }
|
226
|
-
public String getDescription() { return description; }
|
227
|
-
public void setDescription(String description) { this.description = description; }
|
228
|
-
public double getPrice() { return price; }
|
229
|
-
public void setPrice(double price) { this.price = price; }
|
230
|
-
public boolean isAvailable() { return available; }
|
231
|
-
public void setAvailable(boolean available) { this.available = available; }
|
232
|
-
public List<Modifier> getModifiers() { return modifiers; }
|
233
|
-
public void setModifiers(List<Modifier> modifiers) { this.modifiers = modifiers; }
|
234
|
-
}
|
235
|
-
|
236
|
-
public static class Modifier {
|
237
|
-
private String id;
|
238
|
-
private String name;
|
239
|
-
private double price;
|
240
|
-
private boolean available;
|
241
|
-
|
242
|
-
// Getters and setters omitted for brevity
|
243
|
-
public String getId() { return id; }
|
244
|
-
public void setId(String id) { this.id = id; }
|
245
|
-
public String getName() { return name; }
|
246
|
-
public void setName(String name) { this.name = name; }
|
247
|
-
public double getPrice() { return price; }
|
248
|
-
public void setPrice(double price) { this.price = price; }
|
249
|
-
public boolean isAvailable() { return available; }
|
250
|
-
public void setAvailable(boolean available) { this.available = available; }
|
251
|
-
}
|
252
|
-
|
253
|
-
public static class MenuResponse {
|
254
|
-
private String menuId;
|
255
|
-
private String status;
|
256
|
-
private String message;
|
257
|
-
|
258
|
-
// Getters and setters
|
259
|
-
public String getMenuId() { return menuId; }
|
260
|
-
public void setMenuId(String menuId) { this.menuId = menuId; }
|
261
|
-
public String getStatus() { return status; }
|
262
|
-
public void setStatus(String status) { this.status = status; }
|
263
|
-
public String getMessage() { return message; }
|
264
|
-
public void setMessage(String message) { this.message = message; }
|
265
|
-
}
|
266
|
-
|
267
|
-
// Main method for testing
|
268
|
-
public static void main(String[] args) {
|
269
|
-
try {
|
270
|
-
GrubtechMenuSync menuSync = new GrubtechMenuSync();
|
271
|
-
|
272
|
-
// Create example menu data
|
273
|
-
MenuData menuData = createExampleMenuData();
|
274
|
-
|
275
|
-
// Create menu
|
276
|
-
String menuId = menuSync.createMenu(menuData);
|
277
|
-
|
278
|
-
// Optionally update the menu
|
279
|
-
// menuSync.updateMenu(menuId, menuData);
|
280
|
-
|
281
|
-
} catch (Exception e) {
|
282
|
-
System.exit(1);
|
283
|
-
}
|
284
|
-
}
|
285
|
-
}
|