foodticket/jet-connect-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

foodticket/jet-connect-client

Composer 安装命令:

composer require foodticket/jet-connect-client

包简介

A PHP client to integrate with the JET Connect API

README 文档

README

GitHub license

This package allows you to easily make requests to JustEatTakeaway's JET Connect API.

Requirements

  • PHP >= 8.3
  • Laravel >= 12.0

Installation

You can install the package via composer:

composer require foodticket/jet-connect

The package will automatically register itself.

Configuration

To start using the JET Connect API you will need an API key. Add the API key to your project's .env file:

JET_CONNECT_API_KEY=

Making requests

All endpoints are accessed through JetConnectApi:

use Foodticket\JetConnect\Endpoints\JetConnectApi;

$api = new JetConnectApi();

setItemAvailability

Mark one or more menu items as available or unavailable for a given restaurant.

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
);
Parameter Type Required Description
availability Availability Yes Availability::AVAILABLE or Availability::UNAVAILABLE
itemsIds array Yes Array of item PLU/reference strings
restaurant string Yes Restaurant identifier
nextAvailableAt Carbon|null No When the item becomes available again (only applies when marking unavailable)

ingestMenu

Push a full menu to JET Connect for one or more restaurants.

$api->ingestMenu(
    restaurants: ['restaurant-id-1'],
    menus: [$menuArray],
    callbackUrl: 'https://yourapp.com/jet-connect/menu-callback', // optional
);
Parameter Type Required Description
restaurants array Yes Array of restaurant identifier strings
menus array Yes Menu payload array
callbackUrl string|null No URL that JET Connect will call when ingestion completes

sentToPosSuccess

Confirm that an order was successfully sent to the POS.

$api->sentToPosSuccess(orderId: $orderId);
Parameter Type Required Description
orderId string Yes The JET Connect order ID

sentToPosFailed

Report that sending an order to the POS failed.

use Foodticket\JetConnect\Enums\ErrorCode;

$api->sentToPosFailed(
    orderId: $orderId,
    errorCode: ErrorCode::TIMEOUT,
    errorMessage: 'POS did not respond within the timeout window',
);
Parameter Type Required Description
orderId string Yes The JET Connect order ID
errorCode ErrorCode Yes One of the error codes below
errorMessage string Yes Human-readable description of the failure

Available ErrorCode values:

Value Description
AUTH_FAILED Order authorization was incorrect
INCORRECT_SETUP Configuration details sent with the order are wrong (e.g. store ID)
IN_USE POS is currently in use and cannot take requests
INACTIVE POS is offline and cannot take orders
MALFORMED_REQUEST Order request was malformed (e.g. malformed JSON)
MENU_ERROR Order had incorrect items (not in stock, PLU not in POS)
NOT_SUPPORTED Integrated ordering is not supported at this restaurant
STORE_CLOSED Store is closed and cannot take orders
TENDER_ERROR Tender type sent to the POS is wrong
TIMEOUT Request to the POS timed out

orderItemModification

Report that one or more items could not be fulfilled, so JET can update the order accordingly.

$api->orderItemModification(
    orderId: $orderId,
    modifications: [
        [
            'removedItems' => [
                ['plu' => 'plu-123', 'missingQuantity' => 1],
                ['plu' => 'plu-456', 'missingQuantity' => 2],
            ],
        ],
    ],
);
Parameter Type Required Description
orderId string Yes The JET Connect order ID
modifications array Yes Array of modification objects (see structure below)

Each modification object:

Key Type Description
removedItems array Items that could not be fulfilled

Each removedItems entry:

Key Type Description
plu string PLU code of the item
missingQuantity int Number of units that could not be fulfilled

Custom requests

To call any JET Connect endpoint not covered above:

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

Webhooks

To start receiving webhooks from JET Connect, you need to add the following route the App\Providers\RouteServiceProvider file:

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

Security Vulnerabilities

If you discover a security vulnerability within this project, please report this by email to developer@foodticket.nl.

统计信息

  • 总下载量: 11.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固