WC_Helper_API::request( string $endpoint, array $args = array() )
Perform an HTTP request to the Helper API.
Description Description
Parameters Parameters
- $endpoint
-
(Required) The endpoint to request.
- $args
-
(Optional) Additional data for the request. Set authenticated to a truthy value to enable auth.
Default value: array()
Return Return
(array|WP_Error) The response from wp_safe_remote_request()
Source Source
File: includes/admin/helper/class-wc-helper-api.php
public static function request( $endpoint, $args = array() ) {
$url = self::url( $endpoint );
if ( ! empty( $args['authenticated'] ) ) {
if ( ! self::_authenticate( $url, $args ) ) {
return new WP_Error( 'authentication', 'Authentication failed.' );
}
}
/**
* Allow developers to filter the request args passed to wp_safe_remote_request().
* Useful to remove sslverify when working on a local api dev environment.
*/
$args = apply_filters( 'woocommerce_helper_api_request_args', $args, $endpoint );
// TODO: Check response signatures on certain endpoints.
return wp_safe_remote_request( $url, $args );
}