Read from the package's own PHP files at the commit c567fbf9c19e: 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.
ApiclassThe Uber Eats Marketplace APIs (api.uber.com), thin: JSON calls with a Bearer token from Uber's OAuth (client credentials, 30 days), held until it dies - Uber allows 100 token requests an hour - and Uber's errors, {"code", "message"}, as Omnifood's; 401 and 403 as UnauthorizedException.
7 methods · 6 constants
UberEatsPlatformclassA store on Uber Eats, through the Marketplace APIs (https://developer.uber.com/docs/eats/introduction): the Order Fulfillment API Suite (/v1/delivery/order, for stores on webhooks version 1.0.0), the Store API Suite (status), the Menu API (upload, items suspended), the holiday hours (Store API, previous version), the webhooks signed with the client secret, and the merchant's consent to link the store (OAuth, scope eats.pos_provisioning).
24 methods · 2 constants
UberEatsPlatformFactoryclassUber Eats, through the Marketplace APIs (Order Fulfillment, Store, Menu):
11 options
Omnifood\UberEats
Api class
final class Api Api.php:21
The Uber Eats Marketplace APIs (api.uber.com), thin: JSON calls with a Bearer token from Uber's OAuth (client credentials, 30 days), held until it dies - Uber allows 100 token requests an hour - and Uber's errors, {"code", "message"}, as Omnifood's; 401 and 403 as UnauthorizedException.
const PLATFORM = 'ubereats'const BASE_URI = 'https://api.uber.com'const TOKEN_URL = 'https://auth.uber.com/oauth/v2/token'const SANDBOX_BASE_URI = 'https://test-api.uber.com'const SANDBOX_TOKEN_URL = 'https://sandbox-login.uber.com/oauth/v2/token'const SCOPES = ['eats.store', 'eats.order', 'eats.store.orders.read', 'eats.store.status.write']Orders, the store and the menu, its status (each must be granted to the application by Uber).
Api::__construct()
public function __construct(readonly ?string $clientId = null, readonly ?string $clientSecret = null, ?Token $token = null, readonly array $scopes = self::SCOPES, 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(): TokenApi::heldToken()
public function heldToken(): ?TokenApi::refresh()
public function refresh(): TokenApi::grant()
public function grant(array $fields): TokenA token from the token endpoint, the client's id and secret added.
Api::clientId()
public function clientId(): ?stringUberEatsPlatform class
final class UberEatsPlatform implements OrdersInterface, MenuInterface, StoreInterface, NotifiableInterface, RefreshableInterface, OAuthInterface UberEatsPlatform.php:50
A store on Uber Eats, through the Marketplace APIs (https://developer.uber.com/docs/eats/introduction): the Order Fulfillment API Suite (/v1/delivery/order, for stores on webhooks version 1.0.0), the Store API Suite (status), the Menu API (upload, items suspended), the holiday hours (Store API, previous version), the webhooks signed with the client secret, and the merchant's consent to link the store (OAuth, scope eats.pos_provisioning).
A new order (orders.notification) must be accepted or denied within 11.5 minutes, or Uber cancels it. Only the application that is the store's order manager may accept, deny or cancel.
const PROVISIONING_SCOPES = ['eats.pos_provisioning']
UberEatsPlatform::__construct()
public function __construct(readonly Api $api, readonly ?string $storeId = null, readonly ?string $clientSecret = null, readonly string $language = 'en_us', readonly bool $taxInclusive = true, readonly Validator $validator = new Validator())UberEatsPlatform::getName()
public function getName(): stringUberEatsPlatform::getChannel()
public function getChannel(): ChannelUberEatsPlatform::capabilities()
public function capabilities(): CapabilitiesA modifier group's options are items of the menu; the allergens are free strings at Uber (the EU-14 names are sent), the dietary labels VEGAN, VEGETARIAN, GLUTEN_FREE.
UberEatsPlatform::order()
public function order(string $ref): OrderUberEatsPlatform::orders()
public function orders(?\DateTimeImmutable $since = null): arrayThe store's orders created since then (the last 24 hours by default; Uber keeps 60 days), newest first.
UberEatsPlatform::accept()
public function accept(string $ref, ?\DateTimeImmutable $readyAt = null): voidAccepted; $readyAt tells Uber when it will be ready for the courier.
UberEatsPlatform::deny()
public function deny(string $ref, DenyReason $reason, ?string $note = null): voidUberEatsPlatform::ready()
public function ready(string $ref): voidUberEatsPlatform::cancel()
public function cancel(string $ref, DenyReason $reason, ?string $note = null): voidUberEatsPlatform::updateReadyTime()
public function updateReadyTime(string $ref, \DateTimeImmutable $readyAt): voidA new time the order will be ready at (accepted, not yet ready, the courier not on the way).
UberEatsPlatform::pushMenu()
public function pushMenu(Menu $menu): voidThe store's menu replaced whole (Menu::$hours are its service hours: the store's are the union of its menus'). Items marked unavailable are suspended afterwards with setAvailability().
UberEatsPlatform::menuPayload()
public function menuPayload(Menu $menu): array- Returns
the JSON the upload takes for $menu
UberEatsPlatform::setAvailability()
public function setAvailability(string $itemRef, bool $available, ?\DateTimeImmutable $until = null): voidSuspended until $until - Uber needs an end: a year from now when none is given -, or available again (a suspension in the past).
UberEatsPlatform::status()
public function status(): StoreStatusUberEatsPlatform::pause()
public function pause(?\DateTimeImmutable $until = null, ?string $reason = null): voidUberEatsPlatform::resume()
public function resume(): voidUberEatsPlatform::setHours()
public function setHours(Hours $hours): voidThe dates apart (Hours::$exceptions) as Uber's holiday hours, all of them at once (each call replaces the previous ones); a closed date is 00:00 - 00:00. The week is not set here: at Uber it is the menu's service hours (Menu::$hours, pushMenu()).
UberEatsPlatform::notify()
public function notify(string $body, array $headers): NotificationA webhook from Uber, checked: X-Uber-Signature is the lowercase hex HMAC-SHA256 of the raw body with the client secret. It carries the event and the resource's id, not the order: order($notification->reference) reads it. Notification::$id is Uber's event_id (events are retried, and come out of order). The endpoint answers 200, empty.
UberEatsPlatform::token()
public function token(): ?TokenUberEatsPlatform::refresh()
public function refresh(): TokenA new client-credentials token (30 days), for the site to keep and give back as access_token / token_expires_at.
UberEatsPlatform::authorizationUrl()
public function authorizationUrl(string $redirectUri, string $state, array $scopes = []): stringWhere to send the merchant to link their store to the application (scope eats.pos_provisioning); the token exchange() gives is for the provisioning calls only, not for the orders.
UberEatsPlatform::exchange()
public function exchange(string $code, string $redirectUri): TokenUberEatsPlatform::toOrder()
public function toOrder(array $o): OrderAn order as the Order Fulfillment API gives it, as an Order: the prices are in payment.payment_detail (tax included), by cart item.
UberEatsPlatformFactory class
final class UberEatsPlatformFactory extends PlatformFactory UberEatsPlatformFactory.php:27
Uber Eats, through the Marketplace APIs (Order Fulfillment, Store, Menu):
options: client_id: '%env(default::UBEREATS_CLIENT_ID)%' # the Developer Dashboard application's client_secret: '%env(default::UBEREATS_CLIENT_SECRET)%' # also the key of the webhooks' signature store_id: '%env(default::UBEREATS_STORE_ID)%' # the store's id at Uber scopes: [eats.store, eats.order, eats.store.orders.read, eats.store.status.write] access_token: ~ # a token kept by the site (refresh(), token()), and when it dies: token_expires_at: ~ # ATOM; Uber allows 100 token requests an hour language: en_us # the menu's texts' translation key tax_inclusive: true # prices include VAT (vat_rate_percentage), else tax_rate sandbox: false # test-api.uber.com / sandbox-login.uber.com base_uri: ~ token_url: ~
Options
| Option | Default | |
|---|---|---|
client_id | null | |
client_secret | null | |
store_id | null | |
scopes | Api::SCOPES | |
access_token | null | |
token_expires_at | null | |
language | 'en_us' | |
tax_inclusive | true | |
sandbox | false | |
base_uri | null | |
token_url | null |