shoppingmallv2/app/Libraries/Adapter/API/API.php
최준흠git config git config --helpgit config --global user.name 최준흠 b4de105a7d shoppingmallv2 init...
2023-08-10 22:26:56 +09:00

47 lines
1.3 KiB
PHP

<?php
namespace App\Libraries\Adapter\API;
// 참고:https://github.com/SyntaxPhoenix/iloclient
abstract class API
{
protected $_client = null;
protected $_serverInfo = array();
protected $_accountInfo = array();
protected $_debug = false;
protected function __construct($debug = false)
{
$this->_debug = $debug;
}
abstract protected function getClient();
abstract protected function requestURL(string $url, string $method, array $datas = []): object;
final public function setServerInfo($ip, $port)
{
$this->_serverInfo['ip'] = $ip;
$this->_serverInfo['port'] = $port;
}
final protected function getServerInfo($scheme = "https://", $delimeter = ":"): string
{
return $scheme . $this->_serverInfo['ip'] . $delimeter . $this->_serverInfo['port'];
}
final public function setAccountInfo($id, $password)
{
$this->_serverInfo['id'] = $id;
$this->_serverInfo['password'] = $password;
}
final protected function getAccountInfo($authType = 'basic'): array
{
//type: basic , digest
return array($this->_serverInfo['id'], $this->_serverInfo['password'], $authType);
}
final public function get(string $url): object
{
return $this->requestURL($url, 'GET');
}
final public function post(string $url, array $datas): object
{
return $this->requestURL($url, 'POST', $datas);
}
}