Versions constants and fix composer instruction
This commit is contained in:
parent
a18767bddc
commit
845905a5f0
3 changed files with 12 additions and 8 deletions
|
@ -15,7 +15,7 @@ Use [API documentation](http://retailcrm.github.io/api-client-php)
|
|||
|
||||
2) Run into your project directory:
|
||||
```bash
|
||||
composer require retailcrm/api-client-php 5.* --no-dev
|
||||
composer require retailcrm/api-client-php ~5.0
|
||||
```
|
||||
|
||||
If you have not used `composer` before, include autoloader into your project.
|
||||
|
|
|
@ -15,7 +15,7 @@ PHP-клиент для работы с [retailCRM API](http://www.retailcrm.ru/
|
|||
|
||||
2) Выполните в папке проекта:
|
||||
```bash
|
||||
composer require retailcrm/api-client-php 5.* --no-dev
|
||||
composer require retailcrm/api-client-php ~5.0
|
||||
```
|
||||
|
||||
В конфиг `composer.json` вашего проекта будет добавлена библиотека `retailcrm/api-client-php`, которая установится в папку `vendor/`. При отсутствии файла конфига или папки с вендорами они будут созданы.
|
||||
|
@ -32,7 +32,7 @@ require 'path/to/vendor/autoload.php';
|
|||
$client = new \RetailCrm\ApiClient(
|
||||
'https://demo.retailcrm.ru',
|
||||
'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH',
|
||||
'v5'
|
||||
\RetailCrm\ApiClient::V5
|
||||
);
|
||||
|
||||
try {
|
||||
|
@ -67,7 +67,7 @@ if ($response->isSuccessful()) {
|
|||
$client = new \RetailCrm\ApiClient(
|
||||
'https://demo.retailcrm.ru',
|
||||
'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH',
|
||||
'v4'
|
||||
\RetailCrm\ApiClient::V4
|
||||
);
|
||||
|
||||
try {
|
||||
|
|
|
@ -34,6 +34,10 @@ class ApiClient
|
|||
public $request;
|
||||
public $version;
|
||||
|
||||
const V3 = 'v3';
|
||||
const V4 = 'v4';
|
||||
const V5 = 'v5';
|
||||
|
||||
/**
|
||||
* Init version based client
|
||||
*
|
||||
|
@ -43,18 +47,18 @@ class ApiClient
|
|||
* @param string $site site code
|
||||
*
|
||||
*/
|
||||
public function __construct($url, $apiKey, $version = 'v5', $site = null)
|
||||
public function __construct($url, $apiKey, $version = self::V5, $site = null)
|
||||
{
|
||||
$this->version = $version;
|
||||
|
||||
switch ($version) {
|
||||
case 'v5':
|
||||
case self::V5:
|
||||
$this->request = new ApiVersion5($url, $apiKey, $version, $site);
|
||||
break;
|
||||
case 'v4':
|
||||
case self::V4:
|
||||
$this->request = new ApiVersion4($url, $apiKey, $version, $site);
|
||||
break;
|
||||
case 'v3':
|
||||
case self::V3:
|
||||
$this->request = new ApiVersion3($url, $apiKey, $version, $site);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue