HEX
Server: Apache
System: Linux hz.vslconceptsdomains.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: dkfounda (3233)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/local/mailchannels/clients/AWS/AwsApiImpl.php
<?php

namespace AWS;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ConnectException;
use MailChannels\App;

class AwsApiImpl implements AwsApi
{
    private $client;
    private $logger;

    public function __construct($baseUri, Client $client=null) {
        if(!$client) {
            $client = new Client([
                'base_uri'=>$baseUri,
                'verify' => APP::verifySSL()
            ]);
        }
        $this->client = $client;

        $this->logger = \MailChannels\App::getLogger();
    }


    public function getLatestVersion() {
        $response =  $this->call("GET", "plugins/mailchannels-cpanel3-latest-version.txt");
        return $response->getBody()->getContents();
    }

    public function getInstallScript()
    {
        $installer = $this->call("GET", "plugins/mailchannels-cpanel-v3-installer");
        return $installer->getBody()->getContents();
    }

    private function call($method, $uri, $options=[]) {
        try {
            $this->logger->debug("[MailChannels AWS API] request - method: $method, URI: $uri; options: " . json_encode($options));

            return $this->client->request($method, $uri, $options);
        } catch (ClientException $e) {
            $this->logger->debug("[MailChannels AWS API] exception - method: $method URI: $uri; options: " . json_encode($options));
            $this->logger->debug($e);

            throw $e;
        } catch (ConnectException $e) {
            throw new InboundApiConnectException("Couldn't connect to AWS", $e->getCode(), $e);
        }
    }
}