Aller au contenu

omnifood/deliveroo Référence de l’API

Étage
Fournisseur · Omnifood
Version
1.x
Suite de conformité
non branchée
Vérifié en réel
Non vérifié en réel
Licence
MIT
composer require omnifood/deliveroo:1.x-dev

Lue dans les fichiers PHP du paquet au commit ad288b0c0578 : 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é.

Omnifood\Deliveroo

  • Api class

    The Deliveroo Partner Platform (api.developers.deliveroo.com, or its sandbox), thin: JSON calls with a Bearer token from Deliveroo's OAuth (client credentials, HTTP Basic), which lives 5 minutes and has no refresh token: a new one is asked for when it dies. Deliveroo's errors, {"error": {"code", "message"}}, as Omnifood's; 401 and 403 as UnauthorizedException.

    5 methods · 5 constants

  • DeliverooPlatform class

    A restaurant on Deliveroo, through the Partner Platform (https://api-docs.deliveroo.com): the Order API (read, list, accept, reject, prep stages, sync status), the Menu API (upload, items unavailable), the Site API (open or closed, opening hours) and the order and rider webhooks, signed.

    23 methods · 3 constants

  • DeliverooPlatformFactory class

    Deliveroo, through its Partner Platform (Order, Menu and Site APIs):

    12 options

Omnifood\Deliveroo

Api class

final class Api Api.php:22

The Deliveroo Partner Platform (api.developers.deliveroo.com, or its sandbox), thin: JSON calls with a Bearer token from Deliveroo's OAuth (client credentials, HTTP Basic), which lives 5 minutes and has no refresh token: a new one is asked for when it dies. Deliveroo's errors, {"error": {"code", "message"}}, as Omnifood's; 401 and 403 as UnauthorizedException.

const PLATFORM = 'deliveroo'
const BASE_URI = 'https://api.developers.deliveroo.com'
const TOKEN_URL = 'https://auth.developers.deliveroo.com/oauth2/token'
const SANDBOX_BASE_URI = 'https://api-sandbox.developers.deliveroo.com'
const SANDBOX_TOKEN_URL = 'https://auth-sandbox.developers.deliveroo.com/oauth2/token'

Api::__construct()

public function __construct(readonly ?string $clientId = null, readonly ?string $clientSecret = null, readonly string $baseUri = self::BASE_URI, readonly string $tokenUrl = self::TOKEN_URL, ?HttpClientInterface $http = null)

Api::request()

public function request(string $method, string $path, array $query = [], array|object|null $json = null): array
Returns

the answer, [] when it has none (204)

Api::token()

public function token(): Token

Api::heldToken()

public function heldToken(): ?Token

Api::refresh()

public function refresh(): Token

DeliverooPlatform class

final class DeliverooPlatform implements OrdersInterface, MenuInterface, StoreInterface, NotifiableInterface, RefreshableInterface DeliverooPlatform.php:52

A restaurant on Deliveroo, through the Partner Platform (https://api-docs.deliveroo.com): the Order API (read, list, accept, reject, prep stages, sync status), the Menu API (upload, items unavailable), the Site API (open or closed, opening hours) and the order and rider webhooks, signed.

A tablet-less site accepts and rejects through the API (within 10 minutes, 7 in some markets, or Deliveroo rejects the order); a site with a Deliveroo tablet (option "tablet") accepts on the tablet, and the till reports whether the order reached it: there accept() and deny() send the sync status. Deliveroo has no call for the restaurant to cancel an order (its customer service does): cancel() throws NotSupportedException.

const CEREALS = ['gluten_wheat', 'gluten_rye', 'gluten_barley', 'gluten_oats']

Deliveroo lists each cereal and each nut; Omnifood's GLUTEN and NUTS are the regulation's families.

const NUTS = ['nuts_almond', 'nuts_hazelnut', 'nuts_walnut', 'nuts_cashew_nut', 'nuts_pecan_nut', 'nuts_brazil_nut', 'nuts_pistachio_nut', 'nuts_macadamia_or_queensland_n…
const DIETS = ['dairy_free', 'gluten_free', 'vegan', 'vegetarian', 'halal', 'keto', 'paleo', 'plant_based']

DeliverooPlatform::__construct()

public function __construct(readonly Api $api, readonly ?string $brandId = null, readonly ?string $siteId = null, readonly ?string $menuId = null, readonly ?string $webhookSecret = null, readonly bool $tablet = false, readonly string $language = 'fr', readonly ?string $mealtimeImage = null, readonly Validator $validator = new Validator())

DeliverooPlatform::getName()

public function getName(): string

DeliverooPlatform::getChannel()

public function getChannel(): Channel

DeliverooPlatform::capabilities()

public function capabilities(): Capabilities

A modifier's options are items of the menu (with their price, VAT rate and allergens); names 2 to 120 characters (categories 3), the descriptions 500. The site closes and opens, with no end set.

DeliverooPlatform::order()

public function order(string $ref): Order

DeliverooPlatform::orders()

public function orders(?\DateTimeImmutable $since = null): array

The site's orders placed since then (the last 24 hours by default; Deliveroo keeps 30 days), newest first, page after page.

DeliverooPlatform::accept()

public function accept(string $ref, ?\DateTimeImmutable $readyAt = null): void

$readyAt is not sent: Deliveroo's own prepare_for stands.

DeliverooPlatform::deny()

public function deny(string $ref, DenyReason $reason, ?string $note = null): void

DeliverooPlatform::ready()

public function ready(string $ref): void

Ready for collection: Deliveroo asks that it be sent when someone presses "ready", never on a timer.

DeliverooPlatform::cancel()

public function cancel(string $ref, DenyReason $reason, ?string $note = null): void

DeliverooPlatform::prepStage()

public function prepStage(string $ref, string $stage, ?int $delay = null): void

Where the kitchen is: in_kitchen (with a delay of 0, 2, 4, 6, 8 or 10 minutes), ready_for_collection_soon, ready_for_collection, collected.

DeliverooPlatform::syncStatus()

public function syncStatus(string $ref, bool $succeeded, ?string $reason = null, ?string $notes = null): void

For a tablet site: whether the order reached the till (failed: its reason, Deliveroo's word).

DeliverooPlatform::pushMenu()

public function pushMenu(Menu $menu): void

The menu uploaded to the site (Deliveroo processes it, then calls the menu webhook). Items marked unavailable in it are not sent so: setAvailability() once the webhook said the menu is in.

DeliverooPlatform::menuPayload()

public function menuPayload(Menu $menu): array

The JSON the upload takes for $menu, for this site.

DeliverooPlatform::setAvailability()

public function setAvailability(string $itemRef, bool $available, ?\DateTimeImmutable $until = null): void

Unavailable until the site's next opening (Deliveroo's "unavailable", reset each morning) when $until is given - Deliveroo takes no date -, hidden until said otherwise when it is not.

DeliverooPlatform::status()

public function status(): StoreStatus

DeliverooPlatform::pause()

public function pause(?\DateTimeImmutable $until = null, ?string $reason = null): void

Closed now; Deliveroo takes no end: resume() opens it again ($until and $reason are not sent).

DeliverooPlatform::resume()

public function resume(): void

DeliverooPlatform::setHours()

public function setHours(Hours $hours): void

The week replaced whole; Hours::$exceptions are not sent (Deliveroo's days off are not mapped).

DeliverooPlatform::notify()

public function notify(string $body, array $headers): Notification

An order event (order.new, order.status_update), a rider event (rider.status_update) or the menu's upload result (menu.upload_result), checked: X-Deliveroo-Hmac-Sha256 is the hex HMAC-SHA256, with the webhook secret, of X-Deliveroo-Sequence-Guid, a space and the raw body. Events come out of order and more than once: an order's Notification::$id is its id and status, the same on a retry; the others' the sequence GUID.

DeliverooPlatform::token()

public function token(): ?Token

DeliverooPlatform::refresh()

public function refresh(): Token

A new token: it lives 5 minutes, and the platform asks for one itself when it needs it.

DeliverooPlatform::toOrder()

public function toOrder(array $o): Order

An order as Deliveroo gives it - the order webhook's body.order, or GET /order/v2/orders/{id} - as an Order.

DeliverooPlatformFactory class

final class DeliverooPlatformFactory extends PlatformFactory DeliverooPlatformFactory.php:26

Deliveroo, through its Partner Platform (Order, Menu and Site APIs):

options: client_id: '%env(default::DELIVEROO_CLIENT_ID)%' # the Developer Portal application's client_secret: '%env(default::DELIVEROO_CLIENT_SECRET)%' brand_id: '%env(default::DELIVEROO_BRAND_ID)%' # given by Deliveroo's integration team site_id: '%env(default::DELIVEROO_SITE_ID)%' # the restaurant's location id, the partner's own menu_id: '%env(default::DELIVEROO_MENU_ID)%' # the menu pushMenu() writes and setAvailability() acts on webhook_secret: '%env(default::DELIVEROO_WEBHOOK_SECRET)%' # given by the account manager once the webhooks are set sandbox: false # api-sandbox / auth-sandbox tablet: false # the site has a Deliveroo tablet: accept()/deny() report the till's sync status language: fr # the language of the menu's texts mealtime_image: ~ # the menu's picture (Deliveroo requires one), else the first item's base_uri: ~ # instead of the production's or the sandbox's token_url: ~

Options

OptionDefault
client_idnull
client_secretnull
brand_idnull
site_idnull
menu_idnull
webhook_secretnull
sandboxfalse
tabletfalse
language'fr'
mealtime_imagenull
base_urinull
token_urlnull