You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
773 B
38 lines
773 B
<?php
|
|
|
|
namespace App\Services\Api;
|
|
|
|
use Illuminate\Http\Client\Response;
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class BaseApiService
|
|
{
|
|
protected string $hostUrl;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->hostUrl = env('SYS_URL', '');
|
|
}
|
|
|
|
/**
|
|
* @param string $url
|
|
* @param array $query
|
|
* @return Response
|
|
*/
|
|
public function getHttp(string $url, array $query = []): Response
|
|
{
|
|
$getUrl = $this->hostUrl . $url;
|
|
return Http::get($getUrl, $query);
|
|
}
|
|
|
|
/**
|
|
* @param string $url
|
|
* @param array $data
|
|
* @return Response
|
|
*/
|
|
public function putHttp(string $url, array $data): Response
|
|
{
|
|
$getUrl = $this->hostUrl . $url;
|
|
return Http::put($getUrl, $data);
|
|
}
|
|
}
|
|
|