![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/job-board.corals.io/Corals/modules/Woo/Integration/Http/ |
<?php /** * WooCommerce REST API Client * * @category Client * @package Automattic/WooCommerce */ namespace Corals\Modules\Woo\Integration\Http; use Corals\Modules\Woo\Integration\Http\HttpClient\HttpClient; /** * REST API Client class. * * @package Automattic/WooCommerce */ class Client { /** * WooCommerce REST API Client version. */ const VERSION = '3.0.0'; /** * HttpClient instance. * * @var HttpClient */ public $http; /** * Initialize client. * * @param string $url Store URL. * @param string $consumerKey Consumer key. * @param string $consumerSecret Consumer secret. * @param array $options Options (version, timeout, verify_ssl). */ public function __construct($url, $consumerKey, $consumerSecret, $options = []) { $this->http = new HttpClient($url, $consumerKey, $consumerSecret, $options); } /** * POST method. * * @param string $endpoint API endpoint. * @param array $data Request data. * * @return array */ public function post($endpoint, $data) { return $this->http->request($endpoint, 'POST', $data); } /** * PUT method. * * @param string $endpoint API endpoint. * @param array $data Request data. * * @return array */ public function put($endpoint, $data) { return $this->http->request($endpoint, 'PUT', $data); } /** * GET method. * * @param string $endpoint API endpoint. * @param array $parameters Request parameters. * * @return array */ public function get($endpoint, $parameters = []) { $parameters = array_merge(['lang' => 'en'], $parameters); return $this->http->request($endpoint, 'GET', [], $parameters); } /** * DELETE method. * * @param string $endpoint API endpoint. * @param array $parameters Request parameters. * * @return array */ public function delete($endpoint, $parameters = []) { return $this->http->request($endpoint, 'DELETE', [], $parameters); } /** * OPTIONS method. * * @param string $endpoint API endpoint. * * @return array */ public function options($endpoint) { return $this->http->request($endpoint, 'OPTIONS', [], []); } }