# hostinger/2.1.9/includes/Requests/Client.php

Hostinger Tools, version 2.1.9. 47 lines.

- Page: https://pluginprobe.com/plugins/hostinger/2.1.9/code/includes/Requests/Client.php
- Raw: https://pluginprobe.com/plugins/hostinger/2.1.9/raw/includes/Requests/Client.php
- Modified: 2024-03-15T08:53:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/hostinger/2.1.9/code/includes/Requests/Client.php#L10-L20`.

```php
<?php

namespace Hostinger\Requests;

defined( 'ABSPATH' ) || exit;

class Client {
	private string $api_url;
	private array $default_headers;

	public function __construct( $api_url, $default_headers = array() ) {
		$this->api_url         = $api_url;
		$this->default_headers = $default_headers;
	}

	public function get( $endpoint, $params = array(), $headers = array(), $timeout = 120 ) {
		$url          = $this->api_url . $endpoint;
		$request_args = array(
			'method'  => 'GET',
			'headers' => array_merge( $this->default_headers, $headers ),
			'timeout' => $timeout,
		);

		if ( ! empty( $params ) ) {
			$url = add_query_arg( $params, $url );
		}

		$response = wp_remote_get( $url, $request_args );

		return $response;
	}

	public function post( $endpoint, $params = array(), $headers = array(), $timeout = 120 ) {
		$url          = $this->api_url . $endpoint;
		$request_args = array(
			'method'  => 'POST',
			'timeout' => $timeout,
			'headers' => array_merge( $this->default_headers, $headers ),
			'body'    => $params,
		);

		$response = wp_remote_post( $url, $request_args );

		return $response;
	}
}

```
