Lue dans les fichiers PHP du paquet au commit 1c8ac1d37f47 : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.
ApiclassThe JET Connect API (api.flytplatform.com), thin: JSON calls with the brand's key in X-Flyt-Api-Key, and its three error shapes as Omnifood's - {"success": false, "error_message"} (menus, availability, restaurants), {"message"} (order callbacks), {"fault": {"errors": [...]}} - 401 and 403 as UnauthorizedException. Through the application's HTTP client when one is given: the profiler sees the calls, the tests mock them.
2 methods · 2 constants
JustEatPlatformclassA restaurant on Just Eat Takeaway.com through JET Connect, the public point-of-sale API (https://developers.just-eat.com/documentation/jet-connect, reference https://uk.api.just-eat.io/docs/jetconnect/openapi.yaml).
19 methods · 2 constants
JustEatPlatformFactoryclassJust Eat Takeaway.com (Just Eat, Takeaway, Skip The Dishes, Menulog), through JET Connect - the public point-of-sale API:
9 options
Omnifood\JustEat
Api class
final class Api Api.php:21
The JET Connect API (api.flytplatform.com), thin: JSON calls with the brand's key in X-Flyt-Api-Key, and its three error shapes as Omnifood's - {"success": false, "error_message"} (menus, availability, restaurants), {"message"} (order callbacks), {"fault": {"errors": [...]}} - 401 and 403 as UnauthorizedException. Through the application's HTTP client when one is given: the profiler sees the calls, the tests mock them.
const PLATFORM = 'justeat'const BASE_URI = 'https://api.flytplatform.com'
Api::__construct()
public function __construct(readonly ?string $apiKey = null, readonly string $baseUri = self::BASE_URI, ?HttpClientInterface $http = null)Api::request()
public function request(string $method, string $path, array|object|null $json = null): array$jsonan object for "}"
- Returns
the answer, [] when it has no body (204)
JustEatPlatform class
final class JustEatPlatform implements OrdersInterface, MenuInterface, StoreInterface, NotifiableInterface JustEatPlatform.php:57
A restaurant on Just Eat Takeaway.com through JET Connect, the public point-of-sale API (https://developers.just-eat.com/documentation/jet-connect, reference https://uk.api.just-eat.io/docs/jetconnect/openapi.yaml).
How JET Connect works, and what it leaves out:
- An order is accepted on JET's Orderpad (the tablet), then **pushed** to the restaurant's endpoint (Receive Order): notify() reads it. The endpoint answers 200 {"OrderId"} when the order is in, or 202 to take it in later - then accept() (sent-to-pos-success) or deny() (sent-to-pos-failed) within 5 minutes. A failed injection is not a refusal: the order goes to the tablet, to be keyed in by hand.
- JET Connect publishes no call to read an order, list them, mark one ready or cancel one: order(), orders(), ready() and cancel() throw NotSupportedException. Cancellations, the driver's progress and the restaurant set offline by JET arrive as webhooks (notify()).
- The menu is pushed whole (POST /menus) and items are marked out of stock (POST /item-availability); the restaurant is set offline and online, and its service times replaced. Its current state is not readable: status() throws NotSupportedException.
const CEREALS = ['CEREAL_WHEAT', 'CEREAL_RYE', 'CEREAL_BARLEY', 'CEREAL_OATS', 'CEREAL_SPELT', 'CEREAL_KAMUT']JET lists each cereal and each nut; Omnifood's GLUTEN and NUTS are the regulation's families.
const NUTS = ['NUTS_ALMONDS', 'NUTS_HAZELNUTS', 'NUTS_WALNUTS', 'NUTS_CASHEWS', 'NUTS_PECAN', 'NUTS_BRAZIL', 'NUTS_PISTACHIO', 'NUTS_MACADAMIA']
JustEatPlatform::__construct()
public function __construct(readonly Api $api, readonly ?string $restaurant = null, readonly ?string $webhookKey = null, readonly ?string $webhookSecret = null, readonly string $currency = 'GBP', readonly \DateTimeZone $timezone = new \DateTimeZone('Europe/London'), readonly string $menuType = 'DELIVERY', readonly float $standardVatRate = 20.0, readonly Validator $validator = new Validator())JustEatPlatform::getName()
public function getName(): stringJustEatPlatform::getChannel()
public function getChannel(): ChannelJustEatPlatform::capabilities()
public function capabilities(): CapabilitiesOptions are items of their own in JET's schema, with their modifiers: two levels are taken here. Allergens are shown in DE, NL, AT, BE, BG, DK, LU, PL and SK only; VAT is a category, not a rate.
JustEatPlatform::order()
public function order(string $ref): OrderJustEatPlatform::orders()
public function orders(?\DateTimeImmutable $since = null): arrayJustEatPlatform::accept()
public function accept(string $ref, ?\DateTimeImmutable $readyAt = null): voidThe order taken into the till (sent-to-pos-success), after the Receive Order webhook was answered 202. The acceptance itself is the Orderpad's: $readyAt is not sent.
JustEatPlatform::deny()
public function deny(string $ref, DenyReason $reason, ?string $note = null): voidThe order could not be taken into the till (sent-to-pos-failed), after a 202: JET sends it to the tablet's backup flow, where it is keyed in by hand or refused there.
JustEatPlatform::ready()
public function ready(string $ref): voidJustEatPlatform::cancel()
public function cancel(string $ref, DenyReason $reason, ?string $note = null): voidJustEatPlatform::pushMenu()
public function pushMenu(Menu $menu): voidJustEatPlatform::menuPayload()
public function menuPayload(Menu $menu): arrayThe JSON POST /menus takes for $menu, for this restaurant.
JustEatPlatform::setAvailability()
public function setAvailability(string $itemRef, bool $available, ?\DateTimeImmutable $until = null): voidJustEatPlatform::status()
public function status(): StoreStatusJustEatPlatform::pause()
public function pause(?\DateTimeImmutable $until = null, ?string $reason = null): voidOffline: no new order until $until, in the restaurant's local time (null: until resume()). In AT, BE, BG, CH, DE, LU, NL, PL and SK JET brings it back online at 07:00 Amsterdam time the next day whatever is asked. $reason is not sent: JET takes none.
JustEatPlatform::resume()
public function resume(): voidJustEatPlatform::setHours()
public function setHours(Hours $hours): voidThe same week for delivery and collection. JET applies the overlap of these, the menu's availability and its delivery pool's hours; it has no call for dates apart: Hours::$exceptions are not sent (a closed day is a pause()).
JustEatPlatform::notify()
public function notify(string $body, array $headers): NotificationAny of JET Connect's webhooks to the restaurant - Receive Order (the whole order), Cancel Order, Driver Status, Restaurant Temporarily Offline, Failed Order for Backup Flow - told apart by their body.
Checked by what was given to JET: the key, which comes back as the Authorization header; the HMAC secret, as X-JET-Connect-Hash ("HMAC-SHA256 t=...,signature=<base64 HMAC-SHA256 of the body>"), which JET documents on the order webhooks. One of the two must be configured; with the secret alone, a webhook without the hash is refused (configure the key to receive the others, checked by it). JET gives no event id: Notification::$id is composed from the order and the event, the same on a retry.
The endpoint answers each with 200 and the same body (an order: {"OrderId": ...}); a 500 makes JET retry, up to 5 times.
JustEatPlatform::toOrder()
public function toOrder(array $o): OrderA Receive Order body as an Order. Amounts come in minor units without a currency: the configured one.
JustEatPlatformFactory class
final class JustEatPlatformFactory extends PlatformFactory JustEatPlatformFactory.php:28
Just Eat Takeaway.com (Just Eat, Takeaway, Skip The Dishes, Menulog), through JET Connect - the public point-of-sale API:
options: api_key: '%env(default::JUSTEAT_API_KEY)%' # JET Connect's key for the brand (X-Flyt-Api-Key): every call restaurant: '%env(default::JUSTEAT_RESTAURANT)%' # the restaurant's reference as configured by JET Connect (posLocationId) webhook_key: '%env(default::JUSTEAT_WEBHOOK_KEY)%' # the key given to JET for its webhooks (their Authorization header) webhook_secret: '%env(default::JUSTEAT_WEBHOOK_SECRET)%' # the HMAC secret given to JET (X-JET-Connect-Hash) currency: GBP # the orders' amounts come without one timezone: Europe/London # the restaurant's: service times, the end of a pause menu_type: DELIVERY # or COLLECTION standard_vat_rate: 20.0 # an item at this rate is STANDARD_RATE, under it REDUCED_RATE, at 0 NO_TAX base_uri: https://api.flytplatform.com
Nothing is required to build the platform: capabilities() needs no key; a call that needs one and finds none throws InvalidConfigException.
Options
| Option | Default | |
|---|---|---|
api_key | null | |
restaurant | null | |
webhook_key | null | |
webhook_secret | null | |
currency | 'GBP' | |
timezone | 'Europe/London' | |
menu_type | 'DELIVERY' | |
standard_vat_rate | 20.0 | |
base_uri | Api::BASE_URI |