Automattic\WooCommerce\Internal\CLI\Migrator\Platforms\Shopify
ShopifyClient::rest_request
Makes a request to the Shopify REST API.
Method of the class: ShopifyClient{}
No Hooks.
Returns
Object|\WP_Error. Decoded JSON response object or WP_Error on failure.
Usage
$ShopifyClient = new ShopifyClient(); $ShopifyClient->rest_request( $path, $query_params, $method, $body );
- $path(string) (required)
- The API path (e.g., '/products/count.json').
- $query_params(array)
- Optional query parameters.
Default:array() - $method(string)
- HTTP method (GET, POST, PUT, DELETE).
Default:'GET' - $body(array)
- Request body for POST/PUT.
Default:array()
ShopifyClient::rest_request() ShopifyClient::rest request code WC 10.7.0
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 );
}