Skip to content

Response Objects

Every API call returns a SveaResource — a typed, read-only, array-accessible object.

Access patterns

php
$order = Svea::checkout()->get('12345678');

$order->status();                      // named getter (preferred in typed code)
$order->status;                        // magic property access
$order['status'];                      // ArrayAccess read
$order->successful();                  // bool helper
$order->getLastResponse()->statusCode; // int — raw HTTP status
$order->getLastResponse()->headers;    // array
$order->getLastResponse()->body;       // string

Read-only

Attempting $order['key'] = $value or unset($order['key']) throws \BadMethodCallException. Response objects are immutable snapshots.

Common subclasses

ClassReturned by
CheckoutResponseSvea::checkout()->create() / get() / update()
AdminOrderResponseSvea::admin()->order(...)->get()
DeliverResponseSvea::admin()->order(...)->deliver(...)
TaskResponseSvea::admin()->task(...)
SubscriptionSvea::subscriptions()->get() / add() / update()
WebhookEventSvea::webhook()->fromRequest() / Webhook::constructEvent()

Released under the MIT License.