Skip to content

omnisense/omnifood API reference

Floor
Family
Version
1.x
Verified for real
Not verified for real
Licence
MIT
composer require omnisense/omnifood:1.x-dev

Read from the package's own PHP files at the commit cd454531c385: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.

Omnifood

  • Channel enum

    The platforms an order or a reservation comes from.

    1 method · 11 cases

  • Config class

    A platform's configuration while its factory builds it: the options given, the factory's defaults under them, and the keys that must be filled.

    3 methods

  • MenuInterface interface

    The menu the platform shows: pushed whole (the platform replaces its own), and an item (or a modifier) out of stock for a while.

    2 methods

  • NotifiableInterface interface

    A webhook the platform calls: its body and headers, checked (signature, secret) and read. InvalidSignatureException when the signature does not hold: the controller answers 401 and does nothing. Notification::$id is the platform's id for the event, to handle each once (they retry).

    1 method

  • OrdersInterface interface

    The orders a delivery platform sends to the restaurant: read, accepted (within the platform's delay: Capabilities::$acceptanceDelay), denied, marked ready, cancelled. An order arrives by NotifiableInterface (a webhook) or by orders() (polling); $ref is always the platform's id.

    6 methods

  • PlatformFactory class

    The Omnibus way: a platform's factory fills a Config - its name ("omnifood.factory_name"), the options it cannot do without ("omnifood.required_options") and the defaults of the others - and builds its client from it.

    4 methods

  • PlatformFactoryInterface interface

    Builds a platform's client from its options (a client id, a secret, a store id...).

    2 methods

  • PlatformInterface interface

    A restaurant platform's client, for one restaurant. It implements the capabilities the platform offers - OrdersInterface, MenuInterface, StoreInterface, ReservationsInterface, NotifiableInterface - and Auth\RefreshableInterface or Auth\OAuthInterface when it holds a token.

    3 methods

  • Registry class

    The platforms by name, each built once from its factory and options:

    13 methods

  • ReservationsInterface interface

    The table reservations a booking platform holds for the restaurant.

    7 methods

  • StoreInterface interface

    The restaurant as the platform shows it: open, paused for a rush, its hours.

    4 methods

  • Validator class

    A menu against a platform's capabilities, before anything is sent: the references (present, one each), the names and descriptions' lengths, the prices (in the menu's currency, not negative), the VAT rates, the modifier groups' bounds and how deep they nest. Readable violations, by path, for a back office to show.

    1 method

Omnifood\Auth

  • OAuthInterface interface

    Connecting the restaurant's account from a back office: the URL to send the owner to, the code exchanged on the way back.

    2 methods

  • RefreshableInterface interface

    A platform whose token dies: the client-credentials token (Uber Eats, Deliveroo, TheFork's Auth0) asked for again before it does. The platform fetches one itself when a call needs it; refresh() is for a site that keeps it (a cache, a database) and hands it back through the options.

    2 methods

Omnifood\Bridge\Symfony

  • OmnifoodBundle class

    Omnifood in a Symfony application: the platform packages installed (omnifood/ubereats, omnifood/deliveroo, omnifood/justeat, omnifood/thefork, omnifood/zenchef) registered, the restaurant's platforms built from configuration, Omnifood\Registry and Omnifood\Validator autowired, and each platform injectable by its name, as what it does:

    2 methods · 2 constants

Omnifood\Exception

  • InvalidConfigException class

    A platform misconfigured: a credential missing, an unknown factory.

  • InvalidMenuException class

    The menu breaks the platform's capabilities: nothing was sent.

    1 method · 2 properties

  • InvalidSignatureException class

    A webhook whose signature (or secret) does not hold: answer 401, handle nothing.

    1 method · 1 property

  • NotSupportedException class

    The platform does not do that, or its public documentation does not show how: nothing is guessed, the call is refused.

    1 method

  • OmnifoodException interface

    Every exception Omnifood throws.

  • ProviderException class

    The platform refused, or could not be reached.

    1 method · 3 properties

  • UnauthorizedException class

    The credentials are refused, or lack a scope: the keys must be checked, the account connected again.

Omnifood\Http

  • Redaction class

    What a failed call may carry of its credentials, taken out before the failure leaves the package: an HTTP client's exception quotes the URL called (a key in its query, a password in its user part), and every exception's trace keeps the arguments of the calls under it (the request options, headers and query with the key) unless PHP runs with zend.exception_ignore_args.

    5 methods · 1 constant

Omnifood\Model

  • Allergen enum

    The fourteen allergens EU Regulation 1169/2011 (Annex II) requires a menu to declare.

    1 method · 14 cases

  • Capabilities class

    What a platform takes and imposes, for a back office to show and the Validator to check a menu against before it is sent. What the platform does not say is null (no limit known).

    2 methods · 14 properties

  • Courier class

    Who comes to collect a delivery, when the platform says.

    1 method · 5 properties

  • Customer class

    Who ordered, as much as the platform tells (often a first name and a masked phone).

    1 method · 5 properties

  • DenyReason enum

    Why the restaurant refuses or cancels an order; each platform maps it to its own codes.

    9 cases

  • Guest class

    Who the table is booked for.

    2 methods · 6 properties

  • Hours class

    Opening hours: for each day of the week (1 Monday ... 7 Sunday) its ranges ["11:30", "14:30"], and dates that differ (a holiday closed, a Sunday open). A day with no range is closed; a range may end after midnight ("19:00", "01:00").

    4 methods · 2 properties

  • Line class

    One line of an order: so many of one item, with its choices.

    1 method · 8 properties

  • Modifier class

    A choice on an order's line (a sauce, a size, no onions), itself with its choices where the platform nests them.

    1 method · 6 properties

  • Money class

    An amount in a currency's minor units (cents): 1250 EUR is 12,50 €.

    7 methods · 2 properties

  • Notification class

    What a platform's webhook said, checked: one event about one order, one reservation or the store. $event is the platform's own name for it; $reference the order's (or reservation's) id there, for order() or reservation() to read it whole when the webhook carries only the id; $order or $reservation when it carries it all.

    1 method · 11 properties

  • NotificationSubject enum

    What a webhook is about.

    6 cases

  • Order class

    An order as a platform sent it, the same shape for every platform: what, for whom, how it leaves, how much, when. Amounts are Money (minor units); what the platform does not tell is null. $raw keeps the platform's answer.

    2 methods · 20 properties

  • OrderStatus enum

    Where an order stands, the same for every platform; Order::$raw keeps the platform's own word.

    1 method · 8 cases

  • OrderType enum

    3 cases

  • Reservation class

    A table booked, the same shape for every platform. $reference is null for a reservation not yet recorded (createReservation() answers it with one).

    2 methods · 15 properties

  • ReservationStatus enum

    Where a reservation stands, the same for every platform; Reservation::$raw keeps the platform's own word.

    1 method · 9 cases

  • Slot class

    A time a table can be booked at, and for how many.

    1 method · 4 properties

  • StoreState enum

    4 cases

  • StoreStatus class

    The restaurant as the platform shows it now.

    2 methods · 4 properties

  • Token class

    An access token and when it dies: a site stores it and asks the platform to refresh it in time.

    5 methods · 5 properties

  • Violation class

    One thing a platform would refuse: where (categories[0].items[2].name...) and why, readable.

    2 methods · 2 properties

Omnifood\Model\Menu

  • Category class

    1 method · 4 properties

  • Item class

    A dish or a drink.

    1 method · 10 properties

  • Menu class

    A menu as a site holds it, the same for every platform: categories of items, each item with its choices (modifier groups), its price, its VAT rate, its allergens. Each platform's pushMenu() turns it into its own shape; every reference ($ref) is the restaurant's own (a POS's), the one the platform carries back on the orders.

    2 methods · 6 properties

  • Modifier class

    One option of a group; it may open groups of its own (a menu's main course, and its cooking).

    1 method · 7 properties

  • ModifierGroup class

    A choice on an item: "Your sauce" (exactly 1), "Extras" (0 to 3).

    2 methods · 5 properties

Omnifood

Channel enum

enum Channel Channel.php:6

The platforms an order or a reservation comes from.

case UBEREATS = 'ubereats'
case DELIVEROO = 'deliveroo'
case JUSTEAT = 'justeat'
case THEFORK = 'thefork'
case ZENCHEF = 'zenchef'
case DOORDASH = 'doordash'
case WOLT = 'wolt'
case GLOVO = 'glovo'
case OPENTABLE = 'opentable'
case SEVENROOMS = 'sevenrooms'
case DIRECT = 'direct'

The restaurant's own site, the phone, the walk-in: no platform.

Channel::label()

public function label(): string

Config class

final class Config extends ArrayObject Config.php:13

A platform's configuration while its factory builds it: the options given, the factory's defaults under them, and the keys that must be filled.

Config::defaults()

public function defaults(array $defaults): self

Sets each key not set yet.

Config::validateNotEmpty()

public function validateNotEmpty(array $keys): void

Config::get()

public function get(string $key, mixed $default = null): mixed

MenuInterface interface

interface MenuInterface extends PlatformInterface MenuInterface.php:11

The menu the platform shows: pushed whole (the platform replaces its own), and an item (or a modifier) out of stock for a while.

MenuInterface::pushMenu()

public function pushMenu(Menu $menu): void

A menu that breaks capabilities() is refused before anything is sent (InvalidMenuException).

MenuInterface::setAvailability()

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

$itemRef is the item's POS reference (Item::$ref); $until null: until said otherwise.

NotifiableInterface interface

interface NotifiableInterface extends PlatformInterface NotifiableInterface.php:13

A webhook the platform calls: its body and headers, checked (signature, secret) and read. InvalidSignatureException when the signature does not hold: the controller answers 401 and does nothing. Notification::$id is the platform's id for the event, to handle each once (they retry).

NotifiableInterface::notify()

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

as the request has them, any case

OrdersInterface interface

interface OrdersInterface extends PlatformInterface OrdersInterface.php:14

The orders a delivery platform sends to the restaurant: read, accepted (within the platform's delay: Capabilities::$acceptanceDelay), denied, marked ready, cancelled. An order arrives by NotifiableInterface (a webhook) or by orders() (polling); $ref is always the platform's id.

OrdersInterface::order()

public function order(string $ref): Order

OrdersInterface::orders()

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

The orders placed since then, newest first, where the platform lists them (NotSupportedException where it only pushes them).

OrdersInterface::accept()

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

Accepted; $readyAt is when the kitchen expects it ready, where the platform takes it.

OrdersInterface::deny()

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

OrdersInterface::ready()

public function ready(string $ref): void

Ready for the courier, or for the customer who collects it.

OrdersInterface::cancel()

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

An order already accepted, cancelled by the restaurant.

PlatformFactory class

abstract class PlatformFactory implements PlatformFactoryInterface PlatformFactory.php:19

The Omnibus way: a platform's factory fills a Config - its name ("omnifood.factory_name"), the options it cannot do without ("omnifood.required_options") and the defaults of the others - and builds its client from it.

Options left empty (null, '': an environment variable not set) are as if not given: the defaults stand. A credential is best not required here but asked for when a call needs it, so that a platform without its keys still answers what needs none (capabilities(), a webhook's signature check).

PlatformFactory::__construct()

public function __construct(protected readonly ?HttpClientInterface $http = null)

PlatformFactory::getName()

public function getName(): string

PlatformFactory::create()

public function create(array $options = []): PlatformInterface

PlatformFactory::createConfig()

public function createConfig(array $options = []): Config

PlatformFactoryInterface interface

interface PlatformFactoryInterface PlatformFactoryInterface.php:6

Builds a platform's client from its options (a client id, a secret, a store id...).

PlatformFactoryInterface::getName()

public function getName(): string

The name platforms are configured with: "ubereats", "thefork".

..

PlatformFactoryInterface::create()

public function create(array $options = []): PlatformInterface

PlatformInterface interface

interface PlatformInterface PlatformInterface.php:15

A restaurant platform's client, for one restaurant. It implements the capabilities the platform offers - OrdersInterface, MenuInterface, StoreInterface, ReservationsInterface, NotifiableInterface - and Auth\RefreshableInterface or Auth\OAuthInterface when it holds a token.

What the platform offers but its public documentation does not show throws Exception\NotSupportedException.

PlatformInterface::getName()

public function getName(): string

The name it is configured as: "ubereats", "thefork".

..

PlatformInterface::getChannel()

public function getChannel(): Channel

PlatformInterface::capabilities()

public function capabilities(): Capabilities

What the platform takes and imposes, for a back office and the Validator.

Registry class

final class Registry Registry.php:14

The platforms by name, each built once from its factory and options:

new Registry([new UberEatsPlatformFactory($http)], [ 'ubereats' => ['factory' => 'ubereats', 'options' => ['client_id' => '...', 'client_secret' => '...', 'store_id' => '...']], ]);

Registry::__construct()

public function __construct(iterable $factories, readonly array $config)

Registry::get()

public function get(string $name): PlatformInterface

Registry::create()

public function create(string $name, array $overrides = []): PlatformInterface

A platform built afresh, its configured options with $overrides over them - keys typed in a back office, a token kept in a database. Not kept: get() still gives the configured one.

Registry::has()

public function has(string $name): bool

Registry::options()

public function options(string $name): array

Registry::names()

public function names(): array

Registry::all()

public function all(): array

Registry::orders()

public function orders(): array

Registry::menus()

public function menus(): array

Registry::stores()

public function stores(): array

Registry::reservations()

public function reservations(): array

Registry::notifiables()

public function notifiables(): array

Registry::factories()

public function factories(): array
Returns

the factories installed

ReservationsInterface interface

interface ReservationsInterface extends PlatformInterface ReservationsInterface.php:15

The table reservations a booking platform holds for the restaurant.

The methods that write are named after the reservation - createReservation(), updateReservation(), cancelReservation() - so that one platform may take both orders and reservations: OrdersInterface::cancel() is an order's.

ReservationsInterface::reservations()

public function reservations(\DateTimeImmutable $from, \DateTimeImmutable $to): array

The reservations from $from to $to (their date), oldest first.

ReservationsInterface::reservation()

public function reservation(string $ref): Reservation

ReservationsInterface::createReservation()

public function createReservation(Reservation $reservation): Reservation

A reservation taken by the restaurant (the phone, the site), recorded on the platform: answered with its reference there.

ReservationsInterface::updateReservation()

public function updateReservation(Reservation $reservation): Reservation

$reservation->reference says which; its date, covers, guest and notes replace the platform's.

ReservationsInterface::cancelReservation()

public function cancelReservation(string $ref, ?string $reason = null): void

ReservationsInterface::setStatus()

public function setStatus(string $ref, ReservationStatus $status): void

Arrived, seated, left, no-show...: the service as it goes.

ReservationsInterface::pushAvailability()

public function pushAvailability(array $slots): void

The tables free, slot by slot, for the platform to sell.

StoreInterface interface

interface StoreInterface extends PlatformInterface StoreInterface.php:9

The restaurant as the platform shows it: open, paused for a rush, its hours.

StoreInterface::status()

public function status(): StoreStatus

StoreInterface::pause()

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

No more orders until $until (null: until resume()).

StoreInterface::resume()

public function resume(): void

StoreInterface::setHours()

public function setHours(Hours $hours): void

Validator class

final class Validator Validator.php:22

A menu against a platform's capabilities, before anything is sent: the references (present, one each), the names and descriptions' lengths, the prices (in the menu's currency, not negative), the VAT rates, the modifier groups' bounds and how deep they nest. Readable violations, by path, for a back office to show.

What a platform ignores is not a violation (a photo where it takes none): only what it would refuse.

Validator::validate()

public function validate(Menu $menu, Capabilities $c): array

Omnifood\Auth

OAuthInterface interface

interface OAuthInterface OAuthInterface.php:8

Connecting the restaurant's account from a back office: the URL to send the owner to, the code exchanged on the way back.

OAuthInterface::authorizationUrl()

public function authorizationUrl(string $redirectUri, string $state, array $scopes = []): string

OAuthInterface::exchange()

public function exchange(string $code, string $redirectUri): Token

RefreshableInterface interface

interface RefreshableInterface RefreshableInterface.php:13

A platform whose token dies: the client-credentials token (Uber Eats, Deliveroo, TheFork's Auth0) asked for again before it does. The platform fetches one itself when a call needs it; refresh() is for a site that keeps it (a cache, a database) and hands it back through the options.

RefreshableInterface::token()

public function token(): ?Token

RefreshableInterface::refresh()

public function refresh(): Token

Omnifood\Bridge\Symfony

OmnifoodBundle class

final class OmnifoodBundle extends AbstractBundle OmnifoodBundle.php:49

Omnifood in a Symfony application: the platform packages installed (omnifood/ubereats, omnifood/deliveroo, omnifood/justeat, omnifood/thefork, omnifood/zenchef) registered, the restaurant's platforms built from configuration, Omnifood\Registry and Omnifood\Validator autowired, and each platform injectable by its name, as what it does:

omnifood: platforms: ubereats: { factory: ubereats, options: { client_id: '%env(default::UBEREATS_CLIENT_ID)%', client_secret: '%env(default::UBEREATS_CLIENT_SECRET)%', store_id: '%env(default::UBEREATS_STORE_ID)%' } } thefork: { factory: thefork, options: { client_id: '%env(default::THEFORK_CLIENT_ID)%', client_secret: '%env(default::THEFORK_CLIENT_SECRET)%', restaurant_id: '%env(default::THEFORK_RESTAURANT_ID)%' } }

public function __construct(OrdersInterface $ubereats, ReservationsInterface $thefork) }

Nothing is built, nor checked, when the container compiles: a platform is built the first time it is asked for, and a credential left empty only shows when a call needs it (InvalidConfigException). So a site with no keys yet still boots; Registry::has() says a platform is declared.

An application's own factories (a PlatformFactoryInterface) are registered too, autoconfigured.

const FACTORIES = [UberEatsPlatformFactory::class, DeliverooPlatformFactory::class, JustEatPlatformFactory::class, TheForkPlatformFactory::class, ZenchefPlatformFactory::class]

The platform packages this bundle knows, registered when installed.

const CAPABILITIES = [PlatformInterface::class, OrdersInterface::class, MenuInterface::class, StoreInterface::class, ReservationsInterface::class, NotifiableInterface::class]

What a platform may be injected as, by its name.

OmnifoodBundle::configure()

public function configure(DefinitionConfigurator $definition): void

OmnifoodBundle::loadExtension()

public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void

Omnifood\Exception

InvalidConfigException class

final class InvalidConfigException extends LogicException implements OmnifoodException InvalidConfigException.php:6

A platform misconfigured: a credential missing, an unknown factory.

InvalidMenuException class

final class InvalidMenuException extends InvalidArgumentException implements OmnifoodException InvalidMenuException.php:8

The menu breaks the platform's capabilities: nothing was sent.

public readonly string $platform
public readonly array $violations

InvalidMenuException::__construct()

public function __construct(public readonly string $platform, public readonly array $violations)

InvalidSignatureException class

final class InvalidSignatureException extends RuntimeException implements OmnifoodException InvalidSignatureException.php:6

A webhook whose signature (or secret) does not hold: answer 401, handle nothing.

public readonly string $platform

InvalidSignatureException::__construct()

public function __construct(public readonly string $platform, string $message)

NotSupportedException class

final class NotSupportedException extends LogicException implements OmnifoodException NotSupportedException.php:9

The platform does not do that, or its public documentation does not show how: nothing is guessed, the call is refused.

NotSupportedException::operation()

public static function operation(string $platform, string $operation): self

OmnifoodException interface

interface OmnifoodException extends Throwable OmnifoodException.php:6

Every exception Omnifood throws.

ProviderException class

class ProviderException extends RuntimeException implements OmnifoodException ProviderException.php:6

The platform refused, or could not be reached.

public readonly string $platform
public readonly ?int $status
public readonly ?string $providerCode

The platform's own error code, when it gave one

ProviderException::__construct()

public function __construct(public readonly string $platform, string $message, public readonly ?int $status = null, public readonly ?string $providerCode = null, ?\Throwable $previous = null)

UnauthorizedException class

final class UnauthorizedException extends ProviderException UnauthorizedException.php:6

The credentials are refused, or lack a scope: the keys must be checked, the account connected again.

Omnifood\Http

Redaction class

final class Redaction Redaction.php:22

What a failed call may carry of its credentials, taken out before the failure leaves the package: an HTTP client's exception quotes the URL called (a key in its query, a password in its user part), and every exception's trace keeps the arguments of the calls under it (the request options, headers and query with the key) unless PHP runs with zend.exception_ignore_args.

copy() gives the previous exception to wrap instead of the client's own: the same class and code, its message with the key's parameters, the user part and every secret value replaced by ***, its trace without arguments, its own previous copied the same way. Properties of the client's class beyond those of \Exception are not copied (a Symfony HttpException's response, a PSR-18 exception's request: their URL holds the key). withoutArguments() takes the arguments out of the trace of the exception thrown in its place.

const MASK = '***'

Redaction::secrets()

public static function secrets(string $url, array $options = []): array

The secrets a request carries: the values of its query parameters, headers and body fields named as credentials (key, token, secret, password, signature, auth...), a bearer token, a basic password, the URL's user part.

$options

the HTTP client's options

Redaction::sensitive()

public static function sensitive(string $name): bool

Whether a parameter, header or field of this name holds a credential.

Redaction::text()

public static function text(string $text, array $secrets = []): string

A text without credentials: in every address, the user part and the parameters named as credentials masked (api_key=***); then every secret given, raw or URL-encoded, masked wherever it stands.

Redaction::copy()

public static function copy(\Throwable $failure, array $secrets = []): \Throwable

A copy of a failure to wrap in its place: its class, code, file and line, its message through text(), its trace without arguments, its previous copied the same way.

Redaction::withoutArguments()

public static function withoutArguments(\Throwable $failure): \Throwable

The failure given, the arguments out of its trace (and out of its previous ones'), as zend.exception_ignore_args would have left it.

Omnifood\Model

Allergen enum

enum Allergen Allergen.php:6

The fourteen allergens EU Regulation 1169/2011 (Annex II) requires a menu to declare.

case GLUTEN = 'gluten'
case CRUSTACEANS = 'crustaceans'
case EGGS = 'eggs'
case FISH = 'fish'
case PEANUTS = 'peanuts'
case SOYBEANS = 'soybeans'
case MILK = 'milk'
case NUTS = 'nuts'
case CELERY = 'celery'
case MUSTARD = 'mustard'
case SESAME = 'sesame'
case SULPHITES = 'sulphites'
case LUPIN = 'lupin'
case MOLLUSCS = 'molluscs'

Allergen::label()

public function label(): string

Capabilities class

final readonly class Capabilities Capabilities.php:10

What a platform takes and imposes, for a back office to show and the Validator to check a menu against before it is sent. What the platform does not say is null (no limit known).

public array $orderTypes
public ?int $acceptanceDelay

Seconds the restaurant has to accept a new order before the platform cancels it (Uber Eats: 11.5 minutes)

public bool $readyAt

Whether accept() takes when the order will be ready

public int $modifierDepth

How deep modifiers nest: 0 none, 1 an item's groups, 2 a modifier's own groups.

..

public bool $allergens

Whether the menu carries the EU-14 allergens

public bool $photos
public bool $vatRates

Whether each item carries its VAT rate

public ?int $nameMaxLength
public ?int $descriptionMaxLength
public bool $pauseUntil

Whether pause() takes an end

public bool $deposits

Whether a reservation may carry a deposit or a card guarantee

public bool $availabilityPush

Whether the restaurant can push its free tables (pushAvailability())

public array $currencies

ISO 4217; [] any

public bool $modifiersAreItems

Whether a modifier must be a menu item of its own on the platform (Uber Eats: every option is an item)

Capabilities::__construct()

public function __construct(public array $orderTypes = [], public ?int $acceptanceDelay = null, public bool $readyAt = false, public int $modifierDepth = 1, public bool $allergens = false, public bool $photos = false, public bool $vatRates = false, public ?int $nameMaxLength = null, public ?int $descriptionMaxLength = null, public bool $pauseUntil = false, public bool $deposits = false, public bool $availabilityPush = false, public array $currencies = [], public bool $modifiersAreItems = false)
$currencies

ISO 4217; [] any

Capabilities::takes()

public function takes(OrderType $type): bool

Courier class

final readonly class Courier Courier.php:6

Who comes to collect a delivery, when the platform says.

public ?string $name
public ?string $phone
public ?string $status

The platform's word: "ARRIVED_AT_PICKUP", "rider_assigned".

..

public ?\DateTimeImmutable $arrivesAt
public ?string $vehicle

Courier::__construct()

public function __construct(public ?string $name = null, public ?string $phone = null, public ?string $status = null, public ?\DateTimeImmutable $arrivesAt = null, public ?string $vehicle = null)

Customer class

final readonly class Customer Customer.php:6

Who ordered, as much as the platform tells (often a first name and a masked phone).

public ?string $name
public ?string $phone
public ?string $phoneCode

An extension or code to dial after the platform's masked number

public ?string $email
public ?string $address

The delivery address, one line, when the restaurant delivers itself

Customer::__construct()

public function __construct(public ?string $name = null, public ?string $phone = null, public ?string $phoneCode = null, public ?string $email = null, public ?string $address = null)

DenyReason enum

enum DenyReason DenyReason.php:6

Why the restaurant refuses or cancels an order; each platform maps it to its own codes.

case ITEM_UNAVAILABLE = 'item_unavailable'
case CLOSED = 'closed'
case TOO_BUSY = 'too_busy'
case CUSTOMER_REQUEST = 'customer_request'
case ADDRESS = 'address'
case PRICING = 'pricing'
case SPECIAL_INSTRUCTIONS = 'special_instructions'
case TECHNICAL = 'technical'
case OTHER = 'other'

Guest class

final readonly class Guest Guest.php:6

Who the table is booked for.

public ?string $firstName
public ?string $lastName
public ?string $email
public ?string $phone
public ?string $locale

"fr", "en_GB".

..

public ?string $id

The platform's id for the guest

Guest::__construct()

public function __construct(public ?string $firstName = null, public ?string $lastName = null, public ?string $email = null, public ?string $phone = null, public ?string $locale = null, public ?string $id = null)

Guest::name()

public function name(): string

Hours class

final readonly class Hours Hours.php:11

Opening hours: for each day of the week (1 Monday ... 7 Sunday) its ranges ["11:30", "14:30"], and dates that differ (a holiday closed, a Sunday open). A day with no range is closed; a range may end after midnight ("19:00", "01:00").

public array $week
public array $exceptions

Hours::__construct()

public function __construct(array $week, array $exceptions = [])

Hours::day()

public function day(int $day): array
Returns

the ranges of that day of the week, [] when closed

Hours::on()

public function on(\DateTimeInterface $date): array
Returns

that date's ranges: its exception, or its day of the week's

Hours::isOpenAt()

public function isOpenAt(\DateTimeImmutable $at): bool

Whether $at falls in one of its date's ranges (a range past midnight counted on the day it starts).

Line class

final readonly class Line Line.php:6

One line of an order: so many of one item, with its choices.

public string $name
public int $quantity
public ?Money $unitPrice
public ?Money $total

The line's total, modifiers included, as the platform counts it

public ?string $posRef

The restaurant's reference (Menu\Item::$ref), when the platform carries it back

public ?string $platformRef

The platform's own id for the item

public array $modifiers
public ?string $note

"Well done", "no onions": the customer's words for this line

Line::__construct()

public function __construct(public string $name, public int $quantity, public ?Money $unitPrice = null, public ?Money $total = null, public ?string $posRef = null, public ?string $platformRef = null, public array $modifiers = [], public ?string $note = null)

Modifier class

final readonly class Modifier Modifier.php:6

A choice on an order's line (a sauce, a size, no onions), itself with its choices where the platform nests them.

public string $name
public int $quantity
public ?Money $price

The price of one, on top of the item's

public ?string $posRef

The restaurant's reference for it (Menu\Modifier::$ref), when the platform carries it back

public ?string $group

The modifier group it was chosen in, by name

public array $modifiers

Modifier::__construct()

public function __construct(public string $name, public int $quantity = 1, public ?Money $price = null, public ?string $posRef = null, public ?string $group = null, public array $modifiers = [])

Money class

final readonly class Money Money.php:6

An amount in a currency's minor units (cents): 1250 EUR is 12,50 €.

public string $currency
public int $amount

Money::__construct()

public function __construct(public int $amount, string $currency)

Money::of()

public static function of(int $amount, string $currency): self

Money::equals()

public function equals(self $other): bool

Money::decimal()

public function decimal(): string

In major units, as a provider's decimal API expects ("12.50"); yen and the like have none.

Money::fromDecimal()

public static function fromDecimal(string|float $decimal, string $currency): self

From a provider's decimal ("12.50"), to minor units.

Money::minorDigits()

public static function minorDigits(string $currency): int

How many minor digits a currency has: 2 for most, 0 for JPY, KRW..., 3 for BHD, KWD.

..

Money::__toString()

public function __toString(): string

Notification class

final readonly class Notification Notification.php:14

What a platform's webhook said, checked: one event about one order, one reservation or the store. $event is the platform's own name for it; $reference the order's (or reservation's) id there, for order() or reservation() to read it whole when the webhook carries only the id; $order or $reservation when it carries it all.

public Channel $channel
public string $event

The platform's event type: "orders.notification", "order.new".

..

public NotificationSubject $subject
public ?string $reference
public ?string $id

The platform's id for the event, to handle it once: platforms retry

public ?Order $order
public ?Reservation $reservation
public OrderStatus|ReservationStatus|null $status

The status it announces, when it announces one

public ?\DateTimeImmutable $occurredAt
public ?string $store

The store (restaurant) id it concerns

public array $raw

Notification::__construct()

public function __construct(public Channel $channel, public string $event, public NotificationSubject $subject, public ?string $reference = null, public ?string $id = null, public ?Order $order = null, public ?Reservation $reservation = null, public OrderStatus|ReservationStatus|null $status = null, public ?\DateTimeImmutable $occurredAt = null, public ?string $store = null, public array $raw = [])

NotificationSubject enum

enum NotificationSubject NotificationSubject.php:6

What a webhook is about.

case ORDER = 'order'
case COURIER = 'courier'

The courier of an order: assigned, arrived, gone

case RESERVATION = 'reservation'
case STORE = 'store'
case MENU = 'menu'
case OTHER = 'other'

Order class

final readonly class Order Order.php:14

An order as a platform sent it, the same shape for every platform: what, for whom, how it leaves, how much, when. Amounts are Money (minor units); what the platform does not tell is null. $raw keeps the platform's answer.

public Channel $channel
public string $reference

The platform's id: what every call on the order takes

public ?string $displayId

The short number the courier and the customer say ("A1B2C", "#42")

public OrderType $type
public OrderStatus $status
public array $lines
public ?Customer $customer
public ?Money $total

What the customer paid

public ?Money $subtotal

The items, before fees and discounts

public ?Money $discount

Discounts and promotions, as a positive amount

public ?Money $fees

Delivery, service, bag fees

public ?Money $tax
public ?\DateTimeImmutable $placedAt
public ?\DateTimeImmutable $pickupAt

When it should be ready (collected by the courier or the customer)

public ?\DateTimeImmutable $deliverAt

When it should reach the customer, for a delivery

public ?Courier $courier
public ?string $note

The customer's note for the whole order (allergies included where the platform has no field of its own)

public ?string $store

The store (restaurant) id on the platform

public ?bool $cutlery

Cutlery asked for, when the platform says

public array $raw

Order::__construct()

public function __construct(public Channel $channel, public string $reference, public ?string $displayId, public OrderType $type, public OrderStatus $status, public array $lines = [], public ?Customer $customer = null, public ?Money $total = null, public ?Money $subtotal = null, public ?Money $discount = null, public ?Money $fees = null, public ?Money $tax = null, public ?\DateTimeImmutable $placedAt = null, public ?\DateTimeImmutable $pickupAt = null, public ?\DateTimeImmutable $deliverAt = null, public ?Courier $courier = null, public ?string $note = null, public ?string $store = null, public ?bool $cutlery = null, public array $raw = [])

Order::count()

public function count(): int

How many items, modifiers not counted.

OrderStatus enum

enum OrderStatus OrderStatus.php:6

Where an order stands, the same for every platform; Order::$raw keeps the platform's own word.

case NEW = 'new'

Sent to the restaurant, waiting for its answer

case ACCEPTED = 'accepted'
case READY = 'ready'

Ready for the courier or the customer

case PICKED_UP = 'picked_up'

Collected: on its way, or in the customer's hands

case DELIVERED = 'delivered'
case DENIED = 'denied'

Refused by the restaurant before it was accepted

case CANCELLED = 'cancelled'
case UNKNOWN = 'unknown'

The platform's word for it is not one of these

OrderStatus::isFinal()

public function isFinal(): bool

OrderType enum

enum OrderType OrderType.php:5

case DELIVERY = 'delivery'

Taken to the customer, by the platform's courier or the restaurant's own

case PICKUP = 'pickup'

Collected at the counter by the customer

case DINE_IN = 'dine_in'

Eaten at the restaurant

Reservation class

final readonly class Reservation Reservation.php:11

A table booked, the same shape for every platform. $reference is null for a reservation not yet recorded (createReservation() answers it with one).

public \DateTimeImmutable $date

When the guests come: the date and the time, in the restaurant's time zone

public int $covers
public Guest $guest
public ReservationStatus $status
public ?string $reference
public ?Channel $channel
public ?string $notes

The guest's request ("a high chair", "a birthday")

public ?string $allergies
public ?string $table

The table asked for or given, by its name or number

public ?int $duration

Minutes the table is held

public ?Money $deposit

A deposit or prepayment taken, or a card imprint's guarantee

public ?string $source

Where it came from inside the platform: "widget", "marketplace", "phone".

..

public ?\DateTimeImmutable $createdAt
public ?string $restaurant

The restaurant's id on the platform

public array $raw

Reservation::__construct()

public function __construct(public \DateTimeImmutable $date, public int $covers, public Guest $guest, public ReservationStatus $status = ReservationStatus::CONFIRMED, public ?string $reference = null, public ?Channel $channel = null, public ?string $notes = null, public ?string $allergies = null, public ?string $table = null, public ?int $duration = null, public ?Money $deposit = null, public ?string $source = null, public ?\DateTimeImmutable $createdAt = null, public ?string $restaurant = null, public array $raw = [])

Reservation::with()

public function with(mixed ...$changes): self

The same reservation with its fields replaced: a reference given back, a new time.

ReservationStatus enum

enum ReservationStatus ReservationStatus.php:6

Where a reservation stands, the same for every platform; Reservation::$raw keeps the platform's own word.

case REQUESTED = 'requested'

Asked for, waiting for the restaurant (or a deposit)

case CONFIRMED = 'confirmed'
case ARRIVED = 'arrived'

At the door, not seated yet

case SEATED = 'seated'
case FINISHED = 'finished'

Paid and gone

case NO_SHOW = 'no_show'
case CANCELLED = 'cancelled'
case REFUSED = 'refused'

Refused by the restaurant

case UNKNOWN = 'unknown'

ReservationStatus::isFinal()

public function isFinal(): bool

Slot class

final readonly class Slot Slot.php:6

A time a table can be booked at, and for how many.

public \DateTimeImmutable $start
public int $covers

The covers still bookable at that time; 0 is full

public ?\DateTimeImmutable $end
public ?string $area

The room or terrace it is in, when the platform sells them apart

Slot::__construct()

public function __construct(public \DateTimeImmutable $start, public int $covers, public ?\DateTimeImmutable $end = null, public ?string $area = null)

StoreState enum

enum StoreState StoreState.php:5

case OPEN = 'open'

Taking orders

case PAUSED = 'paused'

Within its hours, but taking none for a while (a rush, a shortage)

case CLOSED = 'closed'

Outside its hours

case UNKNOWN = 'unknown'

StoreStatus class

final readonly class StoreStatus StoreStatus.php:6

The restaurant as the platform shows it now.

public StoreState $state
public ?\DateTimeImmutable $until

When a pause ends, when the platform says

public ?string $reason
public array $raw

StoreStatus::__construct()

public function __construct(public StoreState $state, public ?\DateTimeImmutable $until = null, public ?string $reason = null, public array $raw = [])

StoreStatus::isOpen()

public function isOpen(): bool

Token class

final class Token Token.php:6

An access token and when it dies: a site stores it and asks the platform to refresh it in time.

public readonly string $accessToken
public readonly ?\DateTimeImmutable $expiresAt
public readonly ?string $refreshToken
public readonly array $scopes
public readonly ?string $accountId

Token::__construct()

public function __construct(public readonly string $accessToken, public readonly ?\DateTimeImmutable $expiresAt = null, public readonly ?string $refreshToken = null, public readonly array $scopes = [], public readonly ?string $accountId = null)

Token::isExpired()

public function isExpired(?\DateTimeImmutable $now = null): bool

Token::isExpiring()

public function isExpiring(int $days = 10, ?\DateTimeImmutable $now = null): bool

True within $days of the end: time to refresh.

Token::toArray()

public function toArray(): array

Token::fromArray()

public static function fromArray(array $data): self

Violation class

final readonly class Violation Violation.php:6

One thing a platform would refuse: where (categories[0].items[2].name...) and why, readable.

public string $path
public string $message

Violation::__construct()

public function __construct(public string $path, public string $message)

Violation::__toString()

public function __toString(): string

Omnifood\Model\Menu

Category class

final readonly class Category Category.php:5

public string $ref
public string $name
public array $items
public ?string $description

Category::__construct()

public function __construct(public string $ref, public string $name, public array $items, public ?string $description = null)

Item class

final readonly class Item Item.php:9

A dish or a drink.

public string $ref

The restaurant's reference: the one setAvailability() and the orders take

public string $name
public Money $price
public ?string $description
public ?float $vatRate

In percent: 10.0, 5.5, 20.0

public array $allergens
public ?string $photo

A public URL the platform fetches

public array $modifierGroups
public bool $available
public array $labels

"vegetarian", "vegan", "spicy", "halal"...

Item::__construct()

public function __construct(public string $ref, public string $name, public Money $price, public ?string $description = null, public ?float $vatRate = null, public array $allergens = [], public ?string $photo = null, public array $modifierGroups = [], public bool $available = true, public array $labels = [])
$labels

"vegetarian", "vegan", "spicy", "halal"...

Menu class

final readonly class Menu Menu.php:14

A menu as a site holds it, the same for every platform: categories of items, each item with its choices (modifier groups), its price, its VAT rate, its allergens. Each platform's pushMenu() turns it into its own shape; every reference ($ref) is the restaurant's own (a POS's), the one the platform carries back on the orders.

public string $name
public array $categories
public string $currency
public ?Hours $hours

When it is served; null: whenever the store is open

public ?string $ref
public ?string $description

Menu::__construct()

public function __construct(public string $name, public array $categories, public string $currency = 'EUR', public ?Hours $hours = null, public ?string $ref = null, public ?string $description = null)

Menu::items()

public function items(): array
Returns

every item, in the order of the categories

Modifier class

final readonly class Modifier Modifier.php:9

One option of a group; it may open groups of its own (a menu's main course, and its cooking).

public string $ref
public string $name
public ?Money $price

On top of the item's; null or zero: free

public array $allergens
public bool $available
public array $modifierGroups
public ?float $vatRate

Modifier::__construct()

public function __construct(public string $ref, public string $name, public ?Money $price = null, public array $allergens = [], public bool $available = true, public array $modifierGroups = [], public ?float $vatRate = null)

ModifierGroup class

final readonly class ModifierGroup ModifierGroup.php:6

A choice on an item: "Your sauce" (exactly 1), "Extras" (0 to 3).

public string $ref
public string $name
public array $modifiers
public int $min
public ?int $max

null: as many as there are

ModifierGroup::__construct()

public function __construct(public string $ref, public string $name, public array $modifiers, public int $min = 0, public ?int $max = null)

ModifierGroup::isRequired()

public function isRequired(): bool