Automattic\WooCommerce\Internal\PushNotifications\Entities

PushToken::to_rest_format │ public │ WC 11.2.0

Returns this token formatted for the push tokens REST index response.

Deliberately separate from {@see self::to_wpcom_format()}. That method is also the per-token payload the dispatcher POSTs to the WPCOM send endpoint, so adding fields to it would change every notification request.

Metadata is cast to an object so that an empty value encodes as {} rather than [], matching the object type the schema declares for it.

Метод класса: PushToken{}

Хуков нет.

Возвращает

array{user_id: int|null, token: string|null, origin: string|null, device_locale: string|null, id: int|null, device_uuid: string|null, platform: string|null, metadata: stdClass, created_at_gmt: string|null, last_confirmed_at_gmt: string|null, last_sent_at_gmt: string|null}.

Использование

$PushToken = new PushToken();
$PushToken->to_rest_format(): array;

Список изменений

С версии 11.2.0 Введена.

Код PushToken::to_rest_format() WC 11.3.0

public function to_rest_format(): array {
	return array_merge(
		$this->to_wpcom_format(),
		array(
			'id'                    => $this->id,
			'device_uuid'           => $this->device_uuid,
			'platform'              => $this->platform,
			'metadata'              => (object) ( $this->metadata ?? array() ),
			'created_at_gmt'        => $this->to_rest_datetime( $this->created_at_gmt ),
			'last_confirmed_at_gmt' => $this->to_rest_datetime( $this->last_confirmed_at_gmt ),
			'last_sent_at_gmt'      => $this->to_rest_datetime( $this->last_sent_at_gmt ),
		)
	);
}