PluginProbe ʕ •ᴥ•ʔ
Hostinger Reach – AI-Powered Email Marketing for WordPress / 1.7.1
Hostinger Reach – AI-Powered Email Marketing for WordPress v1.7.1
1.7.2 1.7.1 1.7.0 1.6.0 1.5.9 1.5.8 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 trunk 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6
hostinger-reach / vendor / hostinger / hostinger-wp-helper / src / Requests / Client.php
hostinger-reach / vendor / hostinger / hostinger-wp-helper / src / Requests Last commit date
Client.php 1 month ago
Client.php
71 lines
1 <?php
2
3 namespace Hostinger\WpHelper\Requests;
4
5 defined('ABSPATH') || exit;
6
7 class Client
8 {
9 private string $api_url;
10 private array $default_headers;
11
12 public function __construct($api_url, $default_headers = array())
13 {
14 $this->api_url = $api_url;
15 $this->default_headers = $default_headers;
16 }
17
18 public function get_api_url(): string
19 {
20 return $this->api_url;
21 }
22
23 public function set_api_url(string $api_url): void
24 {
25 $this->api_url = $api_url;
26 }
27
28 public function get_default_headers(): array
29 {
30 return $this->default_headers;
31 }
32
33 public function set_default_headers(array $default_headers): void
34 {
35 $this->default_headers = $default_headers;
36 }
37
38 public function get($endpoint, $params = array(), $headers = array(), $timeout = 120)
39 {
40 $url = $this->api_url . $endpoint;
41 $request_args = array(
42 'method' => 'GET',
43 'headers' => array_merge($this->default_headers, $headers),
44 'timeout' => $timeout,
45 );
46
47 if (! empty($params)) {
48 $url = add_query_arg($params, $url);
49 }
50
51 $response = wp_remote_get($url, $request_args);
52
53 return $response;
54 }
55
56 public function post($endpoint, $params = array(), $headers = array(), $timeout = 120)
57 {
58 $url = $this->api_url . $endpoint;
59 $request_args = array(
60 'method' => 'POST',
61 'timeout' => $timeout,
62 'headers' => array_merge($this->default_headers, $headers),
63 'body' => $params,
64 );
65
66 $response = wp_remote_post($url, $request_args);
67
68 return $response;
69 }
70 }
71