Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Shopify

ShopifyClient::rest_requestpublicWC 1.0

Makes a request to the Shopify REST API.

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

Хуков нет.

Возвращает

Объект|\WP_Error. Decoded JSON response object or WP_Error on failure.

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

$ShopifyClient = new ShopifyClient();
$ShopifyClient->rest_request( $path, $query_params, $method, $body );
$path(строка) (обязательный)
The API path (e.g., '/products/count.json').
$query_params(массив)
Optional query parameters.
По умолчанию: array()
$method(строка)
HTTP method (GET, POST, PUT, DELETE).
По умолчанию: 'GET'
$body(массив)
Request body for POST/PUT.
По умолчанию: array()

Код ShopifyClient::rest_request() WC 10.8.1

public function rest_request( string $path, array $query_params = array(), string $method = 'GET', array $body = array() ) {
	$credentials = $this->get_credentials();
	if ( is_wp_error( $credentials ) ) {
		return $credentials;
	}

	$rest_endpoint = $this->build_rest_url( $credentials['domain'], $path, $query_params );
	$request_args  = $this->build_request_args( $credentials['access_token'], $method, $body );

	$response = wp_remote_request( $rest_endpoint, $request_args );

	return $this->process_response( $response, $path );
}