File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/AccountController.php.tar
wp-content/plugins/google-listings-and-ads/src/API/Site/Controllers/Ads/AccountController.php 0000644 00000013122 15156072610 0036322 0 ustar 00 var/www/vhosts/uyarreklam.com.tr/httpdocs <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads;
use Automattic\WooCommerce\GoogleListingsAndAds\Ads\AccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\BaseController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\TransportMethods;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\RESTServer;
use Exception;
use WP_REST_Request as Request;
use WP_REST_Response as Response;
defined( 'ABSPATH' ) || exit;
/**
* Class AccountController
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Ads
*/
class AccountController extends BaseController {
/**
* Service used to access / update Ads account data.
*
* @var AccountService
*/
protected $account;
/**
* AccountController constructor.
*
* @param RESTServer $server
* @param AccountService $account
*/
public function __construct( RESTServer $server, AccountService $account ) {
parent::__construct( $server );
$this->account = $account;
}
/**
* Register rest routes with WordPress.
*/
public function register_routes(): void {
$this->register_route(
'ads/accounts',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_accounts_callback(),
'permission_callback' => $this->get_permission_callback(),
],
[
'methods' => TransportMethods::CREATABLE,
'callback' => $this->create_or_link_account_callback(),
'permission_callback' => $this->get_permission_callback(),
'args' => $this->get_schema_properties(),
],
'schema' => $this->get_api_response_schema_callback(),
]
);
$this->register_route(
'ads/connection',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_connected_ads_account_callback(),
'permission_callback' => $this->get_permission_callback(),
],
[
'methods' => TransportMethods::DELETABLE,
'callback' => $this->disconnect_ads_account_callback(),
'permission_callback' => $this->get_permission_callback(),
],
]
);
$this->register_route(
'ads/billing-status',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_billing_status_callback(),
'permission_callback' => $this->get_permission_callback(),
],
]
);
$this->register_route(
'ads/account-status',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_ads_account_has_access(),
'permission_callback' => $this->get_permission_callback(),
],
]
);
}
/**
* Get the callback function for the list accounts request.
*
* @return callable
*/
protected function get_accounts_callback(): callable {
return function () {
try {
return new Response( $this->account->get_accounts() );
} catch ( Exception $e ) {
return $this->response_from_exception( $e );
}
};
}
/**
* Get the callback function for creating or linking an account.
*
* @return callable
*/
protected function create_or_link_account_callback(): callable {
return function ( Request $request ) {
try {
$link_id = absint( $request['id'] );
if ( $link_id ) {
$this->account->use_existing_account( $link_id );
}
$account_data = $this->account->setup_account();
return $this->prepare_item_for_response( $account_data, $request );
} catch ( Exception $e ) {
return $this->response_from_exception( $e );
}
};
}
/**
* Get the callback function for the connected ads account.
*
* @return callable
*/
protected function get_connected_ads_account_callback(): callable {
return function () {
return $this->account->get_connected_account();
};
}
/**
* Get the callback function for disconnecting a merchant.
*
* @return callable
*/
protected function disconnect_ads_account_callback(): callable {
return function () {
$this->account->disconnect();
return [
'status' => 'success',
'message' => __( 'Successfully disconnected.', 'google-listings-and-ads' ),
];
};
}
/**
* Get the callback function for retrieving the billing setup status.
*
* @return callable
*/
protected function get_billing_status_callback(): callable {
return function () {
return $this->account->get_billing_status();
};
}
/**
* Get the callback function for retrieving the account access status for ads.
*
* @return callable
*/
protected function get_ads_account_has_access(): callable {
return function () {
try {
return $this->account->get_ads_account_has_access();
} catch ( Exception $e ) {
return $this->response_from_exception( $e );
}
};
}
/**
* Get the item schema for the controller.
*
* @return array
*/
protected function get_schema_properties(): array {
return [
'id' => [
'type' => 'number',
'description' => __( 'Google Ads Account ID.', 'google-listings-and-ads' ),
'context' => [ 'view', 'edit' ],
'validate_callback' => 'rest_validate_request_arg',
'required' => false,
],
'billing_url' => [
'type' => 'string',
'description' => __( 'Billing Flow URL.', 'google-listings-and-ads' ),
'context' => [ 'view', 'edit' ],
'readonly' => true,
],
];
}
/**
* Get the item schema name for the controller.
*
* Used for building the API response schema.
*
* @return string
*/
protected function get_schema_title(): string {
return 'account';
}
}
wp-content/plugins/google-listings-and-ads/src/API/Site/Controllers/Google/AccountController.php 0000644 00000014120 15156124055 0037027 0 ustar 00 var/www/vhosts/uyarreklam.com.tr/httpdocs <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Google;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Connection;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\BaseController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\TransportMethods;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\RESTServer;
use Exception;
use WP_REST_Request as Request;
defined( 'ABSPATH' ) || exit;
/**
* Class AccountController
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Google
*/
class AccountController extends BaseController {
/**
* @var Connection
*/
protected $connection;
/**
* Mapping between the client page name and its path.
* The first value is also used as a default,
* and changing the order of keys/values may affect things below.
*
* @var string[]
*/
private const NEXT_PATH_MAPPING = [
'setup-mc' => '/google/setup-mc',
'setup-ads' => '/google/setup-ads',
'reconnect' => '/google/settings&subpath=/reconnect-google-account',
];
/**
* AccountController constructor.
*
* @param RESTServer $server
* @param Connection $connection
*/
public function __construct( RESTServer $server, Connection $connection ) {
parent::__construct( $server );
$this->connection = $connection;
}
/**
* Register rest routes with WordPress.
*/
public function register_routes(): void {
$this->register_route(
'google/connect',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_connect_callback(),
'permission_callback' => $this->get_permission_callback(),
'args' => $this->get_connect_params(),
],
[
'methods' => TransportMethods::DELETABLE,
'callback' => $this->get_disconnect_callback(),
'permission_callback' => $this->get_permission_callback(),
],
'schema' => $this->get_api_response_schema_callback(),
]
);
$this->register_route(
'google/connected',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_connected_callback(),
'permission_callback' => $this->get_permission_callback(),
],
]
);
$this->register_route(
'google/reconnected',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_reconnected_callback(),
'permission_callback' => $this->get_permission_callback(),
],
]
);
}
/**
* Get the callback function for the connection request.
*
* @return callable
*/
protected function get_connect_callback(): callable {
return function ( Request $request ) {
try {
$next = $request->get_param( 'next_page_name' );
$login_hint = $request->get_param( 'login_hint' ) ?: '';
$path = self::NEXT_PATH_MAPPING[ $next ];
return [
'url' => $this->connection->connect(
admin_url( "admin.php?page=wc-admin&path={$path}" ),
$login_hint
),
];
} catch ( Exception $e ) {
return $this->response_from_exception( $e );
}
};
}
/**
* Get the query params for the connection request.
*
* @return array
*/
protected function get_connect_params(): array {
return [
'context' => $this->get_context_param( [ 'default' => 'view' ] ),
'next_page_name' => [
'description' => __( 'Indicates the next page name mapped to the redirect URL when back from Google authorization.', 'google-listings-and-ads' ),
'type' => 'string',
'default' => array_key_first( self::NEXT_PATH_MAPPING ),
'enum' => array_keys( self::NEXT_PATH_MAPPING ),
'validate_callback' => 'rest_validate_request_arg',
],
'login_hint' => [
'description' => __( 'Indicate the Google account to suggest for authorization.', 'google-listings-and-ads' ),
'type' => 'string',
'validate_callback' => 'is_email',
],
];
}
/**
* Get the callback function for the disconnection request.
*
* @return callable
*/
protected function get_disconnect_callback(): callable {
return function () {
$this->connection->disconnect();
return [
'status' => 'success',
'message' => __( 'Successfully disconnected.', 'google-listings-and-ads' ),
];
};
}
/**
* Get the callback function to determine if Google is currently connected.
*
* Uses consistent properties to the Jetpack connected callback
*
* @return callable
*/
protected function get_connected_callback(): callable {
return function () {
try {
$status = $this->connection->get_status();
return [
'active' => array_key_exists( 'status', $status ) && ( 'connected' === $status['status'] ) ? 'yes' : 'no',
'email' => array_key_exists( 'email', $status ) ? $status['email'] : '',
'scope' => array_key_exists( 'scope', $status ) ? $status['scope'] : [],
];
} catch ( Exception $e ) {
return $this->response_from_exception( $e );
}
};
}
/**
* Get the callback function to determine if we have access to the dependent services.
*
* @return callable
*/
protected function get_reconnected_callback(): callable {
return function () {
try {
$status = $this->connection->get_reconnect_status();
$status['active'] = array_key_exists( 'status', $status ) && ( 'connected' === $status['status'] ) ? 'yes' : 'no';
unset( $status['status'] );
return $status;
} catch ( Exception $e ) {
return $this->response_from_exception( $e );
}
};
}
/**
* Get the item schema for the controller.
*
* @return array
*/
protected function get_schema_properties(): array {
return [
'url' => [
'type' => 'string',
'description' => __( 'The URL for making a connection to Google.', 'google-listings-and-ads' ),
'context' => [ 'view' ],
'readonly' => true,
],
];
}
/**
* Get the item schema name for the controller.
*
* Used for building the API response schema.
*
* @return string
*/
protected function get_schema_title(): string {
return 'google_account';
}
}
wp-content/plugins/google-listings-and-ads/src/API/Site/Controllers/Jetpack/AccountController.php 0000644 00000017412 15156170113 0037177 0 ustar 00 var/www/vhosts/uyarreklam.com.tr/httpdocs <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Jetpack;
use Automattic\Jetpack\Connection\Manager;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\BaseOptionsController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\TransportMethods;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Google\Middleware;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\RESTServer;
use WP_REST_Request as Request;
use WP_REST_Response as Response;
defined( 'ABSPATH' ) || exit;
/**
* Class AccountController
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\Jetpack
*/
class AccountController extends BaseOptionsController {
/**
* @var Manager
*/
protected $manager;
/**
* @var Middleware
*/
protected $middleware;
/**
* Retain the connected state to prevent multiple external calls to validate the token.
*
* @var bool
*/
private $jetpack_connected_state;
/**
* Mapping between the client page name and its path.
* The first value is also used as a default,
* and changing the order of keys/values may affect things below.
*
* @var string[]
*/
private const NEXT_PATH_MAPPING = [
'setup-mc' => '/google/setup-mc',
'reconnect' => '/google/settings&subpath=/reconnect-wpcom-account',
];
/**
* AccountController constructor.
*
* @param RESTServer $server
* @param Manager $manager
* @param Middleware $middleware
*/
public function __construct( RESTServer $server, Manager $manager, Middleware $middleware ) {
parent::__construct( $server );
$this->manager = $manager;
$this->middleware = $middleware;
}
/**
* Register rest routes with WordPress.
*/
public function register_routes(): void {
$this->register_route(
'jetpack/connect',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_connect_callback(),
'permission_callback' => $this->get_permission_callback(),
'args' => $this->get_connect_params(),
],
[
'methods' => TransportMethods::DELETABLE,
'callback' => $this->get_disconnect_callback(),
'permission_callback' => $this->get_permission_callback(),
],
'schema' => $this->get_api_response_schema_callback(),
]
);
$this->register_route(
'jetpack/connected',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_connected_callback(),
'permission_callback' => $this->get_permission_callback(),
],
]
);
}
/**
* Get the callback function for the connection request.
*
* @return callable
*/
protected function get_connect_callback(): callable {
return function ( Request $request ) {
// Register the site to WPCOM.
if ( $this->manager->is_connected() ) {
$result = $this->manager->reconnect();
} else {
$result = $this->manager->register();
}
if ( is_wp_error( $result ) ) {
return new Response(
[
'status' => 'error',
'message' => $result->get_error_message(),
],
400
);
}
// Get an authorization URL which will redirect back to our page.
$next = $request->get_param( 'next_page_name' );
$path = self::NEXT_PATH_MAPPING[ $next ];
$redirect = admin_url( "admin.php?page=wc-admin&path={$path}" );
$auth_url = $this->manager->get_authorization_url( null, $redirect );
// Payments flow allows redirect back to the site without showing plans. Escaping the URL preventing XSS.
$auth_url = esc_url( add_query_arg( [ 'from' => 'google-listings-and-ads' ], $auth_url ), null, 'db' );
return [
'url' => $auth_url,
];
};
}
/**
* Get the query params for the connection request.
*
* @return array
*/
protected function get_connect_params(): array {
return [
'context' => $this->get_context_param( [ 'default' => 'view' ] ),
'next_page_name' => [
'description' => __( 'Indicates the next page name mapped to the redirect URL when back from Jetpack authorization.', 'google-listings-and-ads' ),
'type' => 'string',
'default' => array_key_first( self::NEXT_PATH_MAPPING ),
'enum' => array_keys( self::NEXT_PATH_MAPPING ),
'validate_callback' => 'rest_validate_request_arg',
],
];
}
/**
* Get the callback function for the disconnection request.
*
* @return callable
*/
protected function get_disconnect_callback(): callable {
return function () {
$this->manager->remove_connection();
$this->options->delete( OptionsInterface::WP_TOS_ACCEPTED );
$this->options->delete( OptionsInterface::JETPACK_CONNECTED );
return [
'status' => 'success',
'message' => __( 'Successfully disconnected.', 'google-listings-and-ads' ),
];
};
}
/**
* Get the callback function to determine if Jetpack is currently connected.
*
* @return callable
*/
protected function get_connected_callback(): callable {
return function () {
if ( $this->is_jetpack_connected() && ! $this->options->get( OptionsInterface::WP_TOS_ACCEPTED ) ) {
$this->log_wp_tos_accepted();
}
// Update connection status.
$this->options->update( OptionsInterface::JETPACK_CONNECTED, $this->is_jetpack_connected() );
$user_data = $this->get_jetpack_user_data();
return [
'active' => $this->display_boolean( $this->is_jetpack_connected() ),
'owner' => $this->display_boolean( $this->is_jetpack_connection_owner() ),
'displayName' => $user_data['display_name'] ?? '',
'email' => $user_data['email'] ?? '',
];
};
}
/**
* Determine whether Jetpack is connected.
* Check if manager is active and we have a valid token.
*
* @return bool
*/
protected function is_jetpack_connected(): bool {
if ( null !== $this->jetpack_connected_state ) {
return $this->jetpack_connected_state;
}
if ( ! $this->manager->has_connected_owner() || ! $this->manager->is_connected() ) {
$this->jetpack_connected_state = false;
return false;
}
// Send an external request to validate the token.
$this->jetpack_connected_state = $this->manager->get_tokens()->validate_blog_token();
return $this->jetpack_connected_state;
}
/**
* Determine whether user is the current Jetpack connection owner.
*
* @return bool
*/
protected function is_jetpack_connection_owner(): bool {
return $this->manager->is_connection_owner();
}
/**
* Format boolean for display.
*
* @param bool $value
*
* @return string
*/
protected function display_boolean( bool $value ): string {
return $value ? 'yes' : 'no';
}
/**
* Get the wpcom user data of the current connected user.
*
* @return array
*/
protected function get_jetpack_user_data(): array {
$user_data = $this->manager->get_connected_user_data();
// adjust for $user_data returning false
return is_array( $user_data ) ? $user_data : [];
}
/**
* Log accepted TOS for WordPress.
*/
protected function log_wp_tos_accepted() {
$user = wp_get_current_user();
$this->middleware->mark_tos_accepted( 'wp-com', $user->user_email );
$this->options->update( OptionsInterface::WP_TOS_ACCEPTED, true );
}
/**
* Get the item schema for the controller.
*
* @return array
*/
protected function get_schema_properties(): array {
return [
'url' => [
'type' => 'string',
'description' => __( 'The URL for making a connection to Jetpack (wordpress.com).', 'google-listings-and-ads' ),
'context' => [ 'view' ],
'readonly' => true,
],
];
}
/**
* Get the item schema name for the controller.
*
* Used for building the API response schema.
*
* @return string
*/
protected function get_schema_title(): string {
return 'jetpack_account';
}
}
plugins/google-listings-and-ads/src/API/Site/Controllers/MerchantCenter/AccountController.php 0000644 00000017167 15156607333 0040540 0 ustar 00 var/www/vhosts/uyarreklam.com.tr/httpdocs/wp-content <?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter;
use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\BaseController;
use Automattic\WooCommerce\GoogleListingsAndAds\API\TransportMethods;
use Automattic\WooCommerce\GoogleListingsAndAds\Exception\ApiNotReady;
use Automattic\WooCommerce\GoogleListingsAndAds\MerchantCenter\AccountService;
use Automattic\WooCommerce\GoogleListingsAndAds\Proxies\RESTServer;
use Exception;
use WP_REST_Request as Request;
use WP_REST_Response as Response;
defined( 'ABSPATH' ) || exit;
/**
* Class AccountController
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter
*/
class AccountController extends BaseController {
/**
* Service used to access / update Ads account data.
*
* @var AccountService
*/
protected $account;
/**
* AccountController constructor.
*
* @param RESTServer $server
* @param AccountService $account
*/
public function __construct( RESTServer $server, AccountService $account ) {
parent::__construct( $server );
$this->account = $account;
}
/**
* Register rest routes with WordPress.
*/
public function register_routes(): void {
$this->register_route(
'mc/accounts',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_accounts_callback(),
'permission_callback' => $this->get_permission_callback(),
],
[
'methods' => TransportMethods::CREATABLE,
'callback' => $this->setup_account_callback(),
'permission_callback' => $this->get_permission_callback(),
'args' => $this->get_schema_properties(),
],
'schema' => $this->get_api_response_schema_callback(),
]
);
$this->register_route(
'mc/accounts/claim-overwrite',
[
[
'methods' => TransportMethods::CREATABLE,
'callback' => $this->overwrite_claim_callback(),
'permission_callback' => $this->get_permission_callback(),
'args' => $this->get_schema_properties(),
],
'schema' => $this->get_api_response_schema_callback(),
]
);
$this->register_route(
'mc/accounts/switch-url',
[
[
'methods' => TransportMethods::CREATABLE,
'callback' => $this->switch_url_callback(),
'permission_callback' => $this->get_permission_callback(),
'args' => $this->get_schema_properties(),
],
'schema' => $this->get_api_response_schema_callback(),
]
);
$this->register_route(
'mc/connection',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_connected_merchant_callback(),
'permission_callback' => $this->get_permission_callback(),
],
[
'methods' => TransportMethods::DELETABLE,
'callback' => $this->disconnect_merchant_callback(),
'permission_callback' => $this->get_permission_callback(),
],
]
);
$this->register_route(
'mc/setup',
[
[
'methods' => TransportMethods::READABLE,
'callback' => $this->get_setup_merchant_callback(),
'permission_callback' => $this->get_permission_callback(),
],
]
);
}
/**
* Get the callback function for the list accounts request.
*
* @return callable
*/
protected function get_accounts_callback(): callable {
return function ( Request $request ) {
try {
return array_map(
function ( $account ) use ( $request ) {
$data = $this->prepare_item_for_response( $account, $request );
return $this->prepare_response_for_collection( $data );
},
$this->account->get_accounts()
);
} catch ( Exception $e ) {
return $this->response_from_exception( $e );
}
};
}
/**
* Get the callback for creating or linking an account, overwriting the website claim during the claim step.
*
* @return callable
*/
protected function overwrite_claim_callback(): callable {
return $this->setup_account_callback( 'overwrite_claim' );
}
/**
* Get the callback for creating or linking an account, switching the URL during the set_id step.
*
* @return callable
*/
protected function switch_url_callback(): callable {
return $this->setup_account_callback( 'switch_url' );
}
/**
* Get the callback function for creating or linking an account.
*
* @param string $action Action to call while setting up account (default is normal setup).
* @return callable
*/
protected function setup_account_callback( string $action = 'setup_account' ): callable {
return function ( Request $request ) use ( $action ) {
try {
$account_id = absint( $request['id'] );
if ( $account_id && 'setup_account' === $action ) {
$this->account->use_existing_account_id( $account_id );
}
$account = $this->account->{$action}( $account_id );
return $this->prepare_item_for_response( $account, $request );
} catch ( ApiNotReady $e ) {
return $this->get_time_to_wait_response( $e );
} catch ( Exception $e ) {
return $this->response_from_exception( $e );
}
};
}
/**
* Get the callback function for the connected merchant account.
*
* @return callable
*/
protected function get_connected_merchant_callback(): callable {
return function () {
return $this->account->get_connected_status();
};
}
/**
* Get the callback function for the merchant setup status.
*
* @return callable
*/
protected function get_setup_merchant_callback(): callable {
return function () {
return $this->account->get_setup_status();
};
}
/**
* Get the callback function for disconnecting a merchant.
*
* @return callable
*/
protected function disconnect_merchant_callback(): callable {
return function () {
$this->account->disconnect();
return [
'status' => 'success',
'message' => __( 'Merchant Center account successfully disconnected.', 'google-listings-and-ads' ),
];
};
}
/**
* Get the item schema for the controller.
*
* @return array
*/
protected function get_schema_properties(): array {
return [
'id' => [
'type' => 'number',
'description' => __( 'Merchant Center Account ID.', 'google-listings-and-ads' ),
'context' => [ 'view', 'edit' ],
'validate_callback' => 'rest_validate_request_arg',
'required' => false,
],
'subaccount' => [
'type' => 'boolean',
'description' => __( 'Is a MCA sub account.', 'google-listings-and-ads' ),
'context' => [ 'view' ],
'readonly' => true,
],
'name' => [
'type' => 'string',
'description' => __( 'The Merchant Center Account name.', 'google-listings-and-ads' ),
'context' => [ 'view' ],
'required' => false,
],
'domain' => [
'type' => 'string',
'description' => __( 'The domain registered with the Merchant Center Account.', 'google-listings-and-ads' ),
'context' => [ 'view' ],
'readonly' => true,
],
];
}
/**
* Get the item schema name for the controller.
*
* Used for building the API response schema.
*
* @return string
*/
protected function get_schema_title(): string {
return 'account';
}
/**
* Return a 503 Response with Retry-After header and message.
*
* @param ApiNotReady $wait Exception containing the time to wait.
*
* @return Response
*/
private function get_time_to_wait_response( ApiNotReady $wait ): Response {
$data = $wait->get_response_data( true );
return new Response(
$data,
$wait->getCode() ?: 503,
[
'Retry-After' => $data['retry_after'],
]
);
}
}