1
0
mirror of synced 2024-11-22 13:26:08 +03:00
api-client-php/lib/RetailCrm/ApiClient.php

77 lines
1.7 KiB
PHP
Raw Normal View History

<?php
2016-03-09 02:31:29 +03:00
/**
* PHP version 5.4
*
* API client class
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
namespace RetailCrm;
use RetailCrm\Client\ApiVersion3;
use RetailCrm\Client\ApiVersion4;
use RetailCrm\Client\ApiVersion5;
/**
* PHP version 5.4
2016-03-09 02:31:29 +03:00
*
* API client class
*
* @category RetailCrm
* @package RetailCrm
* @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
*/
class ApiClient
{
public $request;
public $version;
2016-01-09 15:23:50 +03:00
2017-06-22 16:42:42 +03:00
const V3 = 'v3';
const V4 = 'v4';
const V5 = 'v5';
2016-01-09 15:23:50 +03:00
/**
* Init version based client
2016-01-09 15:23:50 +03:00
*
* @param string $url api url
* @param string $apiKey api key
* @param string $version api version
* @param string $site site code
2016-03-09 02:31:29 +03:00
*
2016-01-09 15:23:50 +03:00
*/
2017-06-22 16:42:42 +03:00
public function __construct($url, $apiKey, $version = self::V5, $site = null)
2016-01-09 15:23:50 +03:00
{
$this->version = $version;
2016-01-09 15:23:50 +03:00
switch ($version) {
2017-06-22 16:42:42 +03:00
case self::V5:
$this->request = new ApiVersion5($url, $apiKey, $version, $site);
break;
2017-06-22 16:42:42 +03:00
case self::V4:
$this->request = new ApiVersion4($url, $apiKey, $version, $site);
break;
2017-06-22 16:42:42 +03:00
case self::V3:
$this->request = new ApiVersion3($url, $apiKey, $version, $site);
break;
}
}
/**
* Get API version
*
* @return string
*/
public function getVersion()
{
return $this->version;
}
}