PHP code example of foodticket / jet-connect-client

1. Go to this page and download the library: Download foodticket/jet-connect-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

foodticket / jet-connect-client example snippets


JET_CONNECT_API_KEY=

use Foodticket\JetConnect\Endpoints\JetConnectApi;

$api = new JetConnectApi();

use Foodticket\JetConnect\Enums\Availability;

$api->setItemAvailability(
    availability: Availability::UNAVAILABLE,
    itemsIds: ['plu-123', 'plu-456'],
    restaurant: $restaurantId,
    nextAvailableAt: now()->addHours(2), // optional, only used when UNAVAILABLE
);

$api->ingestMenu(
    restaurants: ['restaurant-id-1'],
    menus: [$menuArray],
    callbackUrl: 'https://yourapp.com/jet-connect/menu-callback', // optional
);

$api->sentToPosSuccess(orderId: $orderId);

use Foodticket\JetConnect\Enums\ErrorCode;

$api->sentToPosFailed(
    orderId: $orderId,
    errorCode: ErrorCode::TIMEOUT,
    errorMessage: 'POS did not respond within the timeout window',
);

$api->orderItemModification(
    orderId: $orderId,
    modifications: [
        [
            'removedItems' => [
                ['plu' => 'plu-123', 'missingQuantity' => 1],
                ['plu' => 'plu-456', 'missingQuantity' => 2],
            ],
        ],
    ],
);

$api->request()->get('/some-endpoint');
$api->request()->post('/some-endpoint', $payload);

$this->routes(function () {
    // ...
    Route::jetConnectWebhooks();
});