403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.117.229.144
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/7779/task/7779/cwd/plugins/give/src/Framework/Http/ConnectServer/Client/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/task/7779/cwd/plugins/give/src/Framework/Http/ConnectServer/Client/ConnectClient.php
<?php

namespace Give\Framework\Http\ConnectServer\Client;

use Give\Framework\Http\ConnectServer\Client\Exceptions\RequestException;
use WP_Error;

/**
 * Class ConnectClient
 *
 * @since   2.8.0
 */
class ConnectClient
{
    /**
     * Api Url
     *
     * @since 2.8.0
     *
     * @var string
     */
    public $apiUrl;

    /**
     * @since 2.25.0
     */
    public function __construct($giveConnectUrl)
    {
        $this->apiUrl = $giveConnectUrl;
    }

    /**
     * Get rest api endpoint url for requests.
     *
     * @since 2.25.0 Set default endpoint value as empty
     * @since      2.8.0
     *
     * @param string $endpoint The route on the server. E.g: 'gateway-name/connect'
     */
    public function getApiUrl(string $endpoint = ''): string
    {
        if ( ! empty($endpoint)) {
            return trailingslashit($this->apiUrl) . ltrim($endpoint, '/');
        }

        return $this->apiUrl;
    }

    /**
     * @since 2.25.0
     *
     * @param string $endpoint The route on the server. E.g: 'gateway-name/connect'
     * @param array  $args     Optional. Can contains 'headers' and 'body'
     *
     * @throws RequestException
     */
    public function get(string $endpoint, array $args = []): array
    {
        $url = $this->getApiUrl($endpoint);

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

        $this->validateWpErrorInResponse($response);

        return $response;
    }

    /**
     * @since 2.25.0
     *
     * @param string $endpoint The route on the server. E.g: 'gateway-name/connect'
     * @param array  $args     Optional. Can contains 'headers' and 'body'
     *
     * @throws RequestException
     */
    public function post(string $endpoint, array $args = []): array
    {
        $url = $this->getApiUrl($endpoint);

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

        $this->validateWpErrorInResponse($response);

        return $response;
    }

    /**
     * @since 2.25.0
     *
     * @param string $endpoint The route on the server. E.g: 'gateway-name/connect'
     * @param array  $args     Optional. Can contains 'method', 'headers' and 'body'
     *
     * @throws RequestException
     */
    public function request(string $endpoint, array $args = []): array
    {
        $url = $this->getApiUrl($endpoint);

        $response = wp_remote_request($url, $args);

        $this->validateWpErrorInResponse($response);

        return $response;
    }

    /**
     * @since 2.25.0
     *
     * @param array|WP_Error $response
     *
     * @throws RequestException
     */
    private function validateWpErrorInResponse($response)
    {
        if (is_wp_error($response)) {
            throw new RequestException(
                esc_html__(
                    sprintf(
                        'The request to the %1$s failed. Error:  %2$s',
                        $this->apiUrl,
                        $response->get_error_message()
                    )
                )
            );
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit