| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Services; |
| 4 |
|
| 5 |
use SyncBasalam\Services\Api\PostApiService; |
| 6 |
use SyncBasalam\Services\Api\GetApiService; |
| 7 |
use SyncBasalam\Services\Api\PatchApiService; |
| 8 |
use SyncBasalam\Services\Api\PutApiService; |
| 9 |
use SyncBasalam\Services\Api\DeleteApiService; |
| 10 |
use SyncBasalam\Services\Api\FileUploadApiService; |
| 11 |
|
| 12 |
defined('ABSPATH') || exit; |
| 13 |
|
| 14 |
class ApiServiceManager |
| 15 |
{ |
| 16 |
private $postService = null; |
| 17 |
private $getService = null; |
| 18 |
private $patchService = null; |
| 19 |
private $putService = null; |
| 20 |
private $deleteService = null; |
| 21 |
private $fileUploadService = null; |
| 22 |
|
| 23 |
public function post($url, $data, $headers = []) |
| 24 |
{ |
| 25 |
if ($this->postService === null) $this->postService = new PostApiService(); |
| 26 |
return $this->postService->send($url, $data, $headers); |
| 27 |
} |
| 28 |
|
| 29 |
public function get($url, $headers = []) |
| 30 |
{ |
| 31 |
if ($this->getService === null) $this->getService = new GetApiService(); |
| 32 |
return $this->getService->send($url, $headers); |
| 33 |
} |
| 34 |
|
| 35 |
public function patch($url, $data, $headers = []) |
| 36 |
{ |
| 37 |
if ($this->patchService === null) $this->patchService = new PatchApiService(); |
| 38 |
return $this->patchService->send($url, $data, $headers); |
| 39 |
} |
| 40 |
|
| 41 |
public function put($url, $data, $headers = []) |
| 42 |
{ |
| 43 |
if ($this->putService === null) $this->putService = new PutApiService(); |
| 44 |
return $this->putService->send($url, $data, $headers); |
| 45 |
} |
| 46 |
|
| 47 |
public function delete($url, $headers = [], $data = null) |
| 48 |
{ |
| 49 |
if ($this->deleteService === null) $this->deleteService = new DeleteApiService(); |
| 50 |
return $this->deleteService->send($url, $headers, (array) $data); |
| 51 |
} |
| 52 |
|
| 53 |
public function upload($url, $localFile, $data = [], $headers = [], $options = []) |
| 54 |
{ |
| 55 |
if ($this->fileUploadService === null) $this->fileUploadService = new FileUploadApiService(); |
| 56 |
return $this->fileUploadService->upload($url, $localFile, $data, $headers, $options); |
| 57 |
} |
| 58 |
} |
| 59 |
|