mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
coding standards for api client
This commit is contained in:
parent
f5bb4048cd
commit
804bf35bbe
157 changed files with 8405 additions and 5283 deletions
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
/**
|
||||
* The RequestTrait wraps the wp_remote_get functionality for the API client.
|
||||
*
|
||||
* @package Inpsyde\PayPalCommerce\ApiClient\Endpoint
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\ApiClient\Endpoint;
|
||||
|
||||
/**
|
||||
* Trait RequestTrait
|
||||
*/
|
||||
trait RequestTrait {
|
||||
|
||||
/**
|
||||
* Performs a request
|
||||
*
|
||||
* @param string $url The URL to request.
|
||||
* @param array $args The arguments by which to request.
|
||||
*
|
||||
* @return array|\WP_Error
|
||||
*/
|
||||
private function request( string $url, array $args ) {
|
||||
|
||||
/**
|
||||
* This filter can be used to alter the request args.
|
||||
* For example, during testing, the PayPal-Mock-Response header could be
|
||||
* added here.
|
||||
*/
|
||||
$args = apply_filters( 'ppcp_request_args', $args, $url );
|
||||
if ( ! isset( $args['headers']['PayPal-Partner-Attribution-Id'] ) ) {
|
||||
$args['headers']['PayPal-Partner-Attribution-Id'] = 'Woo_PPCP';
|
||||
}
|
||||
|
||||
return wp_remote_get( $url, $args );
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue