diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8d830c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +vendor + +# IntelliJ project files +.idea +*.iml +out +gen \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1f56388 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +Все заметные изменения в этом проекте будут задокументированы в этом файле. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.0.3] - 2023-09-28 +### Исправлено +- Поддержка домена getcourse.io + +## [0.0.2] - 2023-09-28 +### Добавлено +- Поддержка домена getcourse.io + +## [0.0.1] - 2023-05-17 +### Добавлено +- Метод `setDealCurrency`, который позволяет указывать валюту заказа отличную от Российского Рубля +### Исправлено +- Название переменной в PHPDoc метода `setDateFinished` \ No newline at end of file diff --git a/README.md b/README.md index da79a16..f0e0461 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Системные требования: - * PHP 5.4+ + * PHP 8.0+ * PHP cURL extension с поддержкой SSL (обычно включена). * PHP JSON extension @@ -14,17 +14,21 @@ Если вы используете [Composer](http://getcomposer.org/), то добавьте в свой "composer.json": ``` - "repositories": [ - { - "type": "git", - "url": "https://github.com/getcourse-ru/GetCourse-PHP-SDK" - } - ], "require": { - "getcourse-ru/GetCourse-PHP-SDK": "dev-master" + "xdemonme/getcourse-php-sdk": "^0.0.2" } ``` +и запустите `composer update` для установки + +**или** + +запустите эту команду в командной строке вашего проекта: + +```shell +composer require xdemonme/getcourse-php-sdk +``` + ## Пример использования Находится в директории ```sample``` diff --git a/composer.json b/composer.json index eb51024..92da79f 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,10 @@ { - "name": "getcourse-ru/GetCourse-PHP-SDK", + "name": "xdemonme/getcourse-php-sdk", + "version": "0.0.3", "description": "GetCourse's PHP SDK for APIs", "keywords": ["getcourse", "api", "sdk"], "type": "library", - "license": "Apache2", + "license": "Apache-2.0", "homepage": "https://github.com/getcourse-ru/GetCourse-PHP-SDK", "authors": [ { @@ -12,7 +13,7 @@ } ], "require": { - "php": ">=5.4.0", + "php": ">=8.0", "ext-curl": "*", "ext-json": "*" }, diff --git a/lib/GetCourse/Deal.php b/lib/GetCourse/Deal.php index 4ec181c..e041619 100644 --- a/lib/GetCourse/Deal.php +++ b/lib/GetCourse/Deal.php @@ -27,7 +27,7 @@ public function setDealNumber($deal_number) { $this->deal['deal_number'] = $deal_number; return $this; } - + /** * Статус заказа * @param $deal_status @@ -68,11 +68,11 @@ public function setDateCreated($date_created_at) { return $this; } - /** - * Дата оплаты/завершения заказа - * @param $date_created_at - * @return $this - */ + /** + * Дата оплаты/завершения заказа + * @param $date_finished_at + * @return $this + */ public function setDateFinished($date_finished_at) { $this->deal['deal_finished_at'] = $date_finished_at; return $this; @@ -88,11 +88,22 @@ public function setDealCost($deal_cost) { return $this; } - /** - * Наименование предложения - * @param $deal_cost - * @return $this - */ + /** + * Валюта заказа + * @param $deal_currency + * @return $this + */ + public function setDealCurrency($deal_currency) + { + $this->deal['deal_currency'] = $deal_currency; + return $this; + } + + /** + * Наименование предложения + * @param $product_title + * @return $this + */ public function setProductTitle($product_title) { $this->deal['product_title'] = $product_title; return $this; @@ -179,11 +190,12 @@ public function setDealPartnerEmail($partnerEmail) { return $this; } - /** - * Вызов api - * @param $action - * @return mixed - */ + /** + * Вызов api + * @param $action + * @return mixed + * @throws \Exception + */ public function apiCall( $action ) { return $this->executeCall(self::getUrl().'deals', $action); } diff --git a/lib/GetCourse/core/Model.php b/lib/GetCourse/core/Model.php index 14c04b3..c277da5 100644 --- a/lib/GetCourse/core/Model.php +++ b/lib/GetCourse/core/Model.php @@ -37,7 +37,12 @@ public static function getUrl() { if(!self::$accountName) { throw new \Exception("Account name not supplied"); } - return 'https://' . self::$accountName . '.getcourse.ru/pl/api/'; + $account = self::$accountName; + + if (!str_contains(self::$accountName, 'getcourse.io') && !str_contains(self::$accountName, 'getcourse.ru')) { + $account .= '.getcourse.ru'; + } + return 'https://' . $account . '/pl/api/'; } /**