# Curl Command Output - createMenu.php

## What You'll See in Console

When the service calls createMenu.php, you'll see the **exact curl command** that's being executed.

---

## Console Output Example

```
================================================================================
EQUIVALENT CURL COMMAND FOR createMenu.php
================================================================================
Request ID: 550e8400-e29b-41d4-a716-446655440000
Attempt: 1/3

You can run this command manually to test:

curl --location 'https://zavedenia.com/apps/orderapprestaurant/api/createMenu.php' \
--header 'Content-Type: application/json' \
--data '{"city":"sofia","token":"8800a3a64cfa947c552391f48069cacd","menu":[{"name":"Salads","name_uk":"Salads","description":"Fresh salads","description_uk":"Fresh salads","items":[{"name":"Caesar Salad","name_uk":"Caesar Salad","description":"Classic Caesar with romaine lettuce","description_uk":"Classic Caesar with romaine lettuce","measure":1,"items":[{"name":"Стандартна порция","gramaj":250,"cena":15.0}]},{"name":"Greek Salad","name_uk":"Greek Salad","description":"Traditional Greek salad","description_uk":"Traditional Greek salad","measure":1,"items":[{"name":"Стандартна порция","gramaj":300,"cena":12.0}]}]},{"name":"Main Courses","name_uk":"Main Courses","description":"Hot main dishes","description_uk":"Hot main dishes","items":[{"name":"Grilled Chicken","name_uk":"Grilled Chicken","description":"Marinated chicken breast","description_uk":"Marinated chicken breast","measure":1,"items":[{"name":"Стандартна порция","gramaj":350,"cena":18.0}]}]}]}'

================================================================================
```

---

## How to Use It

### 1. Copy from Console
When you see the curl command in the console, you can:
- Copy it directly
- Paste it into your terminal
- Run it manually to test createMenu.php

### 2. Extract from Logs
Use the helper script to extract curl commands from logs:

```bash
# List recent request IDs
./extract_curl_from_logs.sh

# Extract curl for specific request
./extract_curl_from_logs.sh 550e8400-e29b-41d4-a716-446655440000
```

This will:
- Find the curl command in logs
- Save it to a file: `curl_command_<request_id>.sh`
- Make it executable
- You can then run: `./curl_command_<request_id>.sh`

### 3. Manual Testing
Copy the curl command and run it in your terminal to test createMenu.php independently:

```bash
curl --location 'https://zavedenia.com/apps/orderapprestaurant/api/createMenu.php' \
--header 'Content-Type: application/json' \
--data '{ ... payload ... }'
```

---

## Pretty Printed Version

You can also format the curl command for easier reading:

```bash
curl --location 'https://zavedenia.com/apps/orderapprestaurant/api/createMenu.php' \
--header 'Content-Type: application/json' \
--data '{
  "city": "sofia",
  "token": "8800a3a64cfa947c552391f48069cacd",
  "menu": [
    {
      "name": "Salads",
      "name_uk": "Salads",
      "description": "Fresh salads",
      "description_uk": "Fresh salads",
      "items": [
        {
          "name": "Caesar Salad",
          "name_uk": "Caesar Salad",
          "description": "Classic Caesar with romaine lettuce",
          "description_uk": "Classic Caesar with romaine lettuce",
          "measure": 1,
          "items": [
            {
              "name": "Стандартна порция",
              "gramaj": 250,
              "cena": 15.0
            }
          ]
        }
      ]
    }
  ]
}'
```

---

## Complete Console Flow

When the service runs, you'll see:

1. **Payload Being Sent** (formatted JSON)
```
================================================================================
PAYLOAD BEING SENT TO createMenu.php
================================================================================
Full Payload:
{ ... formatted JSON ... }
================================================================================
```

2. **Equivalent Curl Command** (ready to copy/paste)
```
================================================================================
EQUIVALENT CURL COMMAND FOR createMenu.php
================================================================================
curl --location 'https://...' \
--header 'Content-Type: application/json' \
--data '{ ... }'
================================================================================
```

3. **Response from createMenu.php** (actual result)
```
================================================================================
RESPONSE FROM createMenu.php
================================================================================
Status Code: 200
Full Response:
{"status":"success", ...}
================================================================================
```

---

## Verification Workflow

### Step 1: Make Request
```bash
curl --location 'http://localhost:8000/menu-items/insert' \
--header 'Authorization: Bearer 1f82e364-9c2d-4c59-86b0-8f83c7f0285f' \
--form 'file=@"menu.jpg"' \
--form 'city="sofia"' \
--form 'token="8800a3a64cfa947c552391f48069cacd"'
```

### Step 2: Watch Console
You'll see:
- Menu extraction response
- Payload being sent
- **Curl command** (copy this!)
- Response from API

### Step 3: Test Manually
Copy the curl command from console and run it directly:
```bash
# Paste the curl command here and run
curl --location 'https://zavedenia.com/...' --data '...'
```

This lets you:
- Verify the exact request being made
- Test createMenu.php independently
- Debug issues with the external API
- Share the exact request with others

---

## Log File Entry

The curl command is also logged to `logs/app.log`:

```json
{
  "timestamp": "2025-12-10T14:23:48.456789",
  "level": "INFO",
  "event": "CREATE_MENU_CURL_COMMAND",
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "curl_command": "curl --location 'https://...' --header 'Content-Type: application/json' --data '{...}'"
}
```

You can extract it later using:
```bash
grep "CREATE_MENU_CURL_COMMAND" logs/app.log
```

Or use the helper script:
```bash
./extract_curl_from_logs.sh <request_id>
```

---

## Summary

✅ **Console**: Curl command printed in a nice box
✅ **Logs**: Curl command saved in JSON format
✅ **Copy/Paste**: Ready to run in terminal
✅ **Helper Script**: Extract curl from logs by request ID
✅ **Manual Testing**: Test createMenu.php independently
✅ **Debugging**: Verify exact request being made

Now you can see, copy, and test the exact curl command that's being sent to createMenu.php! 🎉
