models for request serialization, tests placeholder, psr-4 autoload
This commit is contained in:
parent
d83c741437
commit
e13edca8c5
31 changed files with 1753 additions and 394 deletions
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2018-2019 retailCRM
|
||||
Copyright (c) 2018-2019 RetailDriver LLC
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
19
Makefile
Normal file
19
Makefile
Normal file
|
@ -0,0 +1,19 @@
|
|||
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
SRC_DIR=$(ROOT_DIR)/src
|
||||
BIN_DIR=$(ROOT_DIR)/bin
|
||||
|
||||
deps:
|
||||
@echo "==> Installing dependencies"
|
||||
@curl -L https://getcomposer.org/composer.phar -o $(BIN_DIR)/composer
|
||||
@COMPOSER_HOME=/tmp php -d memory_limit=-1 $(BIN_DIR)/composer install
|
||||
|
||||
test:
|
||||
@echo "==> Running tests"
|
||||
@cd $(ROOT_DIR)
|
||||
@php -d memory_limit=-1 $(BIN_DIR)/phpunit -c phpunit.xml.dist --log-junit test-report.xml
|
||||
@echo "==> Testing complete"
|
||||
|
||||
stan:
|
||||
@echo "==> Running analysis"
|
||||
@php $(BIN_DIR)/phpstan analyse -l 4 -c $(ROOT_DIR)/phpstan.neon $(SRC_DIR)
|
||||
@echo "==> Analysis complete"
|
|
@ -14,20 +14,23 @@
|
|||
"require": {
|
||||
"php": ">=7.0",
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*"
|
||||
"ext-json": "*",
|
||||
"jms/serializer": "1.13.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "6.5.*",
|
||||
"phpmd/phpmd": "2.6.*",
|
||||
"phpstan/phpstan": "0.9.*",
|
||||
"squizlabs/php_codesniffer": "3.4.*",
|
||||
"jms/serializer": "1.13.*"
|
||||
"squizlabs/php_codesniffer": "3.4.*"
|
||||
},
|
||||
"support": {
|
||||
"email": "support@retailcrm.ru"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "RetailCrm\\": "src/" }
|
||||
"psr-4": {
|
||||
"RetailCrm\\Mg\\": ["src/", "tests/"],
|
||||
"RetailCrm\\Common\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
|
|
339
composer.lock
generated
339
composer.lock
generated
|
@ -4,9 +4,8 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "7b91891440be4562c063184a1263059b",
|
||||
"packages": [],
|
||||
"packages-dev": [
|
||||
"content-hash": "ee133cf54adab9dae874b4b6f54bca9b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
"version": "v1.6.1",
|
||||
|
@ -185,57 +184,6 @@
|
|||
],
|
||||
"time": "2014-09-09T13:34:57+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jean85/pretty-package-versions",
|
||||
"version": "1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Jean85/pretty-package-versions.git",
|
||||
"reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48",
|
||||
"reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ocramius/package-versions": "^1.2.0",
|
||||
"php": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Jean85\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alessandro Lai",
|
||||
"email": "alessandro.lai85@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A wrapper for ocramius/package-versions to get pretty versions strings",
|
||||
"keywords": [
|
||||
"composer",
|
||||
"package",
|
||||
"release",
|
||||
"versions"
|
||||
],
|
||||
"time": "2018-06-13T13:22:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jms/metadata",
|
||||
"version": "1.7.0",
|
||||
|
@ -410,6 +358,157 @@
|
|||
],
|
||||
"time": "2018-07-25T13:58:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpcollection/phpcollection",
|
||||
"version": "0.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/schmittjoh/php-collection.git",
|
||||
"reference": "f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/schmittjoh/php-collection/zipball/f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6",
|
||||
"reference": "f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"phpoption/phpoption": "1.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PhpCollection": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache2"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Johannes M. Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "General-Purpose Collection Library for PHP",
|
||||
"keywords": [
|
||||
"collection",
|
||||
"list",
|
||||
"map",
|
||||
"sequence",
|
||||
"set"
|
||||
],
|
||||
"time": "2015-05-17T12:39:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/schmittjoh/php-option.git",
|
||||
"reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/94e644f7d2051a5f0fcf77d81605f152eecff0ed",
|
||||
"reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.7.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PhpOption\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache2"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Johannes M. Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Option Type for PHP",
|
||||
"keywords": [
|
||||
"language",
|
||||
"option",
|
||||
"php",
|
||||
"type"
|
||||
],
|
||||
"time": "2015-07-25T16:39:46+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "jean85/pretty-package-versions",
|
||||
"version": "1.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Jean85/pretty-package-versions.git",
|
||||
"reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/75c7effcf3f77501d0e0caa75111aff4daa0dd48",
|
||||
"reference": "75c7effcf3f77501d0e0caa75111aff4daa0dd48",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ocramius/package-versions": "^1.2.0",
|
||||
"php": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^6.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Jean85\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Alessandro Lai",
|
||||
"email": "alessandro.lai85@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "A wrapper for ocramius/package-versions to get pretty versions strings",
|
||||
"keywords": [
|
||||
"composer",
|
||||
"package",
|
||||
"release",
|
||||
"versions"
|
||||
],
|
||||
"time": "2018-06-13T13:22:40+00:00"
|
||||
},
|
||||
{
|
||||
"name": "myclabs/deep-copy",
|
||||
"version": "1.8.1",
|
||||
|
@ -1175,54 +1274,6 @@
|
|||
"description": "Library for handling version information and constraints",
|
||||
"time": "2017-03-05T17:38:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpcollection/phpcollection",
|
||||
"version": "0.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/schmittjoh/php-collection.git",
|
||||
"reference": "f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/schmittjoh/php-collection/zipball/f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6",
|
||||
"reference": "f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"phpoption/phpoption": "1.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PhpCollection": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache2"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Johannes M. Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "General-Purpose Collection Library for PHP",
|
||||
"keywords": [
|
||||
"collection",
|
||||
"list",
|
||||
"map",
|
||||
"sequence",
|
||||
"set"
|
||||
],
|
||||
"time": "2015-05-17T12:39:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "1.0.1",
|
||||
|
@ -1441,56 +1492,6 @@
|
|||
],
|
||||
"time": "2017-01-20T14:41:10+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpoption/phpoption",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/schmittjoh/php-option.git",
|
||||
"reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/schmittjoh/php-option/zipball/94e644f7d2051a5f0fcf77d81605f152eecff0ed",
|
||||
"reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.7.*"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"PhpOption\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache2"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Johannes M. Schmitt",
|
||||
"email": "schmittjoh@gmail.com"
|
||||
}
|
||||
],
|
||||
"description": "Option Type for PHP",
|
||||
"keywords": [
|
||||
"language",
|
||||
"option",
|
||||
"php",
|
||||
"type"
|
||||
],
|
||||
"time": "2015-07-25T16:39:46+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "1.8.0",
|
||||
|
@ -2716,16 +2717,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/config",
|
||||
"version": "v4.2.4",
|
||||
"version": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/config.git",
|
||||
"reference": "7f70d79c7a24a94f8e98abb988049403a53d7b31"
|
||||
"reference": "0e745ead307d5dcd4e163e94a47ec04b1428943f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/config/zipball/7f70d79c7a24a94f8e98abb988049403a53d7b31",
|
||||
"reference": "7f70d79c7a24a94f8e98abb988049403a53d7b31",
|
||||
"url": "https://api.github.com/repos/symfony/config/zipball/0e745ead307d5dcd4e163e94a47ec04b1428943f",
|
||||
"reference": "0e745ead307d5dcd4e163e94a47ec04b1428943f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2775,20 +2776,20 @@
|
|||
],
|
||||
"description": "Symfony Config Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2019-02-23T15:17:42+00:00"
|
||||
"time": "2019-04-01T14:03:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v4.2.4",
|
||||
"version": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/console.git",
|
||||
"reference": "9dc2299a016497f9ee620be94524e6c0af0280a9"
|
||||
"reference": "24206aff3efe6962593297e57ef697ebb220e384"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/9dc2299a016497f9ee620be94524e6c0af0280a9",
|
||||
"reference": "9dc2299a016497f9ee620be94524e6c0af0280a9",
|
||||
"url": "https://api.github.com/repos/symfony/console/zipball/24206aff3efe6962593297e57ef697ebb220e384",
|
||||
"reference": "24206aff3efe6962593297e57ef697ebb220e384",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2847,7 +2848,7 @@
|
|||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2019-02-23T15:17:42+00:00"
|
||||
"time": "2019-04-01T07:32:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/contracts",
|
||||
|
@ -2919,16 +2920,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/dependency-injection",
|
||||
"version": "v4.2.4",
|
||||
"version": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/dependency-injection.git",
|
||||
"reference": "cdadb3765df7c89ac93628743913b92bb91f1704"
|
||||
"reference": "1806e43ff6bff57398d33b326cd753a12d9f434f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/cdadb3765df7c89ac93628743913b92bb91f1704",
|
||||
"reference": "cdadb3765df7c89ac93628743913b92bb91f1704",
|
||||
"url": "https://api.github.com/repos/symfony/dependency-injection/zipball/1806e43ff6bff57398d33b326cd753a12d9f434f",
|
||||
"reference": "1806e43ff6bff57398d33b326cd753a12d9f434f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2988,11 +2989,11 @@
|
|||
],
|
||||
"description": "Symfony DependencyInjection Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2019-02-23T15:17:42+00:00"
|
||||
"time": "2019-03-30T15:58:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v4.2.4",
|
||||
"version": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/filesystem.git",
|
||||
|
@ -3042,7 +3043,7 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
"version": "v4.2.4",
|
||||
"version": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/finder.git",
|
||||
|
|
3
phpstan.neon
Normal file
3
phpstan.neon
Normal file
|
@ -0,0 +1,3 @@
|
|||
parameters:
|
||||
autoload_files:
|
||||
- %currentWorkingDirectory%/vendor/autoload.php
|
199
src/Bot/Client.php
Normal file
199
src/Bot/Client.php
Normal file
|
@ -0,0 +1,199 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Client
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot;
|
||||
|
||||
use RetailCrm\Common\Exception\CurlException;
|
||||
use RetailCrm\Common\Exception\InvalidJsonException;
|
||||
use RetailCrm\Mg\Bot\Model;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Client class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Client
|
||||
{
|
||||
const VERSION = 'v1';
|
||||
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @param string $url api url
|
||||
* @param string $token api key
|
||||
* @param bool $debug debug flag
|
||||
*/
|
||||
public function __construct($url, $token, $debug = false)
|
||||
{
|
||||
$url = sprintf("%sapi/bot/%s", Request::normalizeUrl($url), self::VERSION);
|
||||
$this->client = new Request($url, $token, $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered bots list
|
||||
*
|
||||
* @param Model\Request\BotsRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function bots(Model\Request\BotsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/bots', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered channels list
|
||||
*
|
||||
* @param Model\Request\ChannelsRequest $request
|
||||
*
|
||||
* @return Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function channels(Model\Request\ChannelsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/channels', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered chats list
|
||||
*
|
||||
* @param Model\Request\ChatsRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function chats(Model\Request\ChatsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/chats', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered commands list
|
||||
*
|
||||
* @param Model\Request\CommandsRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function commands(Model\Request\CommandsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/my/commands', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered customers list
|
||||
*
|
||||
* @param Model\Request\CustomersRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function customers(Model\Request\CustomersRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/customers', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered dialogs list
|
||||
*
|
||||
* @param Model\Request\DialogsRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function dialogs(Model\Request\DialogsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/dialogs', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered members list
|
||||
*
|
||||
* @param Model\Request\MembersRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function members(Model\Request\MembersRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/members', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered messages list
|
||||
*
|
||||
* @param Model\Request\MessagesRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function messages(Model\Request\MessagesRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/messages', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered users list
|
||||
*
|
||||
* @param Model\Request\UsersRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function users(Model\Request\UsersRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/users', 'GET', $request, Request::S_ARRAY);
|
||||
}
|
||||
}
|
|
@ -3,27 +3,27 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* RequestHelper
|
||||
* Request Helper
|
||||
*
|
||||
* @package RetailCrm\Helper
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Helper;
|
||||
namespace RetailCrm\Mg\Bot;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* RequestHelper class
|
||||
*
|
||||
* @package RetailCrm\Helper
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class RequestHelper
|
||||
class IntegrationHelper
|
||||
{
|
||||
/**
|
||||
* Prepare module data
|
0
src/Bot/Model/Entity/.gitkeep
Normal file
0
src/Bot/Model/Entity/.gitkeep
Normal file
102
src/Bot/Model/Request/BotsRequest.php
Normal file
102
src/Bot/Model/Request/BotsRequest.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Bots Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* BotsRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class BotsRequest
|
||||
{
|
||||
use CommonFields;
|
||||
|
||||
/**
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getActive",setter="setActive")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getSelf",setter="setSelf")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $self;
|
||||
|
||||
/**
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getRole",setter="setRole")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $role;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getSelf()
|
||||
{
|
||||
return $this->self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $self
|
||||
*/
|
||||
public function setSelf($self)
|
||||
{
|
||||
$this->self = $self;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $active
|
||||
*/
|
||||
public function setActive($active)
|
||||
{
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRole()
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $role
|
||||
*/
|
||||
public function setRole($role)
|
||||
{
|
||||
$this->role = $role;
|
||||
}
|
||||
}
|
79
src/Bot/Model/Request/ChannelsRequest.php
Normal file
79
src/Bot/Model/Request/ChannelsRequest.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Channels Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* ChannelsRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class ChannelsRequest
|
||||
{
|
||||
use CommonFields;
|
||||
|
||||
/**
|
||||
* @Type("array")
|
||||
* @Accessor(getter="getTypes",setter="setTypes")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $types;
|
||||
|
||||
/**
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getActive",setter="setActive")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getTypes()
|
||||
{
|
||||
return $this->types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*/
|
||||
public function setTypes($types)
|
||||
{
|
||||
$this->types = $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $active
|
||||
*/
|
||||
public function setActive($active)
|
||||
{
|
||||
$this->active = $active;
|
||||
}
|
||||
}
|
79
src/Bot/Model/Request/ChatsRequest.php
Normal file
79
src/Bot/Model/Request/ChatsRequest.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Chats Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* ChatsRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class ChatsRequest
|
||||
{
|
||||
use CommonFields;
|
||||
|
||||
/**
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getChannelId",setter="setChannelId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $channelId;
|
||||
|
||||
/**
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getChannelType",setter="setChannelType")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $channelType;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getChannelId()
|
||||
{
|
||||
return $this->channelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $channelId
|
||||
*/
|
||||
public function setChannelId($channelId)
|
||||
{
|
||||
$this->channelId = $channelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChannelType()
|
||||
{
|
||||
return $this->channelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $channelType
|
||||
*/
|
||||
public function setChannelType($channelType)
|
||||
{
|
||||
$this->channelType = $channelType;
|
||||
}
|
||||
}
|
56
src/Bot/Model/Request/CommandsRequest.php
Normal file
56
src/Bot/Model/Request/CommandsRequest.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Commands Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CommandsRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class CommandsRequest
|
||||
{
|
||||
use CommonFields;
|
||||
|
||||
/**
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
100
src/Bot/Model/Request/CommonFields.php
Normal file
100
src/Bot/Model/Request/CommonFields.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Common Fields
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CommonFields trait
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
trait CommonFields
|
||||
{
|
||||
/**
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getId",setter="setId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getSince",setter="setSince")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $since;
|
||||
|
||||
/**
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getUntil",setter="setUntil")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $until;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSince()
|
||||
{
|
||||
return $this->since;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $since
|
||||
*/
|
||||
public function setSince($since)
|
||||
{
|
||||
$this->since = $since;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUntil()
|
||||
{
|
||||
return $this->until;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $until
|
||||
*/
|
||||
public function setUntil($until)
|
||||
{
|
||||
$this->until = $until;
|
||||
}
|
||||
}
|
56
src/Bot/Model/Request/CustomersRequest.php
Normal file
56
src/Bot/Model/Request/CustomersRequest.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Customers Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CustomersRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class CustomersRequest
|
||||
{
|
||||
use CommonFields;
|
||||
|
||||
/**
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getExternalId",setter="setExternalId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $externalId;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalId()
|
||||
{
|
||||
return $this->externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $externalId
|
||||
*/
|
||||
public function setExternalId($externalId)
|
||||
{
|
||||
$this->externalId = $externalId;
|
||||
}
|
||||
}
|
158
src/Bot/Model/Request/DialogsRequest.php
Normal file
158
src/Bot/Model/Request/DialogsRequest.php
Normal file
|
@ -0,0 +1,158 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Commands Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CommandsRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class DialogsRequest
|
||||
{
|
||||
use CommonFields;
|
||||
|
||||
/**
|
||||
* @var int $chatId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getChatId",setter="setChatId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $chatId;
|
||||
|
||||
/**
|
||||
* @var int $userId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getUserId",setter="setUserId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @var int $botId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getBotId",setter="setBotId")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $botId;
|
||||
|
||||
/**
|
||||
* @var int $active
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getActive",setter="setActive")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @var int $assign
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getAssign",setter="setAssign")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $assign;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getChatId(): int
|
||||
{
|
||||
return $this->chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chatId
|
||||
*/
|
||||
public function setChatId(int $chatId)
|
||||
{
|
||||
$this->chatId = $chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUserId(): int
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
*/
|
||||
public function setUserId(int $userId)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBotId(): int
|
||||
{
|
||||
return $this->botId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $botId
|
||||
*/
|
||||
public function setBotId(int $botId)
|
||||
{
|
||||
$this->botId = $botId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getActive(): int
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $active
|
||||
*/
|
||||
public function setActive(int $active)
|
||||
{
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAssign(): int
|
||||
{
|
||||
return $this->assign;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $assign
|
||||
*/
|
||||
public function setAssign(int $assign)
|
||||
{
|
||||
$this->assign = $assign;
|
||||
}
|
||||
}
|
156
src/Bot/Model/Request/MembersRequest.php
Normal file
156
src/Bot/Model/Request/MembersRequest.php
Normal file
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Commands Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CommandsRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class MembersRequest
|
||||
{
|
||||
/**
|
||||
* @var int $chatId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getChatId",setter="setChatId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $chatId;
|
||||
|
||||
/**
|
||||
* @var int $userId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getUserId",setter="setUserId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @var string $state
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getState",setter="setState")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* @var string $since
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getSince",setter="setSince")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $since;
|
||||
|
||||
/**
|
||||
* @var string $until
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getUntil",setter="setUntil")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $until;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getChatId(): int
|
||||
{
|
||||
return $this->chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chatId
|
||||
*/
|
||||
public function setChatId(int $chatId)
|
||||
{
|
||||
$this->chatId = $chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUserId(): int
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
*/
|
||||
public function setUserId(int $userId)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getState(): string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $state
|
||||
*/
|
||||
public function setState(string $state)
|
||||
{
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSince(): string
|
||||
{
|
||||
return $this->since;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $since
|
||||
*/
|
||||
public function setSince(string $since)
|
||||
{
|
||||
$this->since = $since;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUntil(): string
|
||||
{
|
||||
return $this->until;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $until
|
||||
*/
|
||||
public function setUntil(string $until)
|
||||
{
|
||||
$this->until = $until;
|
||||
}
|
||||
}
|
258
src/Bot/Model/Request/MessagesRequest.php
Normal file
258
src/Bot/Model/Request/MessagesRequest.php
Normal file
|
@ -0,0 +1,258 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Customers Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CustomersRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class MessagesRequest
|
||||
{
|
||||
use CommonFields;
|
||||
|
||||
/**
|
||||
* @var int $chatId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getChatId",setter="setChatId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $chatId;
|
||||
|
||||
/**
|
||||
* @var int $dialogId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getDialogId",setter="setDialogId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $dialogId;
|
||||
|
||||
/**
|
||||
* @var int $userId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getUserId",setter="setUserId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @var int $customerId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getCustomerId",setter="setCustomerId")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $customerId;
|
||||
|
||||
/**
|
||||
* @var int $botId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getBotId",setter="setBotId")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $botId;
|
||||
|
||||
/**
|
||||
* @var int $channelId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getChannelId",setter="setChannelId")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $channelId;
|
||||
|
||||
/**
|
||||
* @var string $channelType
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getChannelType",setter="setChannelType")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $channelType;
|
||||
|
||||
/**
|
||||
* @var string $scope
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getScope",setter="setScope")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
/**
|
||||
* @var string $type
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getType",setter="setType")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getChatId(): int
|
||||
{
|
||||
return $this->chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chatId
|
||||
*/
|
||||
public function setChatId(int $chatId)
|
||||
{
|
||||
$this->chatId = $chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDialogId(): int
|
||||
{
|
||||
return $this->dialogId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dialogId
|
||||
*/
|
||||
public function setDialogId(int $dialogId)
|
||||
{
|
||||
$this->dialogId = $dialogId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUserId(): int
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
*/
|
||||
public function setUserId(int $userId)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCustomerId(): int
|
||||
{
|
||||
return $this->customerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $customerId
|
||||
*/
|
||||
public function setCustomerId(int $customerId)
|
||||
{
|
||||
$this->customerId = $customerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBotId(): int
|
||||
{
|
||||
return $this->botId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $botId
|
||||
*/
|
||||
public function setBotId(int $botId)
|
||||
{
|
||||
$this->botId = $botId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getChannelId(): int
|
||||
{
|
||||
return $this->channelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $channelId
|
||||
*/
|
||||
public function setChannelId(int $channelId)
|
||||
{
|
||||
$this->channelId = $channelId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getChannelType(): string
|
||||
{
|
||||
return $this->channelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $channelType
|
||||
*/
|
||||
public function setChannelType(string $channelType)
|
||||
{
|
||||
$this->channelType = $channelType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getScope(): string
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $scope
|
||||
*/
|
||||
public function setScope(string $scope)
|
||||
{
|
||||
$this->scope = $scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType(string $type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
}
|
102
src/Bot/Model/Request/UsersRequest.php
Normal file
102
src/Bot/Model/Request/UsersRequest.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Customers Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Model\Request;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CustomersRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class UsersRequest
|
||||
{
|
||||
use CommonFields;
|
||||
|
||||
/**
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getExternalId",setter="setExternalId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $externalId;
|
||||
|
||||
/**
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getActive",setter="setActive")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getOnline",setter="setOnline")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $online;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalId()
|
||||
{
|
||||
return $this->externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $externalId
|
||||
*/
|
||||
public function setExternalId($externalId)
|
||||
{
|
||||
$this->externalId = $externalId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $active
|
||||
*/
|
||||
public function setActive($active)
|
||||
{
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getOnline()
|
||||
{
|
||||
return $this->online;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $online
|
||||
*/
|
||||
public function setOnline($online)
|
||||
{
|
||||
$this->online = $online;
|
||||
}
|
||||
}
|
0
src/Bot/Model/Response/.gitkeep
Normal file
0
src/Bot/Model/Response/.gitkeep
Normal file
|
@ -5,17 +5,17 @@
|
|||
*
|
||||
* Request
|
||||
*
|
||||
* @package RetailCrm\Bot
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Bot;
|
||||
namespace RetailCrm\Mg\Bot;
|
||||
|
||||
use RetailCrm\Bot\Exception\CurlException;
|
||||
use RetailCrm\Bot\Exception\InvalidJsonException;
|
||||
use RetailCrm\Bot\Exception\LimitException;
|
||||
use JMS\Serializer\SerializerBuilder;
|
||||
use RetailCrm\Common\Exception\CurlException;
|
||||
use RetailCrm\Common\Exception\LimitException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
|
||||
|
@ -24,7 +24,7 @@ use InvalidArgumentException;
|
|||
*
|
||||
* Request class
|
||||
*
|
||||
* @package RetailCrm\Bot
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
|
@ -36,12 +36,13 @@ class Request
|
|||
const METHOD_PUT = 'PUT';
|
||||
const METHOD_DELETE = 'DELETE';
|
||||
|
||||
const SERIALIZE_ARRAY = 0;
|
||||
const SERIALIZE_JSON = 1;
|
||||
const S_ARRAY = 0;
|
||||
const S_JSON = 1;
|
||||
|
||||
protected $url;
|
||||
protected $token;
|
||||
private $debug;
|
||||
private $allowedMethods;
|
||||
|
||||
/**
|
||||
* Client constructor.
|
||||
|
@ -59,44 +60,26 @@ class Request
|
|||
$this->url = $url;
|
||||
$this->token = $token;
|
||||
$this->debug = $debug;
|
||||
$this->allowedMethods = [self::METHOD_GET, self::METHOD_POST, self::METHOD_PUT, self::METHOD_DELETE];
|
||||
}
|
||||
|
||||
/**
|
||||
* Make HTTP request
|
||||
*
|
||||
* @param string $path request url
|
||||
* @param string $method (default: 'GET')
|
||||
* @param array $parameters (default: array())
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \Exception
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @param string $path request url
|
||||
* @param string $method (default: 'GET')
|
||||
* @param mixed $request (default: null)
|
||||
* @param int $serializeTo
|
||||
*
|
||||
* @return Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function makeRequest(
|
||||
$path,
|
||||
$method,
|
||||
array $parameters = []
|
||||
) {
|
||||
$allowedMethods = [self::METHOD_GET, self::METHOD_POST, self::METHOD_PUT, self::METHOD_DELETE];
|
||||
public function makeRequest($path, $method, $request = null, $serializeTo = self::S_JSON)
|
||||
{
|
||||
$this->validateMethod($method);
|
||||
|
||||
if (!in_array($method, $allowedMethods, false)) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Method "%s" is not valid. Allowed methods are %s',
|
||||
$method,
|
||||
implode(', ', $allowedMethods)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$url = $this->url . $path;
|
||||
|
||||
if (self::METHOD_GET === $method && count($parameters)) {
|
||||
$url .= '?' . http_build_query($parameters, '', '&');
|
||||
}
|
||||
$parameters = $this->serialize($request, $serializeTo);
|
||||
$url = $this->buildUrl($path, $method, $parameters);
|
||||
|
||||
$curlHandler = curl_init();
|
||||
curl_setopt($curlHandler, CURLOPT_URL, $url);
|
||||
|
@ -116,7 +99,7 @@ class Request
|
|||
|
||||
if (in_array($method, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_DELETE])) {
|
||||
curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, $method);
|
||||
curl_setopt($curlHandler, CURLOPT_POSTFIELDS, json_encode($parameters));
|
||||
curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $parameters);
|
||||
}
|
||||
|
||||
$responseBody = curl_exec($curlHandler);
|
||||
|
@ -149,4 +132,83 @@ class Request
|
|||
|
||||
return new Response($statusCode, $responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check trailing slash into url
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function normalizeUrl($url)
|
||||
{
|
||||
if ('/' !== $url[strlen($url) - 1]) {
|
||||
$url .= '/';
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate HTTP method
|
||||
*
|
||||
* @param string $method
|
||||
*/
|
||||
private function validateMethod($method)
|
||||
{
|
||||
if (!in_array($method, $this->allowedMethods, false)) {
|
||||
throw new InvalidArgumentException(
|
||||
sprintf(
|
||||
'Method "%s" is not valid. Allowed methods are %s',
|
||||
$method,
|
||||
implode(', ', $this->allowedMethods)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize given object to JSON or Array
|
||||
*
|
||||
* @param object $request
|
||||
* @param int $serialize
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
private function serialize($request, $serialize)
|
||||
{
|
||||
$serialized = null;
|
||||
|
||||
switch ($serialize) {
|
||||
case self::S_ARRAY:
|
||||
$serialized = (array)$request;
|
||||
break;
|
||||
case self::S_JSON:
|
||||
$serializer = SerializerBuilder::create()->build();
|
||||
$serialized = $serializer->serialize($request, 'json');
|
||||
}
|
||||
|
||||
return $serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build request url
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function buildUrl($path, $method, $parameters)
|
||||
{
|
||||
$url = $this->url . $path;
|
||||
|
||||
if (self::METHOD_GET === $method && count($parameters)) {
|
||||
$queryString = http_build_query($parameters, '', '&');
|
||||
$url = sprintf("%s?%s", $url, $queryString);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
|
@ -5,29 +5,30 @@
|
|||
*
|
||||
* Request
|
||||
*
|
||||
* @package RetailCrm\Bot
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Bot;
|
||||
namespace RetailCrm\Mg\Bot;
|
||||
|
||||
use ArrayAccess;
|
||||
use BadMethodCallException;
|
||||
use InvalidArgumentException;
|
||||
use RetailCrm\Bot\Exception\InvalidJsonException;
|
||||
use RetailCrm\Common\Exception\InvalidJsonException;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Request class
|
||||
*
|
||||
* @package RetailCrm\Bot
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Response implements \ArrayAccess
|
||||
class Response implements ArrayAccess
|
||||
{
|
||||
// HTTP response status code
|
||||
protected $statusCode;
|
||||
|
@ -48,7 +49,7 @@ class Response implements \ArrayAccess
|
|||
*/
|
||||
public function __construct($statusCode, $responseBody = null)
|
||||
{
|
||||
$this->statusCode = (int) $statusCode;
|
||||
$this->statusCode = $statusCode;
|
||||
$this->raw = $responseBody;
|
||||
$this->response = self::parseJSON($responseBody);
|
||||
}
|
|
@ -5,13 +5,13 @@
|
|||
*
|
||||
* CurlException
|
||||
*
|
||||
* @package RetailCrm\Bot\Exception
|
||||
* @package RetailCrm\Common\Exception
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Bot\Exception;
|
||||
namespace RetailCrm\Common\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -20,7 +20,7 @@ use RuntimeException;
|
|||
*
|
||||
* Class CurlException
|
||||
*
|
||||
* @package RetailCrm\Bot\Exception
|
||||
* @package RetailCrm\Common\Exception
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
|
@ -5,13 +5,13 @@
|
|||
*
|
||||
* CurlException
|
||||
*
|
||||
* @package RetailCrm\Bot\Exception
|
||||
* @package RetailCrm\Common\Exception
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Bot\Exception;
|
||||
namespace RetailCrm\Common\Exception;
|
||||
|
||||
use DomainException;
|
||||
|
||||
|
@ -20,7 +20,7 @@ use DomainException;
|
|||
*
|
||||
* Class InvalidJsonException
|
||||
*
|
||||
* @package RetailCrm\Bot\Exception
|
||||
* @package RetailCrm\Common\Exception
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
|
@ -5,13 +5,13 @@
|
|||
*
|
||||
* CurlException
|
||||
*
|
||||
* @package RetailCrm\Bot\Exception
|
||||
* @package RetailCrm\Common\Exception
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Bot\Exception;
|
||||
namespace RetailCrm\Common\Exception;
|
||||
|
||||
use DomainException;
|
||||
|
||||
|
@ -20,7 +20,7 @@ use DomainException;
|
|||
*
|
||||
* Class CurlException
|
||||
*
|
||||
* @package RetailCrm\Bot\Exception
|
||||
* @package RetailCrm\Common\Exception
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
|
@ -1,121 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Client
|
||||
*
|
||||
* @package RetailCrm\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Bot;
|
||||
|
||||
use RetailCrm\Bot\Exception\CurlException;
|
||||
use RetailCrm\Bot\Exception\InvalidJsonException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Client class
|
||||
*
|
||||
* @package RetailCrm\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Client
|
||||
{
|
||||
const VERSION = 'v1';
|
||||
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @param string $url api url
|
||||
* @param string $token api key
|
||||
* @param bool $debug debug flag
|
||||
*/
|
||||
public function __construct($url, $token, $debug = false)
|
||||
{
|
||||
if ('/' !== $url[strlen($url) - 1]) {
|
||||
$url .= '/';
|
||||
}
|
||||
|
||||
$url = $url . 'api/bot/' . self::VERSION;
|
||||
$this->client = new Request($url, $token, $debug);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered bots list
|
||||
*
|
||||
* @param array $parameters (default: array())
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function bots(array $parameters = [])
|
||||
{
|
||||
return $this->client->makeRequest('/bots', 'GET', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered channels list
|
||||
*
|
||||
* @param array $parameters (default: array())
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function channels(array $parameters = [])
|
||||
{
|
||||
return $this->client->makeRequest('/channels', 'GET', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered chats list
|
||||
*
|
||||
* @param array $parameters (default: array())
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function chats(array $parameters = [])
|
||||
{
|
||||
return $this->client->makeRequest('/chats', 'GET', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns filtered customers list
|
||||
*
|
||||
* @param array $parameters (default: array())
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function customers(array $parameters = [])
|
||||
{
|
||||
return $this->client->makeRequest('/customers', 'GET', $parameters);
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Channels Request
|
||||
*
|
||||
* @package RetailCrm\RetailCrm\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\RetailCrm\Bot\Model\Request;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* ChannelsRequest class
|
||||
*
|
||||
* @package RetailCrm\RetailCrm\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class ChannelsRequest
|
||||
{
|
||||
public $id;
|
||||
|
||||
public $types;
|
||||
|
||||
public $active;
|
||||
|
||||
public $since;
|
||||
|
||||
public $until;
|
||||
}
|
|
@ -5,17 +5,16 @@
|
|||
*
|
||||
* Test case class
|
||||
*
|
||||
* @category RetailCrm
|
||||
* @package Test
|
||||
* @author RetailCrm <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://www.retailcrm.ru/docs/Developers/ApiVersion5
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Test;
|
||||
namespace RetailCrm\Mg\Bot\Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase as BaseCase;
|
||||
use RetailCrm\Bot\Client;
|
||||
use RetailCrm\Mg\Bot\Client;
|
||||
|
||||
/**
|
||||
* Class TestCase
|
0
tests/Bot/Tests/.gitkeep
Normal file
0
tests/Bot/Tests/.gitkeep
Normal file
84
tests/Bot/Tests/ClientTest.php
Normal file
84
tests/Bot/Tests/ClientTest.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Client Test
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Tests
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Tests;
|
||||
|
||||
use RetailCrm\Mg\Bot\Client;
|
||||
use RetailCrm\Mg\Bot\Test\TestCase;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class ClientTest
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Tests
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class ClientTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
*/
|
||||
public function testChannels()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testChats()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testMembers()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testMessages()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testCommands()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testBots()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testUsers()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testDialogs()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function test__construct()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testCustomers()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
}
|
|
@ -7,4 +7,4 @@ if (function_exists('date_default_timezone_set')
|
|||
}
|
||||
|
||||
$loader = include dirname(__DIR__) . '/vendor/autoload.php';
|
||||
$loader->add('RetailCrm\\Test', __DIR__);
|
||||
$loader->add('RetailCrm\\Mg\\Bot\\Test', __DIR__);
|
||||
|
|
Loading…
Add table
Reference in a new issue