Files
cycle_api/sdk/Wallet/Http.php
2024-03-25 06:15:36 +08:00

34 lines
711 B
PHP

<?php
namespace Sdk\Wallet;
use GuzzleHttp\Client;
class Http
{
protected Client $httpClient;
function __construct($client)
{
$this->httpClient = $client;
}
function getClient()
{
return $this->httpClient;
}
function get(string $endpoint, array $data = [])
{
$stream = (string)$this->getClient()->get($endpoint, ['query' => $data])->getBody();
$body = json_decode($stream, false);
return $body;
}
function post(string $endpoint, array $data = [])
{
$stream = (string)$this->getClient()->post($endpoint, ['json' => $data])->getBody();
$body = json_decode($stream, false);
return $body;
}
}