From 534f17c4fcc83556cca35f54af6c3522ab7a0384 Mon Sep 17 00:00:00 2001 From: winclain Date: Mon, 23 Oct 2023 13:49:09 +0300 Subject: [PATCH] first commit --- composer.json | 4 +-- src/ApiClient.php | 38 +------------------------- src/Sms.php | 42 +++++++++++++++++++++++++++++ src/SourcePrice.php | 66 --------------------------------------------- src/Statistic.php | 53 ------------------------------------ 5 files changed, 45 insertions(+), 158 deletions(-) create mode 100644 src/Sms.php delete mode 100644 src/SourcePrice.php delete mode 100644 src/Statistic.php diff --git a/composer.json b/composer.json index 05baee2..8d9cc96 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "sempico/sempico-php", - "description": "Api library to interact with Sempico Solutions REST Api", + "name": "sempico/api-sms-php", + "description": "Api library to interact with Sempico Solutions Api", "type": "library", "version": "1.0.0", "minimum-stability": "stable", diff --git a/src/ApiClient.php b/src/ApiClient.php index 1a1aa0a..e09db64 100644 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -4,41 +4,11 @@ class ApiClient { - /** - * api token - * @var string - */ - private string $token; - /** * domain * @var string */ - private string $domain; - - public function __construct(string $token, string $domain) - { - $this->token = $token; - $this->domain = $domain; - } - - /** - * Get api token - * @return string - */ - public function getToken(): string - { - return $this->token; - } - - /** - * Get api domain - * @return string - */ - public function getDomain(): string - { - return $this->domain; - } + private string $domain = 'https://api.sempico.solutions/'; /** * Make curl request @@ -52,12 +22,6 @@ public function curlRequest(string $url, string|bool $customMethod, array $data) $output = []; $ch = curl_init(); - // Header - curl_setopt($ch, CURLOPT_HTTPHEADER, [ - 'Content-Type: application/json', - 'x-access-token: '. $this->token - ]); - // Url curl_setopt($ch, CURLOPT_URL, $this->domain . $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); diff --git a/src/Sms.php b/src/Sms.php new file mode 100644 index 0000000..bb7e724 --- /dev/null +++ b/src/Sms.php @@ -0,0 +1,42 @@ +client = $client; + } + + /** + * Get all source prices + * @param array $config + * @return array + */ + public function send(array $config) + { + $route = 'v1/send'.http_build_query($config); + + return $this->client->curlRequest($route, false, []); + } + + /** + * Refactor sms data + * @param int $id + * @param array $config + * @return array + */ + public function refactore(array $config) + { + $route = 'v1/replacement?'.http_build_query($config); + + return $this->client->curlRequest($route, false, []); + } +} \ No newline at end of file diff --git a/src/SourcePrice.php b/src/SourcePrice.php deleted file mode 100644 index dc1a392..0000000 --- a/src/SourcePrice.php +++ /dev/null @@ -1,66 +0,0 @@ -client = $client; - } - - /** - * Get all source prices - * @param array $config - * @return array - */ - public function getAll(array $config) - { - $route = 'v1/source-price/view-all'; - - return $this->client->curlRequest($route, 'POST', $config); - } - - /** - * Update source price - * @param int $id - * @param array $config - * @return array - */ - public function update(int $id, array $config) - { - $route = 'v1/source-price/update?id='. $id; - - return $this->client->curlRequest($route, 'PUT', $config); - } - - /** - * Create source price - * @param array $config - * @return array - */ - public function create(array $config) - { - $route = 'v1/source-price/create'; - - return $this->client->curlRequest($route, 'POST', $config); - } - - /** - * Delete source price - * @param int $id - * @return array - */ - public function delete(int $id) - { - $route = 'v1/source-price/delete?='.$id; - - return $this->client->curlRequest($route, 'DELETE', []); - } -} \ No newline at end of file diff --git a/src/Statistic.php b/src/Statistic.php deleted file mode 100644 index 9fb297d..0000000 --- a/src/Statistic.php +++ /dev/null @@ -1,53 +0,0 @@ -client = $client; - } - - /** - * Quick search - * @param array $config - * @return array - */ - public function quickSearch(array $config) - { - $route = 'v1/statistic/quick'; - - return $this->client->curlRequest($route, 'POST', $config); - } - - /** - * Sms full data - * @param array $config - * @return array - */ - public function smsFullData(array $config) - { - $route = 'v1/statistic/sms-full-data'; - - return $this->client->curlRequest($route, 'POST', $config); - } - - /** - * General search - * @param array $config - * @return array - */ - public function general(array $config) - { - $route = 'v1/statistic/general'; - - return $this->client->curlRequest($route, 'POST', $config); - } -} \ No newline at end of file