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

ShopifyClient::build_request_argsprivateWC 1.0

Build the request arguments.

Method of the class: ShopifyClient{}

No Hooks.

Returns

Array. Request arguments for wp_remote_request.

Usage

// private - for code of main (parent) class only
$result = $this->build_request_args( $access_token, $method, $body ): array;
$access_token(string) (required)
The Shopify access token.
$method(string) (required)
HTTP method.
$body(array) (required)
Request body.

ShopifyClient::build_request_args() code WC 10.8.1

private function build_request_args( string $access_token, string $method, array $body ): array {
	$request_args = array(
		'method'  => $method,
		'headers' => array(
			'Content-Type'           => 'application/json',
			'X-Shopify-Access-Token' => $access_token,
		),
		'timeout' => 60,
	);

	if ( ! empty( $body ) && ( 'POST' === $method || 'PUT' === $method ) ) {
		$request_args['body'] = wp_json_encode( $body );
	}

	return $request_args;
}