1
0
Fork 0
mirror of synced 2025-04-07 07:03:31 +03:00

Compare commits

...

102 commits

Author SHA1 Message Date
7a87f2669b
Merge pull request #54 from Chupocabra/refactor-members_req
Use CommonFields in MembersRequest
2025-03-26 11:42:56 +03:00
Alex Komarichev
f65dcac9f5 ignore phpstan setID type error 2025-03-26 11:33:11 +03:00
Alex Komarichev
9a23562cbd Use CommonFields in MembersRequest 2025-03-26 11:14:48 +03:00
141c2c9bc3
update actions version in ci 2025-03-26 11:09:50 +03:00
46e0f84265
Merge pull request #53 from kifril-ltd/role-hidden
Add new bot role `hidden`
2024-11-15 14:40:13 +03:00
Kirill Sukhorukov
dc0ead717e Add new bot role hidden 2024-11-14 15:46:02 +03:00
2d5a8ceaed
Added is_system to User 2024-11-05 12:42:01 +03:00
Alex Komarichev
2b798fa877 Added is_system to User 2024-11-05 12:28:27 +03:00
95520bb1e7
Add include_mass_communication param to requests 2024-09-16 15:29:00 +03:00
Opheugene
bd0c267f09 fix tests 2024-09-16 13:53:48 +02:00
Opheugene
f0ba8e65f3 Added include_mass_communication param for requests 2024-09-16 13:44:41 +02:00
fb0e9404a5
Add audio transcription field 2024-09-13 15:22:17 +03:00
Opheugene
b1fd78d2b5 fix phpstan 2024-09-13 13:06:04 +02:00
Opheugene
5da993d598 Add Item transcription 2024-09-13 13:00:57 +02:00
4b6e9e0dff
Add chat reply_deadline field 2024-08-14 17:10:27 +03:00
2640e661cf
Add responsible external_id field 2024-08-14 17:10:14 +03:00
Alex Komarichev
d34270121c Add responsible external_id field 2024-08-14 17:02:07 +03:00
Alex Komarichev
93777973b5 Add reply_deadline to chats.json 2024-08-14 10:00:37 +03:00
Alex Komarichev
bcf3d0974b Add chat reply_deadline field 2024-08-13 19:52:44 +03:00
6e4dd6af44
Add since_id field to ChatsRequest 2024-07-16 13:02:55 +03:00
Vlasov
370fd04824 Added since_id field to ChatsRequest 2024-07-16 12:45:06 +03:00
26aa42ce67
Add template attachments 2024-07-02 16:38:51 +03:00
Alex Komarichev
290d5f87e5 phpstan 2024-07-02 15:35:20 +03:00
Alex Komarichev
54486d4008 Add template attachments 2024-07-02 15:30:36 +03:00
1fc8ccda10
Add templates interaction 2024-06-25 12:05:14 +03:00
Alex Komarichev
33e816ce97 Add templateSend phpdoc 2024-06-25 11:20:01 +03:00
Alex Komarichev
4b5041b05b phpstan 2024-06-24 21:07:47 +03:00
Alex Komarichev
8a20b86b17 Add templates interaction 2024-06-24 20:21:41 +03:00
a05cf2cc09
Add note to SendMessageRequest 2024-06-21 14:02:54 +03:00
Alex Komarichev
be857dd1ac Add note to SendMessageRequest 2024-06-20 19:14:50 +03:00
90b90c0f8d
Add working with customer utm 2024-05-22 16:54:37 +03:00
Alex Komarichev
5aaed7ab7d Add working with customer utm 2024-05-21 20:25:44 +03:00
Chupocabra
6682b9b02c
Add working with dialog tags 2024-02-29 12:01:40 +03:00
41cb22a720
Add suggestions to ChannelSettings 2024-02-06 15:01:55 +03:00
Alex Komarichev
8892e5fe5a Phpstan fixes 2024-02-06 12:05:24 +03:00
Alex Komarichev
e14afbf773 Add suggestions to ChannelSettings 2024-02-05 19:21:42 +03:00
93924bf3b5
add limit field to MessagesRequest 2023-10-26 10:16:31 +03:00
3d7a10f7c6 update phpstan baseline 2023-10-26 10:13:42 +03:00
7dd570ffc3 add limit field to MessagesRequest 2023-10-26 09:50:02 +03:00
Ilyas Salikhov
d92b89ad37
Merge pull request #39 from retailcrm/dialog-list-since-id-filter
Filter sinceId in dialog list method
2023-08-10 19:04:04 +03:00
Ilyas Salikhov
8b9afc52af Filter sinceId in dialog list method 2023-08-10 18:57:40 +03:00
Ilyas Salikhov
d9192f963c
Merge pull request #38 from retailcrm/php-env-and-version
Php ENV and actual version
2023-08-10 18:56:49 +03:00
Ilyas Salikhov
b478dd6f25 Ability to run tests in docker 2023-08-10 18:40:29 +03:00
Ilyas Salikhov
29d6732404 Actualized PHP version in README and composer.json according to the versions in CI 2023-08-10 18:31:31 +03:00
59e9c8d3be
add quote field to the message type 2023-06-07 16:00:13 +03:00
Ruslan Efanov
e1e484e046 add field quote for message 2023-06-05 14:31:09 +03:00
516e7855a0
add note field support 2023-05-24 16:04:21 +03:00
a08a03c1c8 phpstan fix 2023-05-24 15:59:04 +03:00
016f152fef add note field support 2023-05-24 15:56:55 +03:00
max-baranikov
c024350882
Fixed url deserialization in getFileById() method (#35)
* Added tests to reproduce issue
* Fixed url deserialization in getFileById() method
2023-04-27 14:27:18 +03:00
6ec1f00df9
add limit to requests 2023-02-07 16:14:01 +03:00
Ruslan Efanov
58aa909473 add using limit in requests 2023-02-07 12:50:29 +03:00
1650ff34aa
Parse dates with and without nanoseconds 2023-01-20 13:09:15 +03:00
aac414ecd5 parse dates without nanoseconds 2023-01-20 13:06:36 +03:00
181a9703a5
fix for /chats request 2022-12-22 15:41:11 +03:00
910bf5e118
update dependencies 2022-12-22 15:40:59 +03:00
7e1ed1a241 additional fixes 2022-12-22 15:21:14 +03:00
45b1012632 update test matrix 2022-12-22 14:57:29 +03:00
2c5fe64779 update dependencies 2022-12-22 14:55:13 +03:00
0631c80ebb fix for typos 2022-12-22 14:03:10 +03:00
c931b2622c fix for /chats request 2022-12-22 13:46:12 +03:00
7a92435f9f
Add test for GET request of chats by customer_id 2022-12-07 17:03:52 +03:00
Ruslan Efanov
4b898fdc95 Add test for GET request of chats by customer_id 2022-11-16 16:19:27 +03:00
62ff2ec979
update ChatsRequest 2022-11-16 10:01:25 +03:00
6476caf9b9 fix for linter notifications 2022-11-16 09:57:29 +03:00
92a0eb0c0b update ChatsRequest 2022-11-16 09:54:56 +03:00
6fbddeb2a9
Bump guzzlehttp/guzzle from 6.5.7 to 6.5.8 2022-06-22 09:52:14 +03:00
dependabot[bot]
00a8764edb
Bump guzzlehttp/guzzle from 6.5.7 to 6.5.8
Bumps [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) from 6.5.7 to 6.5.8.
- [Release notes](https://github.com/guzzle/guzzle/releases)
- [Changelog](https://github.com/guzzle/guzzle/blob/6.5.8/CHANGELOG.md)
- [Commits](https://github.com/guzzle/guzzle/compare/6.5.7...6.5.8)

---
updated-dependencies:
- dependency-name: guzzlehttp/guzzle
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-21 20:51:06 +00:00
c9a992bf6b
Bump guzzlehttp/guzzle from 6.5.6 to 6.5.7 2022-06-15 09:25:32 +03:00
dependabot[bot]
fff4e6d3fa
Bump guzzlehttp/guzzle from 6.5.6 to 6.5.7
Bumps [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) from 6.5.6 to 6.5.7.
- [Release notes](https://github.com/guzzle/guzzle/releases)
- [Changelog](https://github.com/guzzle/guzzle/blob/6.5.7/CHANGELOG.md)
- [Commits](https://github.com/guzzle/guzzle/compare/6.5.6...6.5.7)

---
updated-dependencies:
- dependency-name: guzzlehttp/guzzle
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-10 06:40:35 +00:00
6f277f6ccd
Update guzzlehttp/guzzle to 6.5.6 2022-05-27 11:21:27 +03:00
dependabot[bot]
f56720289b
Bump guzzlehttp/guzzle from 6.5.5 to 6.5.6
Bumps [guzzlehttp/guzzle](https://github.com/guzzle/guzzle) from 6.5.5 to 6.5.6.
- [Release notes](https://github.com/guzzle/guzzle/releases)
- [Changelog](https://github.com/guzzle/guzzle/blob/6.5.6/CHANGELOG.md)
- [Commits](https://github.com/guzzle/guzzle/compare/6.5.5...6.5.6)

---
updated-dependencies:
- dependency-name: guzzlehttp/guzzle
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-05-25 18:14:00 +00:00
dependabot[bot]
04cd471765
Bump guzzlehttp/psr7 from 1.8.3 to 1.8.5 (#25)
Bumps [guzzlehttp/psr7](https://github.com/guzzle/psr7) from 1.8.3 to 1.8.5.
- [Release notes](https://github.com/guzzle/psr7/releases)
- [Changelog](https://github.com/guzzle/psr7/blob/1.8.5/CHANGELOG.md)
- [Commits](https://github.com/guzzle/psr7/compare/1.8.3...1.8.5)

---
updated-dependencies:
- dependency-name: guzzlehttp/psr7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-31 15:03:29 +03:00
tishmaria90
cb94fd8e02
Keep false values while deserializing (#24)
Co-authored-by: Maria Tyschitskaya <tyschitskaya@retailcrm.ru>
2021-12-23 14:33:44 +03:00
tishmaria90
98563e2e60
Update php version (#20) 2021-12-13 10:48:18 +03:00
max-baranikov
c6a44ea2b3
Added suggestions to MessageSendRequest (#16) 2021-10-15 13:39:36 +03:00
Opheugene
bb78a4ffb3
Add dialogUnassign method for the client (#15) 2021-09-02 11:17:59 +03:00
Alex Lushpai
84ecba8714
Update product name, cleanup annotations (#14) 2020-12-15 13:34:43 +03:00
Akolzin Dmitry
b7f214a212
Move CI to GitHub Actions (#13) 2020-11-26 15:57:53 +03:00
Alex Lushpai
c758c27e98
Update README.md 2020-11-12 13:58:50 +03:00
Alex Lushpai
ed2efc4d1d
Merge pull request #12 from open-source-contributions/test_enhancement
Test enhancement
2019-10-23 23:41:13 +03:00
peter279k
316836aca7 Test enhancement 2019-10-24 02:35:21 +08:00
Alex Lushpai
0534f31c34
Merge pull request #11 from Neur0toxine/master
[fix] update phpdoc for getters
2019-10-08 17:06:37 +03:00
91453308fe [fix] update phpdoc for getters 2019-10-08 17:02:39 +03:00
Alex Lushpai
9e18bba010
Merge pull request #10 from Neur0toxine/master
[fix] make all getters nullable
2019-10-08 12:33:34 +03:00
49045777d3 [fix] make all getters nullable 2019-10-08 09:12:36 +03:00
Alex Lushpai
6594182fb0
Merge pull request #9 from Neur0toxine/master
[fix] nullable types to avoid exceptions when properties is not set
2019-10-07 10:14:01 +03:00
e111b8d882 [fix] nullable types to avoid exceptions when properties is not set 2019-10-07 09:09:49 +03:00
Alex Lushpai
5f6179ea1c
Merge pull request #8 from Neur0toxine/master
[fix] removed models duplicates, fixed several errors
2019-09-30 17:23:11 +03:00
1929afe400 [fix] removed models duplicates, fixed several errors 2019-09-30 17:02:48 +03:00
Alex Lushpai
93e06271c7
Merge pull request #7 from Neur0toxine/master
fix: change Register::active type from string to boolean
2019-07-23 17:33:34 +03:00
561737ffbc fix: change Register::active type from string to boolean 2019-07-23 17:25:59 +03:00
Alex Lushpai
f8f5cd1d1e
Merge pull request #6 from gwinn/master
fix serialization keys
2019-07-18 13:04:10 +03:00
Alex Lushpai
9286596157 fix serialization keys 2019-07-18 13:01:50 +03:00
Alex Lushpai
6c7cf52a65
Merge pull request #5 from gwinn/master
Cleanup code
2019-07-16 16:51:01 +03:00
Alex Lushpai
38fa980038 cleanup 2019-07-16 16:41:56 +03:00
Alex Lushpai
997cc48acf
Update README.md 2019-07-16 15:56:44 +03:00
Alex Lushpai
10121a501f
Merge pull request #4 from Neur0toxine/master
fixes for tests
2019-07-16 15:54:09 +03:00
34423a3042 fixes for tests 2019-07-16 15:20:56 +03:00
Alex Lushpai
318b2e74cb
Update models & serialization (#3) 2019-07-16 15:04:54 +03:00
Alex Lushpai
8001ab64e2
Update README.md 2019-06-28 14:43:11 +03:00
Alex Lushpai
e552df5f04
Update README.md 2019-06-28 14:25:03 +03:00
113 changed files with 6734 additions and 6299 deletions

View file

@ -1,3 +1,3 @@
MG_BOT_URL="https://mg-test.retailcrm.pro/"
MG_BOT_URL="https://mg-s1.retailcrm.pro/"
MG_BOT_KEY=""
MG_BOT_DBG=""

36
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,36 @@
name: ci
on:
push:
branches:
- '**'
tags-ignore:
- '*.*'
pull_request:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['7.3', '7.4', '8.0', '8.1']
steps:
- uses: actions/checkout@v4
- name: Setup PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v1
- name: Composer cache
uses: actions/cache@v4
with:
path: ${{ env.HOME }}/.composer/cache
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
- name: Install dependencies
run: composer install -o
- name: Phpstan analysis
run: make stan
- name: Run tests
run: make test
- name: Coverage
run: bash <(curl -s https://codecov.io/bash)

9
.gitignore vendored
View file

@ -192,8 +192,9 @@ phpDocumentor.phar.pubkey
mg-bot-api-client-php.pages/*
build/*
# Test report
# Test report & coverage
test-report.xml
# GraphViz Dot
dot/*
.phpunit.result.cache
clover.xml
composer.lock
docker-compose.yml

View file

@ -1,17 +0,0 @@
language: php
cache:
directories:
- $HOME/.composer/cache
php:
- '7.0'
- '7.1'
- '7.2'
- '7.3'
before_script:
- flags="-o"
- composer install $flags
script: make travis

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018-2019 RetailDriver LLC
Copyright (c) 2018-2020 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

View file

@ -1,18 +1,16 @@
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_DIR=$(ROOT_DIR)/src
BIN_DIR=$(ROOT_DIR)/bin
ifneq ("$(wildcard docker-compose.yml)","")
PHP=docker-compose run --rm --no-deps php php
else
PHP=php
endif
test:
@echo "==> Running tests"
@cd $(ROOT_DIR)
@cp .env.dist .env
@php -d memory_limit=-1 $(BIN_DIR)/phpunit -c phpunit.xml.dist
@$(PHP) -d memory_limit=-1 vendor/bin/phpunit -c phpunit.xml.dist
@echo "==> Testing complete"
stan:
@echo "==> Running analysis"
@php $(BIN_DIR)/phpstan analyse -a $(ROOT_DIR)/extra/autoloader.php -l 4 src
@$(PHP) vendor/bin/phpstan analyse
@echo "==> Analysis complete"
travis: test stan
@echo "==> Completed"

View file

@ -1,15 +1,14 @@
[![Build Status](https://img.shields.io/travis/retailcrm/mg-bot-api-client-php/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/mg-bot-api-client-php)
[![Latest stable](https://img.shields.io/packagist/v/retailcrm/mg-bot-api-client-php.svg?style=flat-square)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
[![PHP from Packagist](https://img.shields.io/packagist/php-v/mg-bot-retailcrm/api-client-php.svg?style=flat-square)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
[![Build Status](https://github.com/retailcrm/mg-bot-api-client-php/workflows/ci/badge.svg)](https://github.com/retailcrm/mg-bot-api-client-php/actions)
[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/mg-bot-api-client-php/master.svg?logo=codecov&logoColor=white)](https://codecov.io/gh/retailcrm/mg-bot-api-client-php)
[![Latest stable](https://img.shields.io/packagist/v/retailcrm/mg-bot-api-client-php.svg)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
[![PHP from Packagist](https://img.shields.io/packagist/php-v/retailcrm/mg-bot-api-client-php.svg?logo=php&logoColor=white)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
# retailCRM API PHP client
This is php retailCRM MG Bot API client.
# Message Gateway Bot API PHP client
## Requirements
* PHP 7.0 and above
* PHP 7.3 and above
* PHP's cURL support
* PHP's JSON support
@ -19,7 +18,7 @@ This is php retailCRM MG Bot API client.
2) Run into your project directory:
```bash
composer require retailcrm/mg-bot-api-client-php ~1.0
composer require retailcrm/mg-bot-api-client-php ~1.*
```
If you have not used `composer` before, include autoloader into your project.
@ -31,8 +30,11 @@ require 'path/to/vendor/autoload.php';
### Assign dialog
```php
use \RetailCrm\Mg\Bot\Client;
use \RetailCrm\Mg\Bot\Model\Request\DialogAssignRequest;
<?php
use RetailCrm\Common\Exception;
use RetailCrm\Mg\Bot\Client;
use RetailCrm\Mg\Bot\Model\Request\DialogAssignRequest;
$client = new Client('https://mg.url.demo', 'T9DMPvuNt7FQJMszHUd', true);
@ -41,23 +43,11 @@ try {
$request->setDialogId(60);
$request->setUserId(4);
/* @var \RetailCrm\Mg\Bot\Model\Response\AssignResponse $response */
$response = $client->dialogAssign($request);
} catch (\RetailCrm\Exception\CurlException $exception) {
echo $exception->getMessage();
} catch (\RetailCrm\Exception\LimitException $exception) {
echo $exception->getMessage();
} catch (\InvalidArgumentException $exception) {
echo $exception->getMessage();
} catch (\Exception $exception) {
} catch (Exception\LimitException | Exception\InvalidJsonException | Exception\UnauthorizedException $exception) {
echo $exception->getMessage();
}
if ($response->isSuccessful()) {
$response->getPreviousResponsible();
}
echo $response->getPreviousResponsible();
```
### Documentation
* [English](http://www.retailcrm.pro/docs/Developers/Index)
* [Russian](https://139810.selcdn.ru/download/doc/mg-bot-api/bot.v1.en.html)

View file

@ -1,69 +1,57 @@
{
"name": "retailcrm/mg-bot-api-client-php",
"description": "PHP client for retailCRM MG Bot API",
"description": "PHP client for MG Bot API",
"type": "library",
"keywords": ["API", "retailCRM", "REST", "bot"],
"keywords": ["API", "RetailCRM", "REST", "bot"],
"homepage": "http://www.retailcrm.ru/",
"license": "MIT",
"authors": [
{
"name": "retailCRM",
"email": "support@retailcrm.ru"
"name": "RetailCRM",
"email": "support@retailcrm.pro"
}
],
"require": {
"php": ">=7.0",
"php": ">=7.3",
"ext-curl": "*",
"ext-json": "*",
"jms/serializer": "1.14.*",
"symfony/validator": "3.*",
"doctrine/annotations": "1.4.*",
"doctrine/cache": "1.6.*",
"guzzlehttp/guzzle": "6.*",
"doctrine/instantiator": "1.0.*",
"symfony/translation": "3.*",
"symfony/dependency-injection": "3.*",
"symfony/config": "3.*",
"symfony/finder": "3.4.*",
"symfony/filesystem": "3.*"
"jms/serializer": "3.*",
"symfony/validator": "5.4.*|^6",
"doctrine/annotations": "^1",
"guzzlehttp/guzzle": "7.*",
"symfony/intl": "5.4.*|^6",
"symfony/cache": "5.4.*|^6"
},
"require-dev": {
"phpmd/phpmd": "2.*",
"squizlabs/php_codesniffer": "3.4.*",
"symfony/dotenv": "3.*",
"friendsofphp/php-cs-fixer": "2.*",
"phpunit/phpunit": "6.*",
"nette/bootstrap": "2.*",
"nette/neon": "2.*",
"nette/php-generator": "3.0.*",
"phpstan/phpstan": "0.9.*",
"ocramius/package-versions": "1.2.*",
"nette/finder": "2.4.*",
"symfony/console": "3.*",
"symfony/debug": "3.*",
"symfony/event-dispatcher": "3.*",
"symfony/options-resolver": "3.4.*",
"symfony/process": "3.4.*",
"symfony/stopwatch": "3.4.*",
"myclabs/deep-copy": "1.6.*"
"symfony/dotenv": "5.4.*",
"phpunit/phpunit": "^9",
"phpstan/phpstan": "0.12.*"
},
"support": {
"email": "support@retailcrm.ru"
"email": "support@retailcrm.pro"
},
"autoload": {
"psr-4": {
"RetailCrm\\Mg\\": ["src/", "tests/"],
"RetailCrm\\Mg\\": "src/",
"RetailCrm\\Common\\": "src/"
},
"files": ["extra/autoloader.php"]
},
"autoload-dev": {
"psr-4": {
"RetailCrm\\Mg\\": "tests/",
"RetailCrm\\Common\\": "tests/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"config": {
"bin-dir": "bin",
"bin-dir": "vendor/bin",
"process-timeout": 600
}
}

4579
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,7 @@ use Composer\Autoload\ClassLoader;
$autoloadFile = file_exists(__DIR__ . '/../vendor/autoload.php')
? __DIR__ . '/../vendor/autoload.php'
: __DIR__ . '/../../../autoload.php';
$loader = require $autoloadFile;
AnnotationRegistry::registerLoader('class_exists');

1932
phpstan-baseline.neon Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,7 @@
includes:
- phpstan-baseline.neon
parameters:
autoload_files:
- %currentWorkingDirectory%/vendor/autoload.php
level: 4
level: 7
paths:
- %currentWorkingDirectory%/src

View file

@ -1,22 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
bootstrap="./tests/bootstrap.php"
colors="true"
verbose="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="RetailCrm">
<directory>tests/Bot/Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src/Bot</directory>
</whitelist>
</filter>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
colors="false"
bootstrap="tests/bootstrap.php"
backupStaticAttributes="false"
convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
processIsolation="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
stopOnRisky="false">
<coverage>
<include>
<directory>src</directory>
</include>
<report>
<clover outputFile="clover.xml"/>
</report>
</coverage>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="/tmp/logfile.xml"/>
</logging>
</phpunit>

View file

@ -1,36 +1,42 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* 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
* @package RetailCrm\Mg\Bot
*/
namespace RetailCrm\Mg\Bot;
use Psr\Http\Message\ResponseInterface;
use RetailCrm\Common\Exception\InvalidJsonException;
use RetailCrm\Common\Url;
use RetailCrm\Common\Serializer;
use RetailCrm\Common\Url;
use RetailCrm\Mg\Bot\Model\Entity\Bot;
use RetailCrm\Mg\Bot\Model\Entity\Channel\Channel;
use RetailCrm\Mg\Bot\Model\Entity\Chat\Chat;
use RetailCrm\Mg\Bot\Model\Entity\Chat\ChatMember;
use RetailCrm\Mg\Bot\Model\Entity\Command;
use RetailCrm\Mg\Bot\Model\Entity\Customer;
use RetailCrm\Mg\Bot\Model\Entity\Dialog;
use RetailCrm\Mg\Bot\Model\Entity\Message\Message;
use RetailCrm\Mg\Bot\Model\Entity\Template\Template;
use RetailCrm\Mg\Bot\Model\Entity\User;
use RetailCrm\Mg\Bot\Model\ModelAdapter;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use RetailCrm\Mg\Bot\Model\Request\UploadFileByUrlRequest;
use RetailCrm\Mg\Bot\Model\Response\AssignResponse;
use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse;
use RetailCrm\Mg\Bot\Model\Response\FullFileResponse;
use RetailCrm\Mg\Bot\Model\Response\ListResponse;
use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse;
use RetailCrm\Mg\Bot\Model\Response\UnassignResponse;
use RetailCrm\Mg\Bot\Model\Response\UploadFileResponse;
/**
* PHP version 7.0
* Class Client
*
* 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
* @package RetailCrm\Mg\Bot
*/
class Client
{
@ -39,11 +45,6 @@ class Client
*/
const VERSION = 'v1';
/**
* @internal
*/
const ERROR_ONLY_RESPONSE = 'ErrorOnlyResponse';
/**
* @var HttpClient
*/
@ -52,9 +53,9 @@ class Client
/**
* Init
*
* @param string $url MG API URL
* @param string $token MG API Key
* @param bool $debug Enable or disable debug mode - will log all requests to STDOUT (default: false)
* @param string $url MG API URL
* @param string $token MG API Key
* @param bool $debug Enable or disable debug mode (default: false)
* @param \GuzzleHttp\HandlerStack $handler GuzzleHttp::HandlerStack instance (default: null)
*/
public function __construct($url, $token, $debug = false, $handler = null)
@ -63,115 +64,25 @@ class Client
$this->client = new HttpClient($url, $token, $debug ? STDOUT : null, $handler);
}
/**
* @param string $path
* @param string $method
* @param object|null $request Request parameters
* @param string $responseType
* @param bool $arrayOfObjects
*
* @return object|null
* @throws \Exception
*/
private function submitRequest(
$path,
$method,
$request,
$responseType,
$arrayOfObjects = false
) {
$response = $this->client->makeRequest(
$path,
$method,
$request
);
$statusCode = $response->getStatusCode();
$data = json_decode((string) $response->getBody(), true);
if (json_last_error() == JSON_ERROR_NONE) {
if ($arrayOfObjects) {
return new ListResponse($responseType, $data, $statusCode);
} else {
$obj = Serializer::deserialize($data, $responseType, Serializer::S_ARRAY);
if ($statusCode >= 400
&& method_exists($obj, 'setErrors')
&& method_exists($obj, 'getErrors')
&& count(call_user_func([$obj, 'getErrors'])) == 0
) {
call_user_func_array([$obj, 'setErrors'], [['Status Code ' . $response->getStatusCode()]]);
}
if (method_exists($obj, 'setStatusCode')) {
call_user_func_array([$obj, 'setStatusCode'], [$statusCode]);
}
return $obj;
}
} else {
throw new InvalidJsonException('Received invalid JSON', 1);
}
}
/**
* @param bool $fromRoot
* @param string ...$classes
*
* @return string
*/
private static function concatClasspath($fromRoot, ...$classes)
{
$path = '';
foreach ($classes as $class) {
if (empty($path) && !$fromRoot) {
$path .= $class;
} else {
$path .= '\\' . $class;
}
}
return $path;
}
/**
* @param string ...$classes
*
* @return string
*/
private static function getEntityClass(...$classes)
{
return static::concatClasspath(true, 'RetailCrm', 'Mg', 'Bot', 'Model', 'Entity', ...$classes);
}
/**
* @param string ...$classes
*
* @return string
*/
private static function getResponseClass(...$classes)
{
return static::concatClasspath(true, 'RetailCrm', 'Mg', 'Bot', 'Model', 'Response', ...$classes);
}
/**
* Returns filtered bots list
*
* @param Model\Request\BotsRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function bots(Model\Request\BotsRequest $request)
public function bots(Model\Request\BotsRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/bots',
HttpClient::METHOD_GET,
$request,
static::getEntityClass('Bot'),
true
$request
);
$adapter = new ModelAdapter(Bot::class);
return $adapter->getResponseList($response);
}
/**
@ -179,17 +90,20 @@ class Client
*
* @param Model\Request\InfoRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function info(Model\Request\InfoRequest $request)
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/my/info',
HttpClient::METHOD_PATCH,
$request,
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
$request
);
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
}
/**
@ -197,18 +111,20 @@ class Client
*
* @param Model\Request\ChannelsRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function channels(Model\Request\ChannelsRequest $request)
public function channels(Model\Request\ChannelsRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/channels',
HttpClient::METHOD_GET,
$request,
static::getEntityClass('Channel', 'Channel'),
true
$request
);
$adapter = new ModelAdapter(Channel::class);
return $adapter->getResponseList($response);
}
/**
@ -216,18 +132,20 @@ class Client
*
* @param Model\Request\ChatsRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function chats(Model\Request\ChatsRequest $request)
public function chats(Model\Request\ChatsRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/chats',
HttpClient::METHOD_GET,
$request,
static::getEntityClass('Chat', 'Chat'),
true
$request
);
$adapter = new ModelAdapter(Chat::class);
return $adapter->getResponseList($response);
}
/**
@ -235,18 +153,20 @@ class Client
*
* @param Model\Request\CommandsRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function commands(Model\Request\CommandsRequest $request)
public function commands(Model\Request\CommandsRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/my/commands',
HttpClient::METHOD_GET,
$request,
static::getEntityClass('Command'),
true
$request
);
$adapter = new ModelAdapter(Command::class);
return $adapter->getResponseList($response);
}
/**
@ -254,17 +174,20 @@ class Client
*
* @param Model\Request\CommandEditRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function commandEdit(Model\Request\CommandEditRequest $request)
{
return $this->submitRequest(
$response = $this->client->makeRequest(
sprintf("/my/commands/%s", $request->getName()),
HttpClient::METHOD_PUT,
$request,
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
$request
);
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
}
/**
@ -272,17 +195,19 @@ class Client
*
* @param string $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function commandDelete(string $request)
{
return $this->submitRequest(
$response = $this->client->makeRequest(
sprintf("/my/commands/%s", $request),
HttpClient::METHOD_DELETE,
null,
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
HttpClient::METHOD_DELETE
);
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
}
/**
@ -290,18 +215,20 @@ class Client
*
* @param Model\Request\CustomersRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function customers(Model\Request\CustomersRequest $request)
public function customers(Model\Request\CustomersRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/customers',
HttpClient::METHOD_GET,
$request,
static::getEntityClass('Customer'),
true
$request
);
$adapter = new ModelAdapter(Customer::class);
return $adapter->getResponseList($response);
}
/**
@ -309,18 +236,20 @@ class Client
*
* @param Model\Request\DialogsRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function dialogs(Model\Request\DialogsRequest $request)
public function dialogs(Model\Request\DialogsRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/dialogs',
HttpClient::METHOD_GET,
$request,
static::getEntityClass('Dialog'),
true
$request
);
$adapter = new ModelAdapter(Dialog::class);
return $adapter->getResponseList($response);
}
/**
@ -328,17 +257,41 @@ class Client
*
* @param Model\Request\DialogAssignRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\AssignResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function dialogAssign(Model\Request\DialogAssignRequest $request)
{
return $this->submitRequest(
$response = $this->client->makeRequest(
sprintf("/dialogs/%d/assign", $request->getDialogId()),
HttpClient::METHOD_PATCH,
$request,
static::getResponseClass('AssignResponse')
$request
);
$adapter = new ModelAdapter(AssignResponse::class);
return $adapter->getResponseModel($response);
}
/**
* Unassigning a dialog from a manager or a bot
*
* @param string $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function dialogUnassign(string $request)
{
$response = $this->client->makeRequest(
sprintf("/dialogs/%d/unassign", $request),
HttpClient::METHOD_PATCH,
null
);
$adapter = new ModelAdapter(UnassignResponse::class);
return $adapter->getResponseModel($response);
}
/**
@ -346,17 +299,62 @@ class Client
*
* @param string $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function dialogClose(string $request)
{
return $this->submitRequest(
$response = $this->client->makeRequest(
sprintf("/dialogs/%d/close", $request),
HttpClient::METHOD_DELETE,
null,
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
null
);
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
}
/**
* Add tag to dialog
*
* @param Model\Request\DialogTagRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function dialogAddTag(Model\Request\DialogTagRequest $request)
{
$response = $this->client->makeRequest(
sprintf("/dialogs/%d/tags/add", $request->getDialogId()),
HttpClient::METHOD_PATCH,
$request
);
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
}
/**
* Delete tag from dialog
*
* @param Model\Request\DialogTagRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function dialogDeleteTag(Model\Request\DialogTagRequest $request)
{
$response = $this->client->makeRequest(
sprintf("/dialogs/%d/tags/delete", $request->getDialogId()),
HttpClient::METHOD_PATCH,
$request
);
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
}
/**
@ -364,18 +362,20 @@ class Client
*
* @param Model\Request\MembersRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function members(Model\Request\MembersRequest $request)
public function members(Model\Request\MembersRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/members',
HttpClient::METHOD_GET,
$request,
static::getEntityClass('Chat', 'ChatMember'),
true
$request
);
$adapter = new ModelAdapter(ChatMember::class);
return $adapter->getResponseList($response);
}
/**
@ -383,18 +383,20 @@ class Client
*
* @param Model\Request\MessagesRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function messages(Model\Request\MessagesRequest $request)
public function messages(Model\Request\MessagesRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/messages',
HttpClient::METHOD_GET,
$request,
self::getEntityClass('Message', 'Message'),
true
$request
);
$adapter = new ModelAdapter(Message::class);
return $adapter->getResponseList($response);
}
/**
@ -402,17 +404,20 @@ class Client
*
* @param Model\Request\MessageSendRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\MessageSendResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function messageSend(Model\Request\MessageSendRequest $request)
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/messages',
HttpClient::METHOD_POST,
$request,
static::getResponseClass('MessageSendResponse')
$request
);
$adapter = new ModelAdapter(MessageSendResponse::class);
return $adapter->getResponseModel($response);
}
/**
@ -420,17 +425,20 @@ class Client
*
* @param Model\Request\MessageEditRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\MessageSendResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function messageEdit(Model\Request\MessageEditRequest $request)
{
return $this->submitRequest(
$response = $this->client->makeRequest(
sprintf("/messages/%d", $request->getId()),
HttpClient::METHOD_PATCH,
$request,
static::getResponseClass('MessageSendResponse')
$request
);
$adapter = new ModelAdapter(MessageSendResponse::class);
return $adapter->getResponseModel($response);
}
/**
@ -438,17 +446,61 @@ class Client
*
* @param string $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function messageDelete(string $request)
{
return $this->submitRequest(
$response = $this->client->makeRequest(
sprintf("/messages/%d", $request),
HttpClient::METHOD_DELETE,
null,
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
null
);
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
}
/**
* Returns templates list
*
* @return Template[]
* @throws \Exception
*/
public function templates(): array
{
$response = $this->client->makeRequest(
'/templates',
HttpClient::METHOD_GET
);
$adapter = new ModelAdapter(Template::class);
return $adapter->getResponseList($response);
}
/**
* Send a template message
*
* @param string $templateId
* @param Model\Request\TemplateSendRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function templateSend(string $templateId, Model\Request\TemplateSendRequest $request): ModelInterface
{
$response = $this->client->makeRequest(
sprintf('/templates/%d/send', $templateId),
HttpClient::METHOD_POST,
$request
);
$adapter = new ModelAdapter(MessageSendResponse::class);
return $adapter->getResponseModel($response);
}
/**
@ -456,18 +508,20 @@ class Client
*
* @param Model\Request\UsersRequest $request Request parameters
*
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object
* @return array
* @throws \Exception
*/
public function users(Model\Request\UsersRequest $request)
public function users(Model\Request\UsersRequest $request): array
{
return $this->submitRequest(
$response = $this->client->makeRequest(
'/users',
HttpClient::METHOD_GET,
$request,
self::getEntityClass('User'),
true
$request
);
$adapter = new ModelAdapter(User::class);
return $adapter->getResponseList($response);
}
/**
@ -475,7 +529,7 @@ class Client
*
* @param string $url File URL
*
* @return \RetailCrm\Mg\Bot\Model\Response\UploadFileResponse|object
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception
*/
public function uploadFileByUrl(string $url)
@ -483,51 +537,54 @@ class Client
$request = new UploadFileByUrlRequest();
$request->setUrl($url);
return $this->submitRequest(
$response = $this->client->makeRequest(
'/files/upload_by_url',
HttpClient::METHOD_POST,
$request,
self::getResponseClass('UploadFileResponse')
$request
);
$adapter = new ModelAdapter(UploadFileResponse::class);
return $adapter->getResponseModel($response);
}
/**
* @param string $filename
* @return Model\Response\UploadFileResponse|null
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
*
* @throws \Exception
*/
public function uploadFile(string $filename)
{
$obj = new ErrorOnlyResponse();
$response = $this->client->postFile($filename);
if ($response instanceof ResponseInterface) {
$obj = Serializer::deserialize(
(string) $response->getBody(),
self::getResponseClass('UploadFileResponse')
UploadFileResponse::class
);
return $obj instanceof UploadFileResponse ? $obj : null;
}
return null;
return $obj;
}
/**
* @param string $fileId
* @return Model\Response\FullFileResponse|null
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
*
* @throws \Exception
*/
public function getFileById(string $fileId)
{
$obj = $this->submitRequest(
\sprintf('/files/%s', $fileId),
$response = $this->client->makeRequest(
sprintf('/files/%s', $fileId),
HttpClient::METHOD_GET,
null,
self::getResponseClass('FullFileResponse')
null
);
return ($obj instanceof FullFileResponse) ? $obj : null;
$adapter = new ModelAdapter(FullFileResponse::class);
return $adapter->getResponseModel($response);
}
}

View file

@ -1,39 +1,37 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* HttpClient
*
* @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 BadMethodCallException;
use ErrorException;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Utils;
use InvalidArgumentException;
use Psr\Http\Message\ResponseInterface;
use RetailCrm\Common\Exception\InvalidJsonException;
use RetailCrm\Common\Exception\LimitException;
use InvalidArgumentException;
use RetailCrm\Common\Exception\NotFoundException;
use RetailCrm\Common\Exception\UnauthorizedException;
use RetailCrm\Common\Serializer;
use RetailCrm\Common\Url;
use RuntimeException;
use Symfony\Component\Validator\Validation;
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use function GuzzleHttp\Psr7\stream_for;
/**
* PHP version 7.0
*
* HttpClient class
* Class HttpClient
*
* @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 HttpClient
{
@ -107,7 +105,7 @@ class HttpClient
* @param string $method Request method (default: 'GET')
* @param mixed $request Request model (default: null)
*
* @return ResponseInterface
* @return \Psr\Http\Message\ResponseInterface
* @throws \Exception
*/
public function makeRequest($path, $method, $request = null)
@ -121,21 +119,25 @@ class HttpClient
}
if ($method == self::METHOD_GET && !is_null($request)) {
$getParameters = Url::buildGetParameters(Serializer::serialize($request, Serializer::S_ARRAY));
$getParameters = Url::buildGetParameters((array)Serializer::serialize($request, Serializer::S_ARRAY));
}
$requestBody = is_null($request) ? null : Serializer::serialize($request, Serializer::S_JSON);
$requestBody = is_null($request) ? '' : Serializer::serialize($request, Serializer::S_JSON);
$request = new Request(
$method,
\sprintf("%s%s%s", $this->basePath, $path, $getParameters),
sprintf("%s%s%s", $this->basePath, $path, $getParameters),
[
'Content-Type' => 'application/json',
'X-Bot-Token' => $this->token
]
);
if (in_array($method, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE])) {
$request = $request->withBody(stream_for($requestBody));
if (in_array(
$method,
[self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE]
) && is_string($requestBody)
) {
$request = $request->withBody(Utils::streamFor($requestBody));
}
$responseObject = null;
@ -151,25 +153,10 @@ class HttpClient
]
);
} catch (GuzzleException $exception) {
throw new \Exception($exception->getMessage(), $exception->getCode(), $exception);
throw new Exception($exception->getMessage(), $exception->getCode(), $exception);
}
$statusCode = $responseObject->getStatusCode();
$response = self::parseJSON((string) $responseObject->getBody());
$errorMessage = !empty($response['errorMsg']) ? $response['errorMsg'] : '';
$errorMessage = !empty($response['errors']) ? $this->getErrors($response['errors']) : $errorMessage;
/**
* responses with 400 & 460 http codes contains extended error data
* therefore they are not handled as exceptions
*/
if (in_array($statusCode, [403, 404, 500])) {
throw new \InvalidArgumentException($errorMessage);
}
if ($statusCode == 503) {
throw new LimitException($errorMessage);
}
$this->validateResponse($responseObject);
return $responseObject;
}
@ -183,17 +170,17 @@ class HttpClient
public function postFile(string $filename)
{
if (!file_exists($filename)) {
throw new \InvalidArgumentException("File doesn't exist");
throw new InvalidArgumentException("File doesn't exist");
}
if (filesize($filename) == 0) {
throw new \InvalidArgumentException("Empty file provided");
throw new InvalidArgumentException("Empty file provided");
}
try {
$responseData = $this->client->request(
self::METHOD_POST,
\sprintf("%s/files/upload", $this->basePath),
sprintf("%s/files/upload", $this->basePath),
[
'headers' => [
'X-Bot-Token' => $this->token
@ -202,7 +189,7 @@ class HttpClient
]
);
} catch (GuzzleException $exception) {
throw new \Exception($exception->getMessage(), $exception->getCode(), $exception);
throw new Exception($exception->getMessage(), $exception->getCode(), $exception);
}
return isset($responseData) ? $responseData : null;
@ -229,25 +216,70 @@ class HttpClient
/**
* Validate given class
*
* @param string $class
* @param object $class
*
* @return void
*/
private function validateRequest($class)
private function validateRequest(object $class)
{
if (!is_string($class) && method_exists($class, 'validate')) {
$errors = $class->validate();
} else {
$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->getValidator();
$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->addDefaultDoctrineAnnotationReader()
->getValidator();
$errors = $validator->validate($class);
$errors = $validator->validate($class);
if ($errors->count() > 0) {
$message = '';
foreach ($errors as $error) {
$message .= $error->getMessage();
}
throw new InvalidArgumentException($message);
}
}
/**
* @param \Psr\Http\Message\ResponseInterface $responseObject
*
* @throws \ErrorException
* @throws \Exception
*/
private function validateResponse(ResponseInterface $responseObject)
{
$statusCode = $responseObject->getStatusCode();
$response = self::parseJSON((string)$responseObject->getBody());
$errorMessage = !empty($response['errorMsg']) ? $response['errorMsg'] : '';
$errorMessage = !empty($response['errors']) ? $this->getErrors($response['errors']) : $errorMessage;
if ($statusCode == 400) {
throw new RuntimeException($errorMessage);
}
if ((is_object($errors) && call_user_func([$errors, 'count']) > 0) || is_string($errors)) {
$message = (string) $errors;
throw new InvalidArgumentException($message);
if (in_array($statusCode, [401, 403])) {
throw new UnauthorizedException($errorMessage);
}
if ($statusCode == 404) {
throw new NotFoundException($errorMessage);
}
if (in_array($statusCode, [405, 501])) {
throw new BadMethodCallException($errorMessage);
}
if (in_array($statusCode, [500, 502])) {
throw new ErrorException($errorMessage);
}
if ($statusCode == 503) {
throw new LimitException($errorMessage);
}
if ($statusCode >= 400) {
throw new Exception($errorMessage);
}
}

View file

@ -1,27 +1,19 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Constants
*
* @package RetailCrm\Mg\Bot\Model
* @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;
/**
* PHP version 7.0
*
* Constants class
*
* @package RetailCrm\Mg\Bot\Model
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Constants
{
@ -46,6 +38,7 @@ class Constants
const BOT_ROLE_DISTRIBUTOR = "distributor";
const BOT_ROLE_RESPONSIBLE = "responsible";
const BOT_ROLE_HIDDEN = "hidden";
const MESSAGE_SCOPE_PUBLIC = "public";
const MESSAGE_SCOPE_PRIVATE = "private";

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Bot entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @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\Entity;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* Bot class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Bot
class Bot implements ModelInterface
{
/**
* @var string $id
@ -40,7 +33,7 @@ class Bot
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
* @SkipWhenEmpty()
*/
@ -49,7 +42,7 @@ class Bot
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
* @SkipWhenEmpty()
*/
@ -137,9 +130,9 @@ class Bot
private $isSystem;
/**
* @return string
* @return string|null
*/
public function getId(): string
public function getId(): ?string
{
return $this->id;
}
@ -155,7 +148,7 @@ class Bot
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
@ -171,7 +164,7 @@ class Bot
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
@ -185,9 +178,9 @@ class Bot
}
/**
* @return string
* @return string|null
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@ -201,9 +194,9 @@ class Bot
}
/**
* @return array
* @return array|null
*/
public function getEvents(): array
public function getEvents(): ?array
{
return $this->events;
}
@ -217,9 +210,9 @@ class Bot
}
/**
* @return string
* @return string|null
*/
public function getClientId(): string
public function getClientId(): ?string
{
return $this->clientId;
}
@ -233,9 +226,9 @@ class Bot
}
/**
* @return string
* @return string|null
*/
public function getAvatarUrl(): string
public function getAvatarUrl(): ?string
{
return $this->avatarUrl;
}
@ -249,9 +242,9 @@ class Bot
}
/**
* @return array
* @return array|null
*/
public function getRoles(): array
public function getRoles(): ?array
{
return $this->roles;
}
@ -265,9 +258,9 @@ class Bot
}
/**
* @return string
* @return string|null
*/
public function getDeactivatedAt(): string
public function getDeactivatedAt(): ?string
{
return $this->deactivatedAt;
}
@ -281,9 +274,9 @@ class Bot
}
/**
* @return bool
* @return bool|null
*/
public function isActive(): bool
public function isActive(): ?bool
{
return $this->isActive;
}
@ -297,9 +290,9 @@ class Bot
}
/**
* @return bool
* @return bool|null
*/
public function isSelf(): bool
public function isSelf(): ?bool
{
return $this->isSelf;
}
@ -313,9 +306,9 @@ class Bot
}
/**
* @return bool
* @return bool|null
*/
public function isSystem(): bool
public function isSystem(): ?bool
{
return $this->isSystem;
}

View file

@ -1,33 +1,26 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Channel entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use DateTime;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
* Class Channel
*
* Channel class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
*/
class Channel
class Channel implements ModelInterface
{
/**
* @var string $id
@ -40,7 +33,7 @@ class Channel
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
*/
private $createdAt;
@ -48,7 +41,7 @@ class Channel
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
*/
private $updatedAt;
@ -56,7 +49,7 @@ class Channel
/**
* @var \DateTime $activatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getActivatedAt",setter="setActivatedAt")
*/
private $activatedAt;
@ -64,7 +57,7 @@ class Channel
/**
* @var \DateTime $deactivatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getDeactivatedAt",setter="setDeactivatedAt")
*/
private $deactivatedAt;
@ -102,9 +95,9 @@ class Channel
private $name;
/**
* @return string
* @return string|null
*/
public function getId(): string
public function getId(): ?string
{
return $this->id;
}
@ -120,7 +113,7 @@ class Channel
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?DateTime
{
return $this->createdAt;
}
@ -128,7 +121,7 @@ class Channel
/**
* @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt)
public function setCreatedAt(DateTime $createdAt)
{
$this->createdAt = $createdAt;
}
@ -136,7 +129,7 @@ class Channel
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?DateTime
{
return $this->updatedAt;
}
@ -144,7 +137,7 @@ class Channel
/**
* @param \DateTime $updatedAt
*/
public function setUpdatedAt(\DateTime $updatedAt)
public function setUpdatedAt(DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
}
@ -152,7 +145,7 @@ class Channel
/**
* @return \DateTime
*/
public function getActivatedAt(): \DateTime
public function getActivatedAt(): ?DateTime
{
return $this->activatedAt;
}
@ -160,7 +153,7 @@ class Channel
/**
* @param \DateTime $activatedAt
*/
public function setActivatedAt(\DateTime $activatedAt)
public function setActivatedAt(DateTime $activatedAt)
{
$this->activatedAt = $activatedAt;
}
@ -168,7 +161,7 @@ class Channel
/**
* @return \DateTime
*/
public function getDeactivatedAt(): \DateTime
public function getDeactivatedAt(): ?DateTime
{
return $this->deactivatedAt;
}
@ -176,15 +169,15 @@ class Channel
/**
* @param \DateTime $deactivatedAt
*/
public function setDeactivatedAt(\DateTime $deactivatedAt)
public function setDeactivatedAt(DateTime $deactivatedAt)
{
$this->deactivatedAt = $deactivatedAt;
}
/**
* @return bool
* @return bool|null
*/
public function isActive(): bool
public function isActive(): ?bool
{
return $this->isActive;
}
@ -198,9 +191,9 @@ class Channel
}
/**
* @return ChannelSettings
* @return ChannelSettings|null
*/
public function getSettings(): ChannelSettings
public function getSettings(): ?ChannelSettings
{
return $this->settings;
}
@ -214,9 +207,9 @@ class Channel
}
/**
* @return string
* @return string|null
*/
public function getType(): string
public function getType(): ?string
{
return $this->type;
}
@ -230,9 +223,9 @@ class Channel
}
/**
* @return string
* @return string|null
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@ -240,7 +233,7 @@ class Channel
/**
* @param string $name
*/
public function setName(string $name)
public function setName($name)
{
$this->name = $name;
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* ChannelSettings entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @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\Entity\Channel;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* ChannelSettings class
* Class ChannelSettings
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ChannelSettings
class ChannelSettings implements ModelInterface
{
/**
* @var ChannelSettingsStatus $status
@ -91,9 +84,18 @@ class ChannelSettings
private $file;
/**
* @return ChannelSettingsStatus
* @var ChannelSettingsSuggestions $suggestions
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettingsSuggestions")
* @Accessor(getter="getSuggestions",setter="setSuggestions")
* @SkipWhenEmpty()
*/
public function getStatus(): ChannelSettingsStatus
private $suggestions;
/**
* @return ChannelSettingsStatus|null
*/
public function getStatus(): ?ChannelSettingsStatus
{
return $this->status;
}
@ -107,9 +109,9 @@ class ChannelSettings
}
/**
* @return bool
* @return bool|null
*/
public function isSpamAllowed(): bool
public function isSpamAllowed(): ?bool
{
return $this->spamAllowed;
}
@ -123,9 +125,9 @@ class ChannelSettings
}
/**
* @return ChannelSettingsItem
* @return ChannelSettingsItem|null
*/
public function getText(): ChannelSettingsItem
public function getText(): ?ChannelSettingsItem
{
return $this->text;
}
@ -139,9 +141,9 @@ class ChannelSettings
}
/**
* @return ChannelSettingsItem
* @return ChannelSettingsItem|null
*/
public function getProduct(): ChannelSettingsItem
public function getProduct(): ?ChannelSettingsItem
{
return $this->product;
}
@ -155,9 +157,9 @@ class ChannelSettings
}
/**
* @return ChannelSettingsItem
* @return ChannelSettingsItem|null
*/
public function getOrder(): ChannelSettingsItem
public function getOrder(): ?ChannelSettingsItem
{
return $this->order;
}
@ -171,9 +173,9 @@ class ChannelSettings
}
/**
* @return ChannelSettingsItem
* @return ChannelSettingsItem|null
*/
public function getImage(): ChannelSettingsItem
public function getImage(): ?ChannelSettingsItem
{
return $this->image;
}
@ -187,9 +189,9 @@ class ChannelSettings
}
/**
* @return ChannelSettingsItem
* @return ChannelSettingsItem|null
*/
public function getFile(): ChannelSettingsItem
public function getFile(): ?ChannelSettingsItem
{
return $this->file;
}
@ -201,4 +203,20 @@ class ChannelSettings
{
$this->file = $file;
}
/**
* @return ChannelSettingsSuggestions|null
*/
public function getSuggestions(): ?ChannelSettingsSuggestions
{
return $this->suggestions;
}
/**
* @param ChannelSettingsSuggestions $suggestions
*/
public function setSuggestions(ChannelSettingsSuggestions $suggestions): void
{
$this->suggestions = $suggestions;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* ChannelSettingsItem entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @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\Entity\Channel;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* ChannelSettingsItem class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ChannelSettingsItem
class ChannelSettingsItem implements ModelInterface
{
/**
* @var string $creating
@ -102,9 +95,9 @@ class ChannelSettingsItem
private $noteMaxCharsCount;
/**
* @return string
* @return string|null
*/
public function getCreating(): string
public function getCreating(): ?string
{
return $this->creating;
}
@ -118,9 +111,9 @@ class ChannelSettingsItem
}
/**
* @return string
* @return string|null
*/
public function getEditing(): string
public function getEditing(): ?string
{
return $this->editing;
}
@ -134,9 +127,9 @@ class ChannelSettingsItem
}
/**
* @return string
* @return string|null
*/
public function getQuoting(): string
public function getQuoting(): ?string
{
return $this->quoting;
}
@ -150,9 +143,9 @@ class ChannelSettingsItem
}
/**
* @return string
* @return string|null
*/
public function getDeleting(): string
public function getDeleting(): ?string
{
return $this->deleting;
}
@ -166,9 +159,9 @@ class ChannelSettingsItem
}
/**
* @return string
* @return string|null
*/
public function getDelivered(): string
public function getDelivered(): ?string
{
return $this->delivered;
}
@ -182,9 +175,9 @@ class ChannelSettingsItem
}
/**
* @return int
* @return int|null
*/
public function getMaxCharsCount(): int
public function getMaxCharsCount(): ?int
{
return $this->maxCharsCount;
}
@ -198,9 +191,9 @@ class ChannelSettingsItem
}
/**
* @return int
* @return int|null
*/
public function getMaxItemsCount(): int
public function getMaxItemsCount(): ?int
{
return $this->maxItemsCount;
}
@ -214,9 +207,9 @@ class ChannelSettingsItem
}
/**
* @return int
* @return int|null
*/
public function getNoteMaxCharsCount(): int
public function getNoteMaxCharsCount(): ?int
{
return $this->noteMaxCharsCount;
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* ChannelSettingsStatus entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @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\Entity\Channel;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* ChannelSettingsStatus class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ChannelSettingsStatus
class ChannelSettingsStatus implements ModelInterface
{
/**
* @var string $delivered
@ -48,9 +41,9 @@ class ChannelSettingsStatus
private $read;
/**
* @return string
* @return string|null
*/
public function getDelivered(): string
public function getDelivered(): ?string
{
return $this->delivered;
}
@ -64,9 +57,9 @@ class ChannelSettingsStatus
}
/**
* @return string
* @return string|null
*/
public function getRead(): string
public function getRead(): ?string
{
return $this->read;
}

View file

@ -0,0 +1,100 @@
<?php
/**
* PHP version 7.1
*
* ChannelSettingsSuggestions entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* ChannelSettingsSuggestions class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
*/
class ChannelSettingsSuggestions implements ModelInterface
{
/**
* @var string $email
*
* @Type("string")
* @Accessor(getter="getEmail", setter="setEmail")
* @SkipWhenEmpty()
*/
private $email;
/**
* @var string $phone
*
* @Type("string")
* @Accessor(getter="getPhone", setter="setPhone")
* @SkipWhenEmpty()
*/
private $phone;
/**
* @var string $text
*
*
* @Type("string")
* @Accessor(getter="getText", setter="setText")
* @SkipWhenEmpty()
*/
private $text;
/**
* @return string|null
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail(string $email): void
{
$this->email = $email;
}
/**
* @return string|null
*/
public function getPhone(): ?string
{
return $this->phone;
}
/**
* @param string $phone
*/
public function setPhone(string $phone): void
{
$this->phone = $phone;
}
/**
* @return string|null
*/
public function getText(): ?string
{
return $this->text;
}
/**
* @param string $text
*/
public function setText(string $text): void
{
$this->text = $text;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Chat entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @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\Entity\Chat;
@ -18,18 +15,14 @@ use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Customer;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* Chat class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Chat
class Chat implements ModelInterface
{
/**
* @var string $id
@ -42,7 +35,7 @@ class Chat
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
*/
private $createdAt;
@ -50,7 +43,7 @@ class Chat
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
*/
private $updatedAt;
@ -107,7 +100,7 @@ class Chat
/**
* @var ChatLastMessage $lastMessage
*
* @Type("ChatLastMessage")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Chat\ChatLastMessage")
* @Accessor(getter="getLastMessage",setter="setLastMessage")
*/
private $lastMessage;
@ -121,9 +114,17 @@ class Chat
private $lastActivity;
/**
* @return string
* @var \DateTime $replyDeadline
*
* @Type("DateTime<'Y-m-d\TH:i:sP'>")
* @Accessor(getter="getReplyDeadline",setter="setReplyDeadline")
*/
public function getId(): string
private $replyDeadline;
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
@ -139,7 +140,7 @@ class Chat
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
@ -155,7 +156,7 @@ class Chat
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
@ -169,9 +170,9 @@ class Chat
}
/**
* @return string
* @return string|null
*/
public function getAvatar(): string
public function getAvatar(): ?string
{
return $this->avatar;
}
@ -185,9 +186,9 @@ class Chat
}
/**
* @return string
* @return string|null
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@ -201,9 +202,9 @@ class Chat
}
/**
* @return Channel
* @return Channel|null
*/
public function getChannel(): Channel
public function getChannel(): ?Channel
{
return $this->channel;
}
@ -217,9 +218,9 @@ class Chat
}
/**
* @return array
* @return array|null
*/
public function getMembers(): array
public function getMembers(): ?array
{
return $this->members;
}
@ -233,9 +234,9 @@ class Chat
}
/**
* @return Customer
* @return Customer|null
*/
public function getCustomer(): Customer
public function getCustomer(): ?Customer
{
return $this->customer;
}
@ -249,9 +250,9 @@ class Chat
}
/**
* @return int
* @return int|null
*/
public function getAuthorId(): int
public function getAuthorId(): ?int
{
return $this->authorId;
}
@ -265,9 +266,9 @@ class Chat
}
/**
* @return ChatLastMessage
* @return ChatLastMessage|null
*/
public function getLastMessage(): ChatLastMessage
public function getLastMessage(): ?ChatLastMessage
{
return $this->lastMessage;
}
@ -283,7 +284,7 @@ class Chat
/**
* @return \DateTime
*/
public function getLastActivity(): \DateTime
public function getLastActivity(): ?\DateTime
{
return $this->lastActivity;
}
@ -295,4 +296,20 @@ class Chat
{
$this->lastActivity = $lastActivity;
}
/**
* @return \DateTime
*/
public function getReplyDeadline(): ?\DateTime
{
return $this->replyDeadline;
}
/**
* @param \DateTime $replyDeadline
*/
public function setReplyDeadline(\DateTime $replyDeadline): void
{
$this->replyDeadline = $replyDeadline;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* ChatLastMessage entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @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\Entity\Chat;
@ -16,18 +13,15 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Chat;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Customer;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* ChatLastMessage class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ChatLastMessage
class ChatLastMessage implements ModelInterface
{
/**
* @var int $creating
@ -41,7 +35,7 @@ class ChatLastMessage
/**
* @var \DateTime $time
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:sP'>")
* @Accessor(getter="getTime",setter="setTime")
* @SkipWhenEmpty()
*/
@ -57,9 +51,80 @@ class ChatLastMessage
private $type;
/**
* @return int
* @var string $scope
*
* @Type("string")
* @Accessor(getter="getScope",setter="setScope")
* @SkipWhenEmpty()
*/
public function getId(): int
private $scope;
/**
* @var int $chatId
*
* @Type("int")
* @Accessor(getter="getChatId",setter="setChatId")
* @SkipWhenEmpty()
*/
private $chatId;
/**
* @var bool $isRead
*
* @Type("bool")
* @Accessor(getter="getIsRead",setter="setIsRead")
* @SkipWhenEmpty()
*/
private $isRead;
/**
* @var bool $isEdit
*
* @Type("bool")
* @Accessor(getter="getIsEdit",setter="setIsEdit")
* @SkipWhenEmpty()
*/
private $isEdit;
/**
* @var string $status
*
* @Type("string")
* @Accessor(getter="getStatus",setter="setStatus")
* @SkipWhenEmpty()
*/
private $status;
/**
* @var Customer $from
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Customer")
* @Accessor(getter="getFrom",setter="setFrom")
*/
private $from;
/**
* @var string $content
*
* @Type("string")
* @Accessor(getter="getContent",setter="setContent")
* @SkipWhenEmpty()
*/
private $content;
/**
* @var \RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuote $quote
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuote")
* @Accessor(getter="getQuote",setter="setQuote")
* @SkipWhenEmpty()
*/
private $quote;
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
@ -75,7 +140,7 @@ class ChatLastMessage
/**
* @return \DateTime
*/
public function getTime(): \DateTime
public function getTime(): ?\DateTime
{
return $this->time;
}
@ -89,9 +154,9 @@ class ChatLastMessage
}
/**
* @return string
* @return string|null
*/
public function getType(): string
public function getType(): ?string
{
return $this->type;
}
@ -103,4 +168,132 @@ class ChatLastMessage
{
$this->type = $type;
}
/**
* @return mixed
*/
public function getScope()
{
return $this->scope;
}
/**
* @param mixed $scope
*/
public function setScope($scope): void
{
$this->scope = $scope;
}
/**
* @return mixed
*/
public function getChatId()
{
return $this->chatId;
}
/**
* @param mixed $chatId
*/
public function setChatId($chatId): void
{
$this->chatId = $chatId;
}
/**
* @return mixed
*/
public function getIsRead()
{
return $this->isRead;
}
/**
* @param mixed $isRead
*/
public function setIsRead($isRead): void
{
$this->isRead = $isRead;
}
/**
* @return mixed
*/
public function getIsEdit()
{
return $this->isEdit;
}
/**
* @param mixed $isEdit
*/
public function setIsEdit($isEdit): void
{
$this->isEdit = $isEdit;
}
/**
* @return mixed
*/
public function getStatus()
{
return $this->status;
}
/**
* @param mixed $status
*/
public function setStatus($status): void
{
$this->status = $status;
}
/**
* @return mixed
*/
public function getFrom()
{
return $this->from;
}
/**
* @param mixed $from
*/
public function setFrom($from): void
{
$this->from = $from;
}
/**
* @return mixed
*/
public function getContent()
{
return $this->content;
}
/**
* @param mixed $content
*/
public function setContent($content): void
{
$this->content = $content;
}
/**
* @return mixed
*/
public function getQuote()
{
return $this->quote;
}
/**
* @param mixed $quote
*/
public function setQuote($quote): void
{
$this->quote = $quote;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* ChatMember entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @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\Entity\Chat;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Chat;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* ChatMember class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ChatMember
class ChatMember implements ModelInterface
{
/**
* @var string $id
@ -40,7 +33,7 @@ class ChatMember
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
*/
private $createdAt;
@ -48,7 +41,7 @@ class ChatMember
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
* @SkipWhenEmpty()
*/
@ -91,9 +84,9 @@ class ChatMember
private $state;
/**
* @return string
* @return string|null
*/
public function getId(): string
public function getId(): ?string
{
return $this->id;
}
@ -109,7 +102,7 @@ class ChatMember
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
@ -125,7 +118,7 @@ class ChatMember
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
@ -139,9 +132,9 @@ class ChatMember
}
/**
* @return int
* @return int|null
*/
public function getChatId(): int
public function getChatId(): ?int
{
return $this->chatId;
}
@ -155,9 +148,9 @@ class ChatMember
}
/**
* @return int
* @return int|null
*/
public function getUserId(): int
public function getUserId(): ?int
{
return $this->userId;
}
@ -171,9 +164,9 @@ class ChatMember
}
/**
* @return bool
* @return bool|null
*/
public function isAuthor(): bool
public function isAuthor(): ?bool
{
return $this->isAuthor;
}
@ -187,9 +180,9 @@ class ChatMember
}
/**
* @return string
* @return string|null
*/
public function getState(): string
public function getState(): ?string
{
return $this->state;
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Command entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @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\Entity;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* Command class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Command
class Command implements ModelInterface
{
/**
* @var string $id
@ -40,7 +33,7 @@ class Command
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
*/
private $createdAt;
@ -48,7 +41,7 @@ class Command
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
* @SkipWhenEmpty()
*/
@ -73,9 +66,9 @@ class Command
private $description;
/**
* @return string
* @return string|null
*/
public function getId(): string
public function getId(): ?string
{
return $this->id;
}
@ -91,7 +84,7 @@ class Command
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
@ -107,7 +100,7 @@ class Command
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
@ -121,9 +114,9 @@ class Command
}
/**
* @return string
* @return string|null
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@ -137,9 +130,9 @@ class Command
}
/**
* @return string
* @return string|null
*/
public function getDescription(): string
public function getDescription(): ?string
{
return $this->description;
}

View file

@ -1,35 +1,27 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Customer entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @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\Entity;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Customer class
* | email | string |
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Customer
class Customer implements ModelInterface
{
/**
* @var string $id
@ -42,7 +34,7 @@ class Customer
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
*/
private $createdAt;
@ -50,7 +42,7 @@ class Customer
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
* @SkipWhenEmpty()
*/
@ -176,9 +168,18 @@ class Customer
private $email;
/**
* @return string
* @var Utm $utm
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Utm")
* @Accessor(getter="getUtm",setter="setUtm")
* @SkipWhenEmpty()
*/
public function getId(): string
private $utm;
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
@ -194,7 +195,7 @@ class Customer
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
@ -210,7 +211,7 @@ class Customer
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
@ -224,9 +225,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getExternalId(): string
public function getExternalId(): ?string
{
return $this->externalId;
}
@ -240,9 +241,9 @@ class Customer
}
/**
* @return int
* @return int|null
*/
public function getChannelId(): int
public function getChannelId(): ?int
{
return $this->channelId;
}
@ -256,9 +257,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getUsername(): string
public function getUsername(): ?string
{
return $this->username;
}
@ -272,9 +273,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getFirstName(): string
public function getFirstName(): ?string
{
return $this->firstName;
}
@ -288,9 +289,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getLastName(): string
public function getLastName(): ?string
{
return $this->lastName;
}
@ -304,9 +305,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getAvatarUrl(): string
public function getAvatarUrl(): ?string
{
return $this->avatarUrl;
}
@ -320,9 +321,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getProfileUrl(): string
public function getProfileUrl(): ?string
{
return $this->profileUrl;
}
@ -336,9 +337,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getRevokedAt(): string
public function getRevokedAt(): ?string
{
return $this->revokedAt;
}
@ -352,9 +353,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getCountry(): string
public function getCountry(): ?string
{
return $this->country;
}
@ -368,9 +369,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getLanguage(): string
public function getLanguage(): ?string
{
return $this->language;
}
@ -384,9 +385,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getPhone(): string
public function getPhone(): ?string
{
return $this->phone;
}
@ -400,9 +401,9 @@ class Customer
}
/**
* @return string
* @return string|null
*/
public function getEmail(): string
public function getEmail(): ?string
{
return $this->email;
}
@ -414,4 +415,21 @@ class Customer
{
$this->email = $email;
}
/**
* @return Utm|null
*/
public function getUtm(): ?Utm
{
return $this->utm;
}
/**
* @param Utm $utm
* @return void
*/
public function setUtm(Utm $utm): void
{
$this->utm = $utm;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Dialog entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @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\Entity;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* Dialog class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Dialog
class Dialog implements ModelInterface
{
/**
* @var string $id
@ -40,7 +33,7 @@ class Dialog
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
*/
private $createdAt;
@ -48,7 +41,7 @@ class Dialog
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
* @SkipWhenEmpty()
*/
@ -93,7 +86,7 @@ class Dialog
/**
* @var \DateTime $closedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getClosedAt",setter="setClosedAt")
* @SkipWhenEmpty()
*/
@ -127,9 +120,9 @@ class Dialog
private $isActive;
/**
* @return string
* @return string|null
*/
public function getId(): string
public function getId(): ?string
{
return $this->id;
}
@ -145,7 +138,7 @@ class Dialog
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
@ -161,7 +154,7 @@ class Dialog
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
@ -175,9 +168,9 @@ class Dialog
}
/**
* @return int
* @return int|null
*/
public function getBotId(): int
public function getBotId(): ?int
{
return $this->botId;
}
@ -191,9 +184,9 @@ class Dialog
}
/**
* @return int
* @return int|null
*/
public function getChatId(): int
public function getChatId(): ?int
{
return $this->chatId;
}
@ -207,9 +200,9 @@ class Dialog
}
/**
* @return int
* @return int|null
*/
public function getBeginMessageId(): int
public function getBeginMessageId(): ?int
{
return $this->beginMessageId;
}
@ -223,9 +216,9 @@ class Dialog
}
/**
* @return int
* @return int|null
*/
public function getEndingMessageId(): int
public function getEndingMessageId(): ?int
{
return $this->endingMessageId;
}
@ -241,7 +234,7 @@ class Dialog
/**
* @return \DateTime
*/
public function getClosedAt(): \DateTime
public function getClosedAt(): ?\DateTime
{
return $this->closedAt;
}
@ -255,9 +248,9 @@ class Dialog
}
/**
* @return bool
* @return bool|null
*/
public function isAssigned(): bool
public function isAssigned(): ?bool
{
return $this->isAssigned;
}
@ -271,9 +264,9 @@ class Dialog
}
/**
* @return Responsible
* @return Responsible|null
*/
public function getResponsible(): Responsible
public function getResponsible(): ?Responsible
{
return $this->responsible;
}
@ -287,9 +280,9 @@ class Dialog
}
/**
* @return bool
* @return bool|null
*/
public function isActive(): bool
public function isActive(): ?bool
{
return $this->isActive;
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* FileMeta entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @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\Entity;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* FileMeta class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class FileMeta
class FileMeta implements ModelInterface
{
/**
* @var int $height
@ -48,9 +41,9 @@ class FileMeta
private $width;
/**
* @return int
* @return int|null
*/
public function getHeight(): int
public function getHeight(): ?int
{
return $this->height;
}
@ -64,9 +57,9 @@ class FileMeta
}
/**
* @return int
* @return int|null
*/
public function getWidth(): int
public function getWidth(): ?int
{
return $this->width;
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Item entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* Item class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Item
class Item implements ModelInterface
{
/**
* @var string $id
@ -57,9 +50,18 @@ class Item
private $caption;
/**
* @return string
* @var string $transcription
*
* @Type("string")
* @Accessor(getter="getTranscription",setter="setTranscription")
* @SkipWhenEmpty()
*/
public function getId()
private $transcription;
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
@ -73,9 +75,9 @@ class Item
}
/**
* @return int
* @return int|null
*/
public function getSize(): int
public function getSize(): ?int
{
return $this->size;
}
@ -89,7 +91,7 @@ class Item
}
/**
* @return string
* @return string|null
*/
public function getCaption()
{
@ -103,4 +105,20 @@ class Item
{
$this->caption = $caption;
}
/**
* @return string|null
*/
public function getTranscription(): ?string
{
return $this->transcription;
}
/**
* @param string $transcription
*/
public function setTranscription(string $transcription): void
{
$this->transcription = $transcription;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Message entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
@ -18,18 +15,14 @@ use RetailCrm\Mg\Bot\Model\Entity\User;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* Message class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Message
class Message implements ModelInterface
{
/**
* @var string $id
@ -42,7 +35,7 @@ class Message
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
*/
private $createdAt;
@ -50,7 +43,7 @@ class Message
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
* @SkipWhenEmpty()
*/
@ -128,11 +121,28 @@ class Message
*/
private $content;
/**
* @var string $note
*
* @Type("string")
* @Accessor(getter="getNote",setter="setNote")
* @SkipWhenEmpty()
*/
private $note;
/**
* @var ?Quote $quote
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\Quote")
* @SkipWhenEmpty()
*/
private $quote;
/**
* @var bool $isRead
*
* @Type("bool")
* @Accessor(getter="getIsRead",setter="setIsRead")
* @Accessor(getter="isRead",setter="setIsRead")
* @SkipWhenEmpty()
*/
private $isRead;
@ -141,7 +151,7 @@ class Message
* @var bool $isEdit
*
* @Type("bool")
* @Accessor(getter="getIsEdit",setter="setIsEdit")
* @Accessor(getter="isEdit",setter="setIsEdit")
* @SkipWhenEmpty()
*/
private $isEdit;
@ -167,7 +177,7 @@ class Message
/**
* @var Dialog $dialog
*
* @Type("Dialog")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Dialog")
* @Accessor(getter="getDialog",setter="setDialog")
* @SkipWhenEmpty()
*/
@ -185,7 +195,7 @@ class Message
/**
* @var \DateTime $channelSentAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getChannelSentAt",setter="setChannelSentAt")
* @SkipWhenEmpty()
*/
@ -194,7 +204,7 @@ class Message
/**
* @var MessageOrder $order
*
* @Type("MessageOrder")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder")
* @Accessor(getter="getOrder",setter="setOrder")
* @SkipWhenEmpty()
*/
@ -203,16 +213,16 @@ class Message
/**
* @var MessageProduct $product
*
* @Type("MessageProduct")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct")
* @Accessor(getter="getProduct",setter="setProduct")
* @SkipWhenEmpty()
*/
private $product;
/**
* @return string
* @return string|null
*/
public function getId(): string
public function getId(): ?string
{
return $this->id;
}
@ -228,7 +238,7 @@ class Message
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
@ -244,7 +254,7 @@ class Message
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
@ -258,9 +268,9 @@ class Message
}
/**
* @return string
* @return string|null
*/
public function getActions(): string
public function getActions(): ?string
{
return $this->actions;
}
@ -274,9 +284,9 @@ class Message
}
/**
* @return array
* @return array|null
*/
public function getItems(): array
public function getItems(): ?array
{
return $this->items;
}
@ -290,9 +300,9 @@ class Message
}
/**
* @return User
* @return User|null
*/
public function getFrom(): User
public function getFrom(): ?User
{
return $this->from;
}
@ -308,7 +318,7 @@ class Message
/**
* @return \DateTime
*/
public function getTime(): \DateTime
public function getTime(): ?\DateTime
{
return $this->time;
}
@ -322,9 +332,9 @@ class Message
}
/**
* @return string
* @return string|null
*/
public function getType(): string
public function getType(): ?string
{
return $this->type;
}
@ -338,9 +348,9 @@ class Message
}
/**
* @return string
* @return string|null
*/
public function getScope(): string
public function getScope(): ?string
{
return $this->scope;
}
@ -354,9 +364,9 @@ class Message
}
/**
* @return int
* @return int|null
*/
public function getChatId(): int
public function getChatId(): ?int
{
return $this->chatId;
}
@ -370,9 +380,9 @@ class Message
}
/**
* @return string
* @return string|null
*/
public function getContent(): string
public function getContent(): ?string
{
return $this->content;
}
@ -386,9 +396,37 @@ class Message
}
/**
* @return bool
* @return string|null
*/
public function isRead(): bool
public function getNote(): ?string
{
return $this->note;
}
/**
* @param string $note
*/
public function setNote(string $note): void
{
$this->note = $note;
}
public function getQuote(): ?Quote
{
return $this->quote ?? null;
}
public function setQuote(?Quote $quote): Message
{
$this->quote = $quote;
return $this;
}
/**
* @return bool|null
*/
public function isRead(): ?bool
{
return $this->isRead;
}
@ -402,9 +440,9 @@ class Message
}
/**
* @return bool
* @return bool|null
*/
public function isEdit(): bool
public function isEdit(): ?bool
{
return $this->isEdit;
}
@ -418,9 +456,9 @@ class Message
}
/**
* @return string
* @return string|null
*/
public function getStatus(): string
public function getStatus(): ?string
{
return $this->status;
}
@ -434,9 +472,9 @@ class Message
}
/**
* @return string
* @return string|null
*/
public function getAction(): string
public function getAction(): ?string
{
return $this->action;
}
@ -450,9 +488,9 @@ class Message
}
/**
* @return Dialog
* @return Dialog|null
*/
public function getDialog(): Dialog
public function getDialog(): ?Dialog
{
return $this->dialog;
}
@ -466,9 +504,9 @@ class Message
}
/**
* @return int
* @return int|null
*/
public function getChannelId(): int
public function getChannelId(): ?int
{
return $this->channelId;
}
@ -484,7 +522,7 @@ class Message
/**
* @return \DateTime
*/
public function getChannelSentAt(): \DateTime
public function getChannelSentAt(): ?\DateTime
{
return $this->channelSentAt;
}
@ -498,9 +536,9 @@ class Message
}
/**
* @return MessageOrder
* @return MessageOrder|null
*/
public function getOrder(): MessageOrder
public function getOrder(): ?MessageOrder
{
return $this->order;
}
@ -514,9 +552,9 @@ class Message
}
/**
* @return MessageProduct
* @return MessageProduct|null
*/
public function getProduct(): MessageProduct
public function getProduct(): ?MessageProduct
{
return $this->product;
}

View file

@ -1,33 +1,27 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessageCost entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageCost class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessageCost
class MessageCost implements ModelInterface
{
/**
* @var float $value
@ -49,7 +43,7 @@ class MessageCost
private $currency;
/**
* @return float
* @return float|null
*/
public function getValue()
{
@ -65,7 +59,7 @@ class MessageCost
}
/**
* @return string
* @return string|null
*/
public function getCurrency()
{

View file

@ -1,34 +1,27 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessageDelivery entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageDelivery class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessageDelivery
class MessageDelivery implements ModelInterface
{
/**
* @var string $name
@ -43,7 +36,7 @@ class MessageDelivery
/**
* @var MessageCost $price
*
* @Type("Cost")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getPrice",setter="setPrice")
*
* @Assert\Currency
@ -69,7 +62,7 @@ class MessageDelivery
private $comment;
/**
* @return string
* @return string|null
*/
public function getName()
{
@ -85,7 +78,7 @@ class MessageDelivery
}
/**
* @return MessageCost
* @return MessageCost|null
*/
public function getPrice()
{
@ -101,7 +94,7 @@ class MessageDelivery
}
/**
* @return string
* @return string|null
*/
public function getAddress()
{
@ -117,7 +110,7 @@ class MessageDelivery
}
/**
* @return string
* @return string|null
*/
public function getComment()
{

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessageOrder entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageOrder class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessageOrder
class MessageOrder implements ModelInterface
{
/**
* @var string $number
@ -59,7 +52,7 @@ class MessageOrder
/**
* @var MessageCost $cost
*
* @Type("MessageCost")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getCost",setter="setCost")
* @SkipWhenEmpty()
*/
@ -68,7 +61,7 @@ class MessageOrder
/**
* @var MessageStatus $status
*
* @Type("MessageStatus")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageStatus")
* @Accessor(getter="getStatus",setter="setStatus")
* @SkipWhenEmpty()
*/
@ -77,7 +70,7 @@ class MessageOrder
/**
* @var MessageDelivery $delivery
*
* @Type("MessageDelivery")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageDelivery")
* @Accessor(getter="getDelivery",setter="setDelivery")
* @SkipWhenEmpty()
*/
@ -102,7 +95,7 @@ class MessageOrder
private $payments;
/**
* @return string
* @return string|null
*/
public function getNumber()
{
@ -118,7 +111,7 @@ class MessageOrder
}
/**
* @return string
* @return string|null
*/
public function getUrl()
{
@ -134,7 +127,7 @@ class MessageOrder
}
/**
* @return string
* @return string|null
*/
public function getDate()
{
@ -150,7 +143,7 @@ class MessageOrder
}
/**
* @return MessageCost
* @return MessageCost|null
*/
public function getCost()
{
@ -166,7 +159,7 @@ class MessageOrder
}
/**
* @return MessageStatus
* @return MessageStatus|null
*/
public function getStatus()
{
@ -182,7 +175,7 @@ class MessageOrder
}
/**
* @return MessageDelivery
* @return MessageDelivery|null
*/
public function getDelivery()
{
@ -198,7 +191,7 @@ class MessageOrder
}
/**
* @return array
* @return array|null
*/
public function getItems()
{
@ -214,7 +207,7 @@ class MessageOrder
}
/**
* @return array
* @return array|null
*/
public function getPayments()
{

View file

@ -1,14 +1,9 @@
<?php
/**
* PHP version 7.0.
* PHP version 7.1
*
* MessageOrderItem entity
*
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
*
* @see http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Message;
@ -16,18 +11,12 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0.
*
* MessageOrderItem class
*
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
*
* @see http://help.retailcrm.pro/docs/Developers
*/
class MessageOrderItem
class MessageOrderItem implements ModelInterface
{
/**
* @var string
@ -59,7 +48,7 @@ class MessageOrderItem
/**
* @var MessageCost
*
* @Type("MessageCost")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getPrice",setter="setPrice")
* @SkipWhenEmpty()
*/
@ -68,14 +57,14 @@ class MessageOrderItem
/**
* @var MessageQuantity
*
* @Type("MessageQuantity")
* @Accessor(getter="getQuantity",setter="setQuantity)
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuantity")
* @Accessor(getter="getQuantity",setter="setQuantity")
* @SkipWhenEmpty()
*/
private $quantity;
/**
* @return string
* @return string|null
*/
public function getName()
{
@ -91,7 +80,7 @@ class MessageOrderItem
}
/**
* @return string
* @return string|null
*/
public function getUrl()
{
@ -107,7 +96,7 @@ class MessageOrderItem
}
/**
* @return string
* @return string|null
*/
public function getImg()
{
@ -123,7 +112,7 @@ class MessageOrderItem
}
/**
* @return MessageCost
* @return MessageCost|null
*/
public function getPrice()
{
@ -139,7 +128,7 @@ class MessageOrderItem
}
/**
* @return MessageQuantity
* @return MessageQuantity|null
*/
public function getQuantity()
{

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessageOrderPaymentStatus entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageOrderPaymentStatus class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessageOrderPaymentStatus
class MessageOrderPaymentStatus implements ModelInterface
{
/**
* @var string $name
@ -48,9 +41,9 @@ class MessageOrderPaymentStatus
private $payed;
/**
* @return string
* @return string|null
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@ -64,9 +57,9 @@ class MessageOrderPaymentStatus
}
/**
* @return bool
* @return bool|null
*/
public function getPayed(): bool
public function getPayed(): ?bool
{
return $this->payed;
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessagePayment entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessagePayment class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessagePayment
class MessagePayment implements ModelInterface
{
/**
* @var string $name
@ -41,7 +34,7 @@ class MessagePayment
/**
* @var MessageOrderPaymentStatus $status
*
* @Type("MessageOrderPaymentStatus")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrderPaymentStatus")
* @Accessor(getter="getStatus",setter="setStatus")
* @SkipWhenEmpty()
*/
@ -50,14 +43,14 @@ class MessagePayment
/**
* @var MessageCost $amount
*
* @Type("MessageCost")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getAmount",setter="setAmount")
* @SkipWhenEmpty()
*/
private $amount;
/**
* @return string
* @return string|null
*/
public function getName()
{
@ -73,7 +66,7 @@ class MessagePayment
}
/**
* @return MessageOrderPaymentStatus
* @return MessageOrderPaymentStatus|null
*/
public function getStatus()
{
@ -89,7 +82,7 @@ class MessagePayment
}
/**
* @return MessageCost
* @return MessageCost|null
*/
public function getAmount()
{

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessageProduct entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageProduct class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessageProduct
class MessageProduct implements ModelInterface
{
/**
* @var int $id
@ -77,7 +70,7 @@ class MessageProduct
/**
* @var MessageCost $cost
*
* @Type("Cost")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getCost",setter="setCost")
* @SkipWhenEmpty()
*/
@ -86,16 +79,16 @@ class MessageProduct
/**
* @var MessageQuantity $quantity
*
* @Type("MessageQuantity")
* @Accessor(getter="getQuantity",setter="setQuantity)
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuantity")
* @Accessor(getter="getQuantity",setter="setQuantity")
* @SkipWhenEmpty()
*/
private $quantity;
/**
* @return int
* @return int|null
*/
public function getId(): int
public function getId(): ?int
{
return $this->id;
}
@ -109,9 +102,9 @@ class MessageProduct
}
/**
* @return string
* @return string|null
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@ -125,9 +118,9 @@ class MessageProduct
}
/**
* @return string
* @return string|null
*/
public function getArticle(): string
public function getArticle(): ?string
{
return $this->article;
}
@ -141,9 +134,9 @@ class MessageProduct
}
/**
* @return string
* @return string|null
*/
public function getUrl(): string
public function getUrl(): ?string
{
return $this->url;
}
@ -157,9 +150,9 @@ class MessageProduct
}
/**
* @return string
* @return string|null
*/
public function getImg(): string
public function getImg(): ?string
{
return $this->img;
}
@ -173,9 +166,9 @@ class MessageProduct
}
/**
* @return MessageCost
* @return MessageCost|null
*/
public function getCost(): MessageCost
public function getCost(): ?MessageCost
{
return $this->cost;
}
@ -189,9 +182,9 @@ class MessageProduct
}
/**
* @return MessageQuantity
* @return MessageQuantity|null
*/
public function getQuantity(): MessageQuantity
public function getQuantity(): ?MessageQuantity
{
return $this->quantity;
}

View file

@ -1,33 +1,27 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessageQuantity entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageQuantity class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessageQuantity
class MessageQuantity implements ModelInterface
{
/**
* @var float $value
@ -49,7 +43,7 @@ class MessageQuantity
private $unit;
/**
* @return float
* @return float|null
*/
public function getValue()
{
@ -65,7 +59,7 @@ class MessageQuantity
}
/**
* @return string
* @return string|null
*/
public function getUnit()
{

View file

@ -0,0 +1,172 @@
<?php
/**
* PHP version 7.3
*
* @category MessageQuote
* @package RetailCrm\Mg\Bot\Model\Entity\Message
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\User;
/**
* Class MessageQuote
*
* @category MessageQuote
* @package RetailCrm\Mg\Bot\Model\Entity\Message
*/
class MessageQuote
{
/**
* @var int $id
*
* @Type("int")
* @Accessor(getter="getId",setter="setId")
* @SkipWhenEmpty()
*/
private $id;
/**
* @var string $type
*
* @Type("string")
* @Accessor(getter="getType",setter="setType")
* @SkipWhenEmpty()
*/
private $type;
/**
* @var User $from
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\User")
* @Accessor(getter="getFrom",setter="setFrom")
* @SkipWhenEmpty()
*/
private $from;
/**
* @var \DateTime $time
*
* @Type("DateTime<'Y-m-d\TH:i:sP'>")
* @Accessor(getter="getTime",setter="setTime")
*/
private $time;
/**
* @var string $content
*
* @Type("string")
* @Accessor(getter="getContent",setter="setContent")
*/
private $content;
/**
* @var object[] $items
*
* @Type("array")
* @Accessor(getter="getItems",setter="setItems")
* @SkipWhenEmpty()
*/
private $items;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return string|null
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type): void
{
$this->type = $type;
}
/**
* @return User|null
*/
public function getFrom(): ?User
{
return $this->from;
}
/**
* @param User $from
*/
public function setFrom(User $from): void
{
$this->from = $from;
}
/**
* @return \DateTime
*/
public function getTime(): ?\DateTime
{
return $this->time;
}
/**
* @param \DateTime $time
*/
public function setTime(\DateTime $time): void
{
$this->time = $time;
}
/**
* @return string
*/
public function getContent(): string
{
return $this->content;
}
/**
* @param string $content
*/
public function setContent(string $content): void
{
$this->content = $content;
}
/**
* @return object[]|null
*/
public function getItems(): ?array
{
return $this->items;
}
/**
* @param object[] $items
*/
public function setItems(array $items): void
{
$this->items = $items;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessageStatus entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Entity\Message;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageStatus class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessageStatus
class MessageStatus implements ModelInterface
{
/**
* @var string $code
@ -48,9 +41,9 @@ class MessageStatus
private $name;
/**
* @return string
* @return string|null
*/
public function getCode(): string
public function getCode(): ?string
{
return $this->code;
}
@ -64,9 +57,9 @@ class MessageStatus
}
/**
* @return string
* @return string|null
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}

View file

@ -0,0 +1,106 @@
<?php
namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use DateTime;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\User;
use RetailCrm\Mg\Bot\Model\ModelInterface;
class Quote implements ModelInterface
{
/**
* @var int
*
* @Type("integer")
*/
private $id;
/**
* @var string
*
* @Type("string")
*/
private $type;
/**
* @var User
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\User")
*/
private $from;
/**
* @var DateTime $time
*
* @Type("DateTime<'Y-m-d\TH:i:sP'>")
* @Accessor(getter="getTime",setter="setTime")
* @SkipWhenEmpty()
*/
private $time;
/**
* @var string
*
* @Type("string")
*/
private $content;
public function getId(): int
{
return $this->id;
}
public function setId(int $id): Quote
{
$this->id = $id;
return $this;
}
public function getType(): string
{
return $this->type;
}
public function setType(string $type): Quote
{
$this->type = $type;
return $this;
}
public function getFrom(): User
{
return $this->from;
}
public function setFrom(User $from): Quote
{
$this->from = $from;
return $this;
}
public function getTime(): DateTime
{
return $this->time;
}
public function setTime(DateTime $time): Quote
{
$this->time = $time;
return $this;
}
public function getContent(): string
{
return $this->content;
}
public function setContent(string $content): Quote
{
$this->content = $content;
return $this;
}
}

View file

@ -0,0 +1,74 @@
<?php
/**
* PHP version 7.1
*
* Suggestion entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* Suggestion class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
*/
class Suggestion implements ModelInterface
{
/**
* @var string $title
*
* @Type("string")
* @Accessor(getter="getTitle",setter="setTitle")
* @SkipWhenEmpty()
*/
private $title;
/**
* @var string $type
*
* @Type("string")
* @Accessor(getter="getType",setter="setType")
* @SkipWhenEmpty()
*/
private $type;
/**
* @return string|null
*/
public function getTitle(): ?string
{
return $this->title;
}
/**
* @param string $title
*/
public function setTitle(string $title)
{
$this->title = $title;
}
/**
* @return string|null
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type)
{
$this->type = $type;
}
}

View file

@ -0,0 +1,50 @@
<?php
/**
* PHP version 7.1
*
* TransportAttachments entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* TransportAttachments class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
*/
class TransportAttachments implements ModelInterface
{
/**
* @var array $suggestions
*
* @Type("array")
* @Accessor(getter="getSuggestions",setter="setSuggestions")
* @SkipWhenEmpty()
*/
private $suggestions;
/**
* @param array $suggestions
*/
public function setSuggestions(array $suggestions): void
{
$this->suggestions = $suggestions;
}
/**
* @return array
*/
public function getSuggestions(): array
{
return $this->suggestions;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Responsible entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @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\Entity;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* Responsible class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Responsible
class Responsible implements ModelInterface
{
/**
* @var string $assignedAt
@ -57,9 +50,18 @@ class Responsible
private $type;
/**
* @return string
* @var string $externalId
*
* @Type("string")
* @Accessor(getter="getExternalId",setter="setExternalId")
* @SkipWhenEmpty()
*/
public function getAssignedAt(): string
private $externalId;
/**
* @return string|null
*/
public function getAssignedAt(): ?string
{
return $this->assignedAt;
}
@ -73,9 +75,9 @@ class Responsible
}
/**
* @return int
* @return int|null
*/
public function getId(): int
public function getId(): ?int
{
return $this->id;
}
@ -89,9 +91,9 @@ class Responsible
}
/**
* @return string
* @return string|null
*/
public function getType(): string
public function getType(): ?string
{
return $this->type;
}
@ -103,4 +105,20 @@ class Responsible
{
$this->type = $type;
}
/**
* @return string|null
*/
public function getExternalId(): ?string
{
return $this->externalId;
}
/**
* @param string $externalId
*/
public function setExternalId(string $externalId): void
{
$this->externalId = $externalId;
}
}

View file

@ -0,0 +1,78 @@
<?php
/**
* PHP version 7.1
*
* Tag entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Tag class
*
* @package RetailCrm\Mg\Bot\Model\Entity
*/
class Tag implements ModelInterface
{
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
*
* @Assert\NotBlank
*/
private $name;
/**
* @var string $colorCode
*
* @Type("string")
* @Accessor(getter="getColorCode",setter="setColorCode")
* @SkipWhenEmpty()
*/
private $colorCode;
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return void
*/
public function setName(string $name): void
{
$this->name = $name;
}
/**
* @return string|null
*/
public function getColorCode(): ?string
{
return $this->colorCode;
}
/**
* @param string $colorCode
* @return void
*/
public function setColorCode(string $colorCode): void
{
$this->colorCode = $colorCode;
}
}

View file

@ -0,0 +1,385 @@
<?php
/**
* PHP version 7.1
*
* Template entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Template
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Template;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* Template class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Template
*/
class Template implements ModelInterface
{
/**
* @var int $id
*
* @Type("int")
* @Accessor(getter="getId",setter="setId")
*/
private $id;
/**
* @var string $code
*
* @Type("string")
* @Accessor(getter="getCode",setter="setCode")
*/
private $code;
/**
* @var int $channelId
*
* @Type("int")
* @Accessor(getter="getChannelId",setter="setChannelId")
*/
private $channelId;
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
*/
private $name;
/**
* @var bool $enabled
*
* @Type("bool")
* @Accessor(getter="getEnabled",setter="setEnabled")
*/
private $enabled;
/**
* @var string $type
*
* @Type("string")
* @Accessor(getter="getType",setter="setType")
*/
private $type;
/**
* @var array<string, string> $template
*
* @Type("array")
* @Accessor(getter="getTemplate",setter="setTemplate")
*/
private $template;
/**
* @var string $body
*
* @Type("string")
* @Accessor(getter="getBody",setter="setBody")
*/
private $body;
/**
* @var string $lang
*
* @Type("string")
* @Accessor(getter="getLang",setter="setLang")
*/
private $lang;
/**
* @var string $category
*
* @Type("string")
* @Accessor(getter="getCategory",setter="setCategory")
*/
private $category;
/**
* @var string $verificationStatus
*
* @Type("string")
* @Accessor(getter="getVerificationStatus",setter="setVerificationStatus")
*/
private $verificationStatus;
/**
* @var string $rejectionReason
*
* @Type("string")
* @Accessor(getter="getRejectionReason",setter="setRejectionReason")
*/
private $rejectionReason;
/**
* @var string $quality
*
* @Type("string")
* @Accessor(getter="getQuality",setter="setQuality")
* @SkipWhenEmpty()
*/
private $quality;
/**
* @var array<string, string> $header
*
* @Type("array")
* @Accessor(getter="getHeader",setter="setHeader")
* @SkipWhenEmpty()
*/
private $header;
/**
* @var array<string, array<string, string>> $buttons
*
* @Type("array")
* @Accessor(getter="getButtons",setter="setButtons")
* @SkipWhenEmpty()
*/
private $buttons;
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return string|null
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* @param string $code
*/
public function setCode(string $code): void
{
$this->code = $code;
}
/**
* @return int|null
*/
public function getChannelId(): ?int
{
return $this->channelId;
}
/**
* @param int $channelId
*/
public function setChannelId(int $channelId): void
{
$this->channelId = $channelId;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $name;
}
/**
* @return bool|null
*/
public function getEnabled(): ?bool
{
return $this->enabled;
}
/**
* @param bool $enabled
*/
public function setEnabled(bool $enabled): void
{
$this->enabled = $enabled;
}
/**
* @return string|null
*/
public function getType(): ?string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type): void
{
$this->type = $type;
}
/**
* @return array<string, string>|null
*/
public function getTemplate(): ?array
{
return $this->template;
}
/**
* @param array<string, string> $template
*/
public function setTemplate(array $template): void
{
$this->template = $template;
}
/**
* @return string|null
*/
public function getBody(): ?string
{
return $this->body;
}
/**
* @param string $body
*/
public function setBody(string $body): void
{
$this->body = $body;
}
/**
* @return string|null
*/
public function getVerificationStatus(): ?string
{
return $this->verificationStatus;
}
/**
* @param string $verificationStatus
*/
public function setVerificationStatus(string $verificationStatus): void
{
$this->verificationStatus = $verificationStatus;
}
/**
* @return string|null
*/
public function getLang(): ?string
{
return $this->lang;
}
/**
* @param string $lang
*/
public function setLang(string $lang): void
{
$this->lang = $lang;
}
/**
* @return string|null
*/
public function getCategory(): ?string
{
return $this->category;
}
/**
* @param string $category
*/
public function setCategory(string $category): void
{
$this->category = $category;
}
/**
* @return string|null
*/
public function getRejectionReason(): ?string
{
return $this->rejectionReason;
}
/**
* @param string $rejectionReason
*/
public function setRejectionReason(string $rejectionReason): void
{
$this->rejectionReason = $rejectionReason;
}
/**
* @return string|null
*/
public function getQuality(): ?string
{
return $this->quality;
}
public function setQuality(string $quality): void
{
$this->quality = $quality;
}
/**
* @return array<string, string>|null
*/
public function getHeader(): ?array
{
return $this->header;
}
/**
* @param array<string, string> $header
*/
public function setHeader(array $header): void
{
$this->header = $header;
}
/**
* @return array<string, array<string, string>>|null
*/
public function getButtons(): ?array
{
return $this->buttons;
}
/**
* @param array<string, array<string, string>> $buttons
*/
public function setButtons(array $buttons): void
{
$this->buttons = $buttons;
}
}

View file

@ -0,0 +1,74 @@
<?php
/**
* PHP version 7.1
*
* TemplateAttachment entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Template
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Template;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* TemplateAttachment class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Template
*/
class TemplateAttachment implements ModelInterface
{
/**
* @var string $id
*
* @Type("string")
* @Accessor(getter="getId",setter="setId")
*/
private $id;
/**
* @var string $caption
*
* @Type("string")
* @Accessor(getter="getCaption",setter="setCaption")
* @SkipWhenEmpty()
*/
private $caption;
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string $id
* @return void
*/
public function setId(string $id): void
{
$this->id = $id;
}
/**
* @return string|null
*/
public function getCaption(): ?string
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption(string $caption): void
{
$this->caption = $caption;
}
}

View file

@ -0,0 +1,120 @@
<?php
/**
* PHP version 7.1
*
* TemplateVariables entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Template
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Template;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* TemplateVariables class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Template
*/
class TemplateVariables implements ModelInterface
{
/**
* @var array<string, string> $header
*
* @Type("array")
* @Accessor(getter="getHeader",setter="setHeader")
*/
private $header;
/** @var array<TemplateAttachment> $attachments
*
* @Type("array")
* @Accessor(getter="getAttachments",setter="setAttachments")
*/
private $attachments;
/**
* @var array<string, string> $body
*
* @Type("array")
* @Accessor(getter="getBody",setter="setBody")
*/
private $body;
/**
* @var array<string, array<string, string>> $buttons
*
* @Type("array")
* @Accessor(getter="getButtons",setter="setButtons")
*/
private $buttons;
/**
* @return array<string, string>|null
*/
public function getHeader(): ?array
{
return $this->header;
}
/**
* @param array<string, string> $header
*/
public function setHeader(array $header): void
{
$this->header = $header;
}
/**
* @return array<string, string>|null
*/
public function getBody(): ?array
{
return $this->body;
}
/**
* @param array<string, string> $body
*/
public function setBody(array $body): void
{
$this->body = $body;
}
/**
* @return array<string, array<string, string>>|null
*/
public function getButtons(): ?array
{
return $this->buttons;
}
/**
* @param array<string, array<string, string>> $buttons
*/
public function setButtons(array $buttons): void
{
$this->buttons = $buttons;
}
/**
* @return TemplateAttachment[]|null
*/
public function getAttachments(): ?array
{
return $this->attachments;
}
/**
* @param TemplateAttachment[] $attachments
*/
public function setAttachments(array $attachments): void
{
$this->attachments = $attachments;
}
}

View file

@ -1,34 +1,27 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* User entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @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\Entity;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* User class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class User
class User implements ModelInterface
{
/**
* @var string $id
@ -41,7 +34,7 @@ class User
/**
* @var \DateTime $createdAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getCreatedAt",setter="setCreatedAt")
*/
private $createdAt;
@ -49,7 +42,7 @@ class User
/**
* @var \DateTime $updatedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getUpdatedAt",setter="setUpdatedAt")
* @SkipWhenEmpty()
*/
@ -143,16 +136,25 @@ class User
/**
* @var \DateTime $revokedAt
*
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>")
* @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>")
* @Accessor(getter="getRevokedAt",setter="setRevokedAt")
* @SkipWhenEmpty()
*/
private $revokedAt;
/**
* @return string
* @var bool $isSystem
*
* @Type("bool")
* @Accessor(getter="isSystem",setter="setIsSystem")
* @SkipWhenEmpty()
*/
public function getId(): string
private $isSystem;
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
@ -168,7 +170,7 @@ class User
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
@ -184,7 +186,7 @@ class User
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
@ -198,9 +200,9 @@ class User
}
/**
* @return string
* @return string|null
*/
public function getExternalId(): string
public function getExternalId(): ?string
{
return $this->externalId;
}
@ -214,9 +216,9 @@ class User
}
/**
* @return string
* @return string|null
*/
public function getType(): string
public function getType(): ?string
{
return $this->type;
}
@ -230,9 +232,9 @@ class User
}
/**
* @return string
* @return string|null
*/
public function getAvatar(): string
public function getAvatar(): ?string
{
return $this->avatar;
}
@ -246,9 +248,9 @@ class User
}
/**
* @return string
* @return string|null
*/
public function getName(): string
public function getName(): ?string
{
return $this->name;
}
@ -262,9 +264,9 @@ class User
}
/**
* @return string
* @return string|null
*/
public function getUsername(): string
public function getUsername(): ?string
{
return $this->username;
}
@ -278,9 +280,9 @@ class User
}
/**
* @return string
* @return string|null
*/
public function getFirstName(): string
public function getFirstName(): ?string
{
return $this->firstName;
}
@ -294,9 +296,9 @@ class User
}
/**
* @return string
* @return string|null
*/
public function getLastName(): string
public function getLastName(): ?string
{
return $this->lastName;
}
@ -310,9 +312,9 @@ class User
}
/**
* @return bool
* @return bool|null
*/
public function isActive(): bool
public function isActive(): ?bool
{
return $this->isActive;
}
@ -326,9 +328,9 @@ class User
}
/**
* @return bool
* @return bool|null
*/
public function isOnline(): bool
public function isOnline(): ?bool
{
return $this->isOnline;
}
@ -344,7 +346,7 @@ class User
/**
* @return \DateTime
*/
public function getRevokedAt(): \DateTime
public function getRevokedAt(): ?\DateTime
{
return $this->revokedAt;
}
@ -356,4 +358,20 @@ class User
{
$this->revokedAt = $revokedAt;
}
/**
* @return bool|null
*/
public function isSystem(): ?bool
{
return $this->isSystem;
}
/**
* @param bool $isSystem
*/
public function setIsSystem(bool $isSystem): void
{
$this->isSystem = $isSystem;
}
}

View file

@ -0,0 +1,154 @@
<?php
/**
* PHP version 7.1
*
* Utm entity
*
* @package Retailcrm\Mg\Bot\Model\Entity
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* Utm class
*
* @package RetailCrm\Mg\Bot\Model\Entity
*/
class Utm implements ModelInterface
{
/**
* @var string $campaign
*
* @Type("string")
* @Accessor(getter="getCampaign",setter="setCampaign")
* @SkipWhenEmpty()
*/
private $campaign;
/**
* @var string $content
*
* @Type("string")
* @Accessor(getter="getContent",setter="setContent")
* @SkipWhenEmpty()
*/
private $content;
/**
* @var string $medium
*
* @Type("string")
* @Accessor(getter="getMedium",setter="setMedium")
* @SkipWhenEmpty()
*/
private $medium;
/**
* @var string $source
*
* @Type("string")
* @Accessor(getter="getSource",setter="setSource")
* @SkipWhenEmpty()
*/
private $source;
/**
* @var string $term
*
* @Type("string")
* @Accessor(getter="getTerm",setter="setTerm")
* @SkipWhenEmpty()
*/
private $term;
/**
* @return string|null
*/
public function getCampaign(): ?string
{
return $this->campaign;
}
/**
* @param string $campaign
* @return void
*/
public function setCampaign(string $campaign): void
{
$this->campaign = $campaign;
}
/**
* @return string|null
*/
public function getContent(): ?string
{
return $this->content;
}
/**
* @param string $content
* @return void
*/
public function setContent(string $content): void
{
$this->content = $content;
}
/**
* @return string|null
*/
public function getMedium(): ?string
{
return $this->medium;
}
/**
* @param string $medium
* @return void
*/
public function setMedium(string $medium): void
{
$this->medium = $medium;
}
/**
* @return string|null
*/
public function getSource(): ?string
{
return $this->source;
}
/**
* @param string $source
* @return void
*/
public function setSource(string $source): void
{
$this->source = $source;
}
/**
* @return string|null
*/
public function getTerm(): ?string
{
return $this->term;
}
/**
* @param string $term
* @return void
*/
public function setTerm(string $term): void
{
$this->term = $term;
}
}

View file

@ -0,0 +1,75 @@
<?php
/**
* PHP version 7.1
*
* ModelAdapter
*
* @package RetailCrm\Mg\Bot\Adapter
*/
namespace RetailCrm\Mg\Bot\Model;
use Psr\Http\Message\ResponseInterface;
use RetailCrm\Common\Exception\InvalidJsonException;
use RetailCrm\Common\Serializer;
/**
* Class ModelAdapter
*
* @package RetailCrm\Mg\Bot\Adapter
*/
class ModelAdapter
{
/**
* @var string $classname
*/
private $classname;
/**
* ModelAdapter constructor.
*
* @param string $classname
*
*/
public function __construct(string $classname)
{
$this->classname = $classname;
}
/**
* Get Response Model
*
* @param \Psr\Http\Message\ResponseInterface $response
*
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
*/
public function getResponseModel(ResponseInterface $response)
{
return Serializer::deserialize((string)$response->getBody(), $this->classname);
}
/**
* Get Response List
*
* @param \Psr\Http\Message\ResponseInterface $response
*
* @return array
*/
public function getResponseList(ResponseInterface $response)
{
$array = json_decode((string)$response->getBody(), true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new InvalidJsonException('Received invalid JSON', 1);
}
$result = [];
foreach ($array as $item) {
$result[] = Serializer::deserialize($item, $this->classname, Serializer::S_ARRAY);
}
return $result;
}
}

View file

@ -0,0 +1,14 @@
<?php
/**
* PHP version 7.1
*
* ModelInterface
*
* @package RetailCrm\Mg\Bot\Model
*/
namespace RetailCrm\Mg\Bot\Model;
interface ModelInterface
{
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* 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;
@ -16,20 +13,17 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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
class BotsRequest implements ModelInterface
{
use CommonFields;
use PageLimit;
/**
* @Type("int")

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Channels list 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;
@ -16,20 +13,17 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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
class ChannelsRequest implements ModelInterface
{
use CommonFields;
use PageLimit;
/**
* @Type("array")

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Chats list 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;
@ -16,20 +13,18 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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
class ChatsRequest implements ModelInterface
{
use CommonFields;
use PageLimit;
use IncludeMassCommunication;
/**
* @Type("int")
@ -45,6 +40,24 @@ class ChatsRequest
*/
private $channelType;
/**
* @var int $customerId
*
* @Type("int")
* @Accessor(getter="getCustomerId",setter="setCustomerId")
* @SkipWhenEmpty()
*/
private $customerId;
/**
* @var int $sinceId
*
* @Type("int")
* @Accessor(getter="getSinceId",setter="setSinceId")
* @SkipWhenEmpty()
*/
private $sinceId;
/**
* @return int
*/
@ -76,4 +89,38 @@ class ChatsRequest
{
$this->channelType = $channelType;
}
/**
* @return int|null
*/
public function getCustomerId(): ?int
{
return $this->customerId;
}
/**
* @param int $customerId
* @return void
*/
public function setCustomerId($customerId)
{
$this->customerId = $customerId;
}
/**
* @return int|null
*/
public function getSinceId()
{
return $this->sinceId;
}
/**
* @param int $sinceId
* @return void
*/
public function setSinceId($sinceId)
{
$this->sinceId = $sinceId;
}
}

View file

@ -1,35 +1,26 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Edit Command 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 as Serializer;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use Symfony\Component\Validator\Constraints as Assert;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* CommandEditRequest 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 CommandEditRequest
class CommandEditRequest implements ModelInterface
{
/**
* @var int $botId

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Commands list 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;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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
class CommandsRequest implements ModelInterface
{
use CommonFields;

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* 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;
@ -18,14 +15,9 @@ 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
{
@ -57,9 +49,9 @@ trait CommonFields
private $until;
/**
* @return int
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Customers list 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;
@ -16,21 +13,17 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Request\CommonFields;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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
class CustomersRequest implements ModelInterface
{
use CommonFields;
use PageLimit;
/**
* @Type("string")

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Dialog assign 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;
@ -17,18 +14,14 @@ use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* DialogAssignRequest 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 DialogAssignRequest
class DialogAssignRequest implements ModelInterface
{
/**
* @var int $dialogId

View file

@ -0,0 +1,78 @@
<?php
/**
* PHP version 7.1
*
* Dialog add or delete tag request
*
* @package RetailCrm\Mg\Bot\Model\Request
*/
namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Tag;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* DialogTagRequest class
*
* @package RetailCrm\Mg\Bot\Model\Request
*/
class DialogTagRequest implements ModelInterface
{
/**
* @var int $dialogId
*
* @Type("int")
* @Accessor(getter="getDialogId", setter="setDialogId")
* @SkipWhenEmpty()
*/
private $dialogId;
/**
* @var Tag[] $tags
*
* @Type("array")
* @Accessor(getter="getTags", setter="setTags")
* @SkipWhenEmpty()
*/
private $tags;
/**
* @return int
*/
public function getDialogId(): int
{
return $this->dialogId;
}
/**
* @param int $dialogId
* @return void
*/
public function setDialogId(int $dialogId): void
{
$this->dialogId = $dialogId;
}
/**
* @return Tag[]
*/
public function getTags(): array
{
return $this->tags;
}
/**
* @param Tag[] $tags
* @return void
*/
public function setTags(array $tags): void
{
$this->tags = $tags;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Dialogs list 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;
@ -16,20 +13,27 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* DialogsRequest 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
class DialogsRequest implements ModelInterface
{
use CommonFields;
use PageLimit;
use IncludeMassCommunication;
/**
* @var int $sinceId
*
* @Type("int")
* @Accessor(getter="getSinceId",setter="setSinceId")
* @SkipWhenEmpty
*/
private $sinceId;
/**
* @var int $chatId
@ -76,6 +80,22 @@ class DialogsRequest
*/
private $assign;
/**
* @return int
*/
public function getSinceId()
{
return $this->sinceId;
}
/**
* @param int $sinceId
*/
public function setSinceId(int $sinceId)
{
$this->sinceId = $sinceId;
}
/**
* @return int
*/

View file

@ -0,0 +1,48 @@
<?php
/**
* PHP version 7.1
*
* Common fields
*
* @package RetailCrm\Mg\Bot\Model\Request
*/
namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* CommonFields trait
*
* @package RetailCrm\Mg\Bot\Model\Request
*/
trait IncludeMassCommunication
{
/**
* @var int $includeMassCommunication
*
* @Type("int")
* @Accessor(getter="getIncludeMassCommunication",setter="setIncludeMassCommunication")
* @SkipWhenEmpty
*/
private $includeMassCommunication;
/**
* @return int
*/
public function getIncludeMassCommunication()
{
return $this->includeMassCommunication;
}
/**
* @param int $includeMassCommunication
*/
public function setIncludeMassCommunication(?int $includeMassCommunication): void
{
$this->includeMassCommunication = $includeMassCommunication;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Bot info 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;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* InfoRequest 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 InfoRequest
class InfoRequest implements ModelInterface
{
/**
* @var string $name

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Members list 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;
@ -16,19 +13,18 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MembersRequest 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
class MembersRequest implements ModelInterface
{
use CommonFields;
use PageLimit;
/**
* @var int $chatId
*
@ -56,24 +52,6 @@ class MembersRequest
*/
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
*/
@ -121,36 +99,4 @@ class MembersRequest
{
$this->state = $state;
}
/**
* @return string
*/
public function getSince()
{
return $this->since;
}
/**
* @param string $since
*/
public function setSince(string $since)
{
$this->since = $since;
}
/**
* @return string
*/
public function getUntil()
{
return $this->until;
}
/**
* @param string $until
*/
public function setUntil(string $until)
{
$this->until = $until;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Messages edit 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;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageEditRequest 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 MessageEditRequest
class MessageEditRequest implements ModelInterface
{
/**
* @var int $id
@ -48,9 +41,9 @@ class MessageEditRequest
private $content;
/**
* @return int
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}

View file

@ -1,38 +1,31 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Messages send 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 as Serializer;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct;
use RetailCrm\Mg\Bot\Model\Entity\Message\TransportAttachments;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert;
use RetailCrm\Mg\Bot\Model\Entity\Order;
use RetailCrm\Mg\Bot\Model\Entity\Product;
/**
* PHP version 7.0
*
* MessageSendRequest 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 MessageSendRequest
class MessageSendRequest implements ModelInterface
{
/**
* @var string $type
@ -48,15 +41,14 @@ class MessageSendRequest
*
* @Type("string")
* @Accessor(getter="getContent",setter="setContent")
*
* @Assert\NotBlank
* @SkipWhenEmpty()
*/
private $content;
/**
* @var MessageProduct $product
*
* @Type("Product")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct")
* @Accessor(getter="getProduct",setter="setProduct")
* @SkipWhenEmpty()
*/
@ -65,7 +57,7 @@ class MessageSendRequest
/**
* @var MessageOrder $order
*
* @Type("Order")
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder")
* @Accessor(getter="getOrder",setter="setOrder")
* @SkipWhenEmpty()
*/
@ -80,6 +72,15 @@ class MessageSendRequest
*/
private $items;
/**
* @var string $note
*
* @Type("string")
* @Accessor(getter="getNote",setter="setNote")
* @SkipWhenEmpty()
*/
private $note;
/**
* @var string $scope
*
@ -90,6 +91,16 @@ class MessageSendRequest
*/
private $scope;
/**
* @var TransportAttachments $transportAttachments
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Message\TransportAttachments")
* @Accessor(getter="getTransportAttachments",setter="setTransportAttachments")
* @SkipWhenEmpty
*/
private $transportAttachments;
/**
* @var int $chatId
*
@ -143,6 +154,22 @@ class MessageSendRequest
$this->scope = $scope;
}
/**
* @return TransportAttachments
*/
public function getTransportAttachments()
{
return $this->transportAttachments;
}
/**
* @param TransportAttachments $transportAttachments
*/
public function setTransportAttachments(TransportAttachments $transportAttachments)
{
$this->transportAttachments = $transportAttachments;
}
/**
* @return string
*/
@ -223,6 +250,22 @@ class MessageSendRequest
$this->items = $items;
}
/**
* @return null|string
*/
public function getNote(): ?string
{
return $this->note;
}
/**
* @param string $note
*/
public function setNote(string $note): void
{
$this->note = $note;
}
/**
* @return int
*/

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Messages list 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;
@ -16,20 +13,17 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessagesRequest 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
class MessagesRequest implements ModelInterface
{
use CommonFields;
use IncludeMassCommunication;
/**
* @var int $chatId
@ -112,6 +106,15 @@ class MessagesRequest
*/
private $type;
/**
* @var int $limit
*
* @Type("int")
* @Accessor(getter="getLimit",setter="setLimit")
* @SkipWhenEmpty()
*/
private $limit;
/**
* @return int
*/
@ -255,4 +258,20 @@ class MessagesRequest
{
$this->type = $type;
}
/**
* @return int
*/
public function getLimit()
{
return $this->limit;
}
/**
* @param int $limit
*/
public function setLimit(int $limit)
{
$this->limit = $limit;
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
* PHP version 7.1
*
* Page limit
*
* @package RetailCrm\Mg\Bot\Model\Request
*/
namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PageLimit trait
*
* @package RetailCrm\Mg\Bot\Model\Request
*/
trait PageLimit
{
/**
* @var int $limit
*
* @Type("int")
* @Accessor(getter="getLimit",setter="setLimit")
* @SkipWhenEmpty
*/
private $limit;
/**
* @return int|null
*/
public function getLimit(): ?int
{
return $this->limit;
}
/**
* @param int $limit
* @return void
*/
public function setLimit($limit)
{
$this->limit = $limit;
}
}

View file

@ -0,0 +1,77 @@
<?php
/**
* PHP version 7.1
*
* Template send request
*
* @package RetailCrm\Mg\Bot\Model\Request
*/
namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Template\TemplateVariables;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* TemplateSendRequest class
*
* @package RetailCrm\Mg\Bot\Model\Request
*/
class TemplateSendRequest implements ModelInterface
{
/**
* @var string $phone
*
* @Type("string")
* @Accessor(getter="getPhone",setter="setPhone")
*
* @Assert\NotBlank
*/
private $phone;
/**
* @var TemplateVariables $args
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Template\TemplateVariables")
* @Accessor(getter="getArgs",setter="setArgs")
* @SkipWhenEmpty()
*/
private $args;
/**
* @return string
*/
public function getPhone(): string
{
return $this->phone;
}
/**
* @param string $phone
*/
public function setPhone(string $phone): void
{
$this->phone = $phone;
}
/**
* @return TemplateVariables|null
*/
public function getArgs(): ?TemplateVariables
{
return $this->args;
}
/**
* @param TemplateVariables $args
*/
public function setArgs(TemplateVariables $args): void
{
$this->args = $args;
}
}

View file

@ -1,40 +1,33 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Upload file by url 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\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* PHP version 7.0
*
* UploadFileByUrlRequest 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 UploadFileByUrlRequest
class UploadFileByUrlRequest implements ModelInterface
{
/**
* @var string $url
*
* @Type("string")
* @Accessor(getter="getUrl",setter="setUrl")
* @Assert\NotBlank()
* @Assert\NotBlank(allowNull=false)
* @Assert\Url()
*/
private $url;

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Users list 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;
@ -16,20 +13,17 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* UsersRequest 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
class UsersRequest implements ModelInterface
{
use CommonFields;
use PageLimit;
/**
* @Type("string")

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* AssignResponse
*
* @package RetailCrm\Mg\Bot\Model\Response
* @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\Response;
@ -17,18 +14,14 @@ use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Responsible;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* AssignResponse class
*
* @package RetailCrm\Mg\Bot\Model\Response
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class AssignResponse
class AssignResponse implements ModelInterface
{
use CommonFields;
@ -69,9 +62,9 @@ class AssignResponse
private $responsible;
/**
* @return bool
* @return bool|null
*/
public function getIsReassign(): bool
public function getIsReassign(): ?bool
{
return $this->isReassign;
}
@ -85,9 +78,9 @@ class AssignResponse
}
/**
* @return int
* @return int|null
*/
public function getLeftManagerId(): int
public function getLeftManagerId(): ?int
{
return $this->leftManagerId;
}
@ -101,9 +94,9 @@ class AssignResponse
}
/**
* @return Responsible
* @return Responsible|null
*/
public function getPreviousResponsible(): Responsible
public function getPreviousResponsible(): ?Responsible
{
return $this->previousResponsible;
}
@ -117,9 +110,9 @@ class AssignResponse
}
/**
* @return Responsible
* @return Responsible|null
*/
public function getResponsible(): Responsible
public function getResponsible(): ?Responsible
{
return $this->responsible;
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* ErrorTrait
*
* @package RetailCrm\Mg\Bot\Model\Response
* @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\Response;
@ -19,14 +16,9 @@ use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* CommonFields trait
*
* @package RetailCrm\Mg\Bot\Model\Response
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
trait CommonFields
{
@ -46,11 +38,11 @@ trait CommonFields
private $statusCode;
/**
* @return array
* @return array|null
*/
public function getErrors(): array
public function getErrors(): ?array
{
return is_null($this->errors) ? [] : $this->errors;
return empty($this->errors) ? [] : $this->errors;
}
/**
@ -62,9 +54,9 @@ trait CommonFields
}
/**
* @return int
* @return int|null
*/
public function getStatusCode(): int
public function getStatusCode(): ?int
{
return $this->statusCode;
}

View file

@ -1,29 +1,23 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* ErrorOnlyResponse
*
* @package RetailCrm\Mg\Bot\Model\Response
* @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\Response;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* ErrorOnlyResponse class
*
* @package RetailCrm\Mg\Bot\Model\Response
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ErrorOnlyResponse
class ErrorOnlyResponse implements ModelInterface
{
use CommonFields;
}

View file

@ -1,33 +1,27 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* FullFileResponse
*
* @package RetailCrm\Mg\Bot\Model\Response
* @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\Response;
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* FullFileResponse class
*
* @package RetailCrm\Mg\Bot\Model\Response
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class FullFileResponse
class FullFileResponse implements ModelInterface
{
use CommonFields;
@ -62,15 +56,16 @@ class FullFileResponse
* @var string $url
*
* @Type("string")
* @SerializedName("Url")
* @Accessor(getter="getUrl",setter="setUrl")
* @SkipWhenEmpty()
*/
private $url;
/**
* @return string
* @return string|null
*/
public function getId(): string
public function getId(): ?string
{
return $this->id;
}
@ -84,9 +79,9 @@ class FullFileResponse
}
/**
* @return int
* @return int|null
*/
public function getSize(): int
public function getSize(): ?int
{
return $this->size;
}
@ -100,9 +95,9 @@ class FullFileResponse
}
/**
* @return string
* @return string|null
*/
public function getType(): string
public function getType(): ?string
{
return $this->type;
}
@ -116,9 +111,9 @@ class FullFileResponse
}
/**
* @return string
* @return string|null
*/
public function getUrl(): string
public function getUrl(): ?string
{
return $this->url;
}

View file

@ -1,202 +0,0 @@
<?php
/**
* PHP version 7.0
*
* ListResponse
*
* @package RetailCrm\Mg\Bot\Model\Response
* @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\Response;
use RetailCrm\Common\Serializer;
/**
* PHP version 7.0
*
* ListResponse class. Used to store multiple objects at once.
* Implements `Iterator`, `ArrayAccess` and `Countable`.
*
* @package RetailCrm\Mg\Bot\Model\Response
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ListResponse implements \Iterator, \ArrayAccess, \Countable
{
use CommonFields;
/**
* @var array
*/
private $items = [];
/**
* @var int
*/
private $position = 0;
/**
* ListResponse constructor.
*
* @param string $responseType
* @param array $data
* @param int $statusCode
*/
public function __construct($responseType, $data, $statusCode)
{
$this->setStatusCode($statusCode);
if (isset($data['errors'])) {
$this->setErrors($data['errors']);
} else {
foreach ($data as $item) {
$this->items[] =
Serializer::deserialize($item, $responseType, Serializer::S_ARRAY);
}
}
}
/**
* @return bool
*/
public function isSuccessful()
{
return empty($this->errors);
}
/**
* \Countable implementation
*
* @return int
*/
public function count(): int
{
return count($this->items ?: []);
}
/**
* Set offset
*
* @param mixed $offset offset value
* @param mixed $value value
*
* @return void
* @internal
*/
public function offsetSet($offset, $value)
{
throw new \BadMethodCallException(
"This call not allowed: offsetSet [$offset] [$value]"
);
}
/**
* Unset offset
*
* @param mixed $offset offset value
*
* @return void
* @internal
*/
public function offsetUnset($offset)
{
throw new \BadMethodCallException(
"This call not allowed: offsetSet [$offset]"
);
}
/**
* Check offset
*
* @param mixed $offset offset value
*
* @return bool
* @internal
*/
public function offsetExists($offset)
{
return isset($this->items[$offset]);
}
/**
* Get offset
*
* @param mixed $offset offset value
*
* @return mixed
* @internal
*/
public function offsetGet($offset)
{
if (!isset($this->items[$offset])) {
throw new \InvalidArgumentException("Item \"$offset\" not found");
}
return $this->items[$offset];
}
/**
* @param mixed $name
*
* @return mixed
* @internal
*/
public function __get($name)
{
return $this->items[$name];
}
/**
* Implements rewind() for Iterable
* @internal
*/
public function rewind()
{
$this->position = 0;
}
/**
* Implements current() for Iterable
*
* @internal
* @return mixed
*/
public function current()
{
return $this->items[$this->position];
}
/**
* Implements key() for Iterable
*
* @internal
* @return int|mixed
*/
public function key()
{
return $this->position;
}
/**
* Implements next() for Iterable
* @internal
*/
public function next()
{
++$this->position;
}
/**
* Implements valid() for Iterable
*
* @internal
* @return bool
*/
public function valid()
{
return isset($this->items[$this->position]);
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* MessageSendResponse
*
* @package RetailCrm\Mg\Bot\Model\Response
* @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\Response;
@ -16,18 +13,14 @@ namespace RetailCrm\Mg\Bot\Model\Response;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* MessageSendResponse class
*
* @package RetailCrm\Mg\Bot\Model\Response
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class MessageSendResponse
class MessageSendResponse implements ModelInterface
{
use CommonFields;
@ -50,9 +43,9 @@ class MessageSendResponse
private $time;
/**
* @return int
* @return int|null
*/
public function getMessageId(): int
public function getMessageId(): ?int
{
return $this->messageId;
}
@ -66,9 +59,9 @@ class MessageSendResponse
}
/**
* @return string
* @return string|null
*/
public function getTime(): string
public function getTime(): ?string
{
return $this->time;
}

View file

@ -0,0 +1,52 @@
<?php
/**
* PHP version 7.1
*
* UnassignResponse
*
* @package RetailCrm\Mg\Bot\Model\Response
*/
namespace RetailCrm\Mg\Bot\Model\Response;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Responsible;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* UnassignResponse class
*
* @package RetailCrm\Mg\Bot\Model\Response
*/
class UnassignResponse implements ModelInterface
{
use CommonFields;
/**
* @var Responsible $previousResponsible
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Responsible")
* @Accessor(getter="getPreviousResponsible",setter="setPreviousResponsible")
* @SkipWhenEmpty()
*/
private $previousResponsible;
/**
* @return Responsible|null
*/
public function getPreviousResponsible(): ?Responsible
{
return $this->previousResponsible;
}
/**
* @param Responsible $previousResponsible
*/
public function setPreviousResponsible(Responsible $previousResponsible)
{
$this->previousResponsible = $previousResponsible;
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* UploadFileResponse
*
* @package RetailCrm\Mg\Bot\Model\Response
* @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\Response;
@ -17,18 +14,14 @@ use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\FileMeta;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* PHP version 7.0
*
* UploadFileResponse class
*
* @package RetailCrm\Mg\Bot\Model\Response
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class UploadFileResponse
class UploadFileResponse implements ModelInterface
{
use CommonFields;
@ -105,9 +98,9 @@ class UploadFileResponse
private $type;
/**
* @return string
* @return string|null
*/
public function getCreatedAt(): string
public function getCreatedAt(): ?string
{
return $this->createdAt;
}
@ -121,9 +114,9 @@ class UploadFileResponse
}
/**
* @return string
* @return string|null
*/
public function getHash(): string
public function getHash(): ?string
{
return $this->hash;
}
@ -137,9 +130,9 @@ class UploadFileResponse
}
/**
* @return string
* @return string|null
*/
public function getId(): string
public function getId(): ?string
{
return $this->id;
}
@ -153,9 +146,9 @@ class UploadFileResponse
}
/**
* @return FileMeta
* @return FileMeta|null
*/
public function getMeta(): FileMeta
public function getMeta(): ?FileMeta
{
return $this->meta;
}
@ -169,9 +162,9 @@ class UploadFileResponse
}
/**
* @return string
* @return string|null
*/
public function getMimeType(): string
public function getMimeType(): ?string
{
return $this->mimeType;
}
@ -185,9 +178,9 @@ class UploadFileResponse
}
/**
* @return int
* @return int|null
*/
public function getSize(): int
public function getSize(): ?int
{
return $this->size;
}
@ -201,9 +194,9 @@ class UploadFileResponse
}
/**
* @return string
* @return string|null
*/
public function getSourceUrl(): string
public function getSourceUrl(): ?string
{
return $this->sourceUrl;
}
@ -217,9 +210,9 @@ class UploadFileResponse
}
/**
* @return string
* @return string|null
*/
public function getType(): string
public function getType(): ?string
{
return $this->type;
}

View file

@ -1,30 +1,23 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* CurlException
* InvalidJsonException
*
* @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\Common\Exception;
use DomainException;
use Throwable;
/**
* PHP version 7.0
*
* Class InvalidJsonException
*
* @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class InvalidJsonException extends DomainException
class InvalidJsonException extends DomainException implements Throwable
{
}

View file

@ -1,30 +1,23 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* CurlException
* LimitException
*
* @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\Common\Exception;
use DomainException;
use Throwable;
/**
* PHP version 7.0
*
* Class LimitException
*
* @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class LimitException extends DomainException
class LimitException extends DomainException implements Throwable
{
}

View file

@ -0,0 +1,22 @@
<?php
/**
* PHP version 7.1
*
* NotFoundException
*
* @package RetailCrm\Common\Exception
*/
namespace RetailCrm\Common\Exception;
use DomainException;
use Throwable;
/**
* Class NotFoundException
*
* @package RetailCrm\Common\Exception
*/
class NotFoundException extends DomainException implements Throwable
{
}

View file

@ -0,0 +1,17 @@
<?php
/**
* PHP version 7.1
*
* UnauthorizedException
*
* @package RetailCrm\Common\Exception
*/
namespace RetailCrm\Common\Exception;
use DomainException;
use Throwable;
class UnauthorizedException extends DomainException implements Throwable
{
}

View file

@ -1,32 +1,25 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Register Helper
* Register
*
* @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Common;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use Symfony\Component\Validator\Constraints as Assert;
/**
* PHP version 7.0
*
* RequestHelper class
* Class Register
*
* @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Register
{
@ -45,14 +38,15 @@ class Register
*
* @Type("string")
* @Accessor(getter="getIntegrationCode",setter="setIntegrationCode")
* @SerializedName("integrationCode")
*
* @Assert\NotBlank
*/
private $integrationCode;
/**
* @var string $active
* @Type("string")
* @var bool $active
* @Type("bool")
* @Accessor(getter="getActive",setter="setActive")
* @SkipWhenEmpty
*/
@ -63,7 +57,7 @@ class Register
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty
* @Assert\NotBlank()
*/
private $name;
@ -86,6 +80,7 @@ class Register
*
* @Type("string")
* @Accessor(getter="getClientId",setter="setClientId")
* @SerializedName("clientId")
*
* @Assert\NotBlank
*/
@ -96,6 +91,7 @@ class Register
*
* @Type("string")
* @Accessor(getter="getBaseUrl",setter="setBaseUrl")
* @SerializedName("baseUrl")
*
* @Assert\NotBlank
* @Assert\Url(
@ -110,6 +106,7 @@ class Register
*
* @Type("string")
* @Accessor(getter="getAccountUrl",setter="setAccountUrl")
* @SerializedName("accountUrl")
*
* @Assert\NotBlank
* @Assert\Url(
@ -134,6 +131,7 @@ class Register
*
* @Type("array")
* @Accessor(getter="getAvailableCountries",setter="setAvailableCountries")
* @SerializedName("availableCountries")
* @SkipWhenEmpty
*/
private $availableCountries;
@ -181,7 +179,7 @@ class Register
}
/**
* @return string
* @return bool
*/
public function getActive()
{
@ -189,9 +187,9 @@ class Register
}
/**
* @param string $active
* @param bool $active
*/
public function setActive(string $active)
public function setActive(bool $active)
{
$this->active = $active;
}
@ -327,20 +325,32 @@ class Register
/**
* Get configuration as JSON
*
* @return array|string
* @return string
*/
public function getJsonConfiguration()
{
return Serializer::serialize($this);
$serialized = Serializer::serialize($this);
if (is_string($serialized)) {
return $serialized;
}
return '';
}
/**
* Get configuration as array
*
* @return array|string
* @return array
*/
public function getArrayConfiguration()
{
return Serializer::serialize($this, Serializer::S_ARRAY);
$serialized = Serializer::serialize($this, Serializer::S_ARRAY);
if (is_array($serialized)) {
return $serialized;
}
return [];
}
}

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Serializer
*
* @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
* @package RetailCrm\Common
*/
namespace RetailCrm\Common;
@ -16,16 +13,13 @@ namespace RetailCrm\Common;
use JMS\Serializer\DeserializationContext;
use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse;
/**
* PHP version 7.0
* Class Serializer
*
* Serializer class
*
* @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
* @package RetailCrm\Common
*/
class Serializer
{
@ -44,16 +38,18 @@ class Serializer
{
$serialized = null;
$serializer = SerializerBuilder::create()->build();
$context = self::getContext();
$context = self::getContext(false);
switch ($serialize) {
case self::S_ARRAY:
$serialized = $serializer->toArray($request, $context);
break;
case self::S_JSON:
default:
$serialized = $serializer->serialize($request, $serialize, $context);
break;
if ($context instanceof SerializationContext) {
switch ($serialize) {
case self::S_ARRAY:
$serialized = $serializer->toArray($request, $context);
break;
case self::S_JSON:
default:
$serialized = $serializer->serialize($request, $serialize, $context);
break;
}
}
return $serialized;
@ -62,11 +58,11 @@ class Serializer
/**
* Deserialize given array or JSON to object
*
* @param mixed $data
* @param mixed $data
* @param string $entityType
* @param string $from
*
* @return object|null
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
*/
public static function deserialize($data, $entityType, $from = self::S_JSON)
{
@ -74,18 +70,23 @@ class Serializer
$serializer = SerializerBuilder::create()->build();
$context = self::getContext(true);
switch ($from) {
case self::S_ARRAY:
$deserialized =
$serializer->fromArray(array_filter($data), self::normalizeNamespace($entityType), $context);
break;
case self::S_JSON:
$deserialized =
$serializer->deserialize($data, self::normalizeNamespace($entityType), $from, $context);
break;
if ($context instanceof DeserializationContext) {
switch ($from) {
case self::S_ARRAY:
$filtered = array_filter($data, static function ($el) {
return $el !== null;
});
$deserialized = $serializer
->fromArray($filtered, self::normalizeNamespace($entityType), $context);
break;
case self::S_JSON:
$deserialized = $serializer
->deserialize($data, self::normalizeNamespace($entityType), $from, $context);
break;
}
}
return is_object($deserialized) ? $deserialized : null;
return $deserialized instanceof ModelInterface ? $deserialized : new ErrorOnlyResponse();
}
/**
@ -93,15 +94,15 @@ class Serializer
*
* @return DeserializationContext|SerializationContext
*/
private static function getContext(bool $deserialization = false)
private static function getContext(bool $deserialization)
{
if ($deserialization) {
$context = new DeserializationContext();
} else {
$context = new SerializationContext();
}
$context->setSerializeNull(false);
$context->setSerializeNull(false);
}
return $context;
}
@ -109,7 +110,7 @@ class Serializer
/**
* @param string $namespace
*
* @return bool|string
* @return string
*/
private static function normalizeNamespace(string $namespace)
{

View file

@ -1,37 +1,22 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* Url handler
* Url
*
* @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Common;
/**
* PHP version 7.0
*
* Url class
* Class Url
*
* @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Url
{
/**
* This class is used to store normalizeUrl method
* which is used in Client and HttpClient to check
* trailing slash.
*/
private function __construct() {}
/**
* Check trailing slash into url
*

View file

@ -1,14 +1,11 @@
<?php
/**
* PHP version 5.4
* PHP version 7.1
*
* Test case class
*
* @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\Mg\Bot\Test;
@ -22,21 +19,17 @@ use RetailCrm\Mg\Bot\Client;
/**
* Class TestCase
*
* @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
*/
class TestCase extends BaseCase
{
/**
* Return bot api client object
*
* @param string $url (default: null)
* @param string $key (default: null)
* @param bool $debug (default: false)
* @param array $response (default: null)
* @param string $url (default: null)
* @param string $key (default: null)
* @param bool $debug (default: false)
* @param array ...$response (default: null)
*
* @return Client
*/
@ -62,8 +55,8 @@ class TestCase extends BaseCase
/**
* Returns mocked GuzzleHttp response
*
* @param string|null $body
* @param int $statusCode
* @param string|null $body HTTP Body
* @param int $statusCode HTTP status code
*
* @return Response
*/
@ -93,8 +86,8 @@ class TestCase extends BaseCase
* Only file name (without extension or any other data) should be provided,
* e.g. `getJsonResponse('bots', 200)`
*
* @param string $jsonFile
* @param int $statusCode
* @param string $jsonFile mocked body
* @param int $statusCode mocked status code
*
* @return Response|null
*/
@ -120,8 +113,8 @@ class TestCase extends BaseCase
}
/**
* @param int $statusCode
* @param array ...$errors
* @param int $statusCode response code
* @param array ...$errors response errors
*
* @return Response
*/
@ -139,7 +132,7 @@ class TestCase extends BaseCase
/**
* Generate and return empty response
*
* @param int $statusCode
* @param int $statusCode HTTP status code
*
* @return Response|null
*/

View file

@ -1,18 +1,18 @@
<?php
/**
* PHP version 7.0
* PHP version 7.1
*
* 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 Psr\Http\Message\ResponseInterface;
use RetailCrm\Mg\Bot\Client;
use RetailCrm\Mg\Bot\HttpClient;
use RetailCrm\Mg\Bot\Model\Constants;
use RetailCrm\Mg\Bot\Model\Entity\Channel;
use RetailCrm\Mg\Bot\Model\Entity\Chat\Chat;
@ -30,9 +30,6 @@ use RetailCrm\Mg\Bot\Test\TestCase;
* Class ClientListTest
*
* @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 ClientListTest extends TestCase
{
@ -55,8 +52,11 @@ class ClientListTest extends TestCase
$response = $client->channels($request);
static::assertEquals(4, count($response), "Incorrect channels count");
static::assertTrue($response[0] instanceof Channel\Channel, "Incorrect channel instance");
static::assertCount(5, $response, "Incorrect channels count");
static::assertInstanceOf(Channel\Channel::class, $response[0], "Incorrect channel instance");
$textSuggestions = $response[0]->getSettings()->getSuggestions()->getText();
static::assertStringContainsString("both", $textSuggestions, "Incorrect text suggestions");
}
/**
@ -77,8 +77,29 @@ class ClientListTest extends TestCase
$response = $client->chats($request);
static::assertEquals(2, count($response), "Incorrect chats count");
static::assertTrue($response[0] instanceof Chat, "Incorrect chat instance");
static::assertCount(3, $response, "Incorrect chats count");
static::assertInstanceOf(Chat::class, $response[0], "Incorrect chat instance");
}
/**
* @group("list")
* @throws \Exception
*/
public function testGetChatsByCustomerId(): void
{
$client = self::getApiClient(
null,
null,
false,
$this->getJsonResponse('chatsByCustomerId')
);
$request = new Request\ChatsRequest();
$request->setCustomerId(39);
$response = $client->chats($request);
static::assertCount(1, $response, "Incorrect chats count");
static::assertInstanceOf(Chat::class, $response[0], "Incorrect chat instance");
}
/**
@ -97,8 +118,8 @@ class ClientListTest extends TestCase
$request = new Request\MembersRequest();
$response = $client->members($request);
static::assertEquals(4, count($response), "Incorrect members count");
static::assertTrue($response[0] instanceof ChatMember, "Incorrect member instance");
static::assertCount(5, $response, "Incorrect members count");
static::assertInstanceOf(ChatMember::class, $response[0], "Incorrect member instance");
}
/**
@ -117,11 +138,12 @@ class ClientListTest extends TestCase
$request = new Request\MessagesRequest();
$request->setChannelType(Constants::CHANNEL_TYPE_INSTAGRAM);
$request->setType(Constants::MESSAGE_TYPE_TEXT);
$request->setLimit(1000);
$response = $client->messages($request);
static::assertEquals(2, count($response), "Incorrect message count");
static::assertTrue($response[0] instanceof Message, "Incorrect message instance");
static::assertCount(3, $response, "Incorrect message count");
static::assertInstanceOf(Message::class, $response[0], "Incorrect message instance");
}
/**
@ -140,7 +162,7 @@ class ClientListTest extends TestCase
$request = new Request\CommandsRequest();
$response = $client->commands($request);
self::assertEquals(0, count($response), "Invalid commands count");
self::assertCount(0, $response, "Invalid commands count");
}
/**
@ -162,7 +184,7 @@ class ClientListTest extends TestCase
$data = $client->bots($request);
static::assertEquals(3, count($data));
static::assertCount(4, $data);
}
/**
@ -184,8 +206,8 @@ class ClientListTest extends TestCase
$response = $client->users($request);
self::assertEquals(2, count($response));
self::assertTrue($response[0] instanceof User);
self::assertCount(3, $response);
self::assertInstanceOf(User::class, $response[0]);
}
/**
@ -207,8 +229,8 @@ class ClientListTest extends TestCase
$response = $client->dialogs($request);
self::assertEquals(2, count($response));
self::assertTrue($response[0] instanceof Dialog);
self::assertCount(3, $response);
self::assertInstanceOf(Dialog::class, $response[0]);
}
/**
@ -228,7 +250,10 @@ class ClientListTest extends TestCase
$response = $client->customers($request);
self::assertEquals(2, count($response));
self::assertTrue($response[0] instanceof Customer);
self::assertCount(3, $response);
self::assertInstanceOf(Customer::class, $response[0]);
$utm = $response[0]->getUtm()->getCampaign();
static::assertEquals('spring_sale', $utm, "Incorrect utm data");
}
}

View file

@ -6,9 +6,6 @@
* Commands 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;
@ -24,9 +21,6 @@ use RetailCrm\Mg\Bot\Test\TestCase;
* Class CommandsTest
*
* @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 CommandsTest extends TestCase
{
@ -86,7 +80,7 @@ class CommandsTest extends TestCase
$response = $client->commandEdit($request);
self::assertTrue($response instanceof ErrorOnlyResponse);
self::assertInstanceOf(ErrorOnlyResponse::class, $response);
self::assertTrue($response->isSuccessful());
}
@ -106,6 +100,6 @@ class CommandsTest extends TestCase
$response = $client->commandDelete("show_payment_types");
self::assertTrue($response->isSuccessful() == true);
self::assertTrue($response->isSuccessful());
}
}

View file

@ -6,16 +6,17 @@
* Dialogs 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
* @category Test
*/
namespace RetailCrm\Mg\Bot\Tests;
use InvalidArgumentException;
use RetailCrm\Common\Exception\NotFoundException;
use RetailCrm\Mg\Bot\Model\Entity\Responsible;
use RetailCrm\Mg\Bot\Model\Entity\Tag;
use RetailCrm\Mg\Bot\Model\Request\DialogAssignRequest;
use RetailCrm\Mg\Bot\Model\Request\DialogTagRequest;
use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse;
use RetailCrm\Mg\Bot\Test\TestCase;
@ -25,9 +26,6 @@ use RetailCrm\Mg\Bot\Test\TestCase;
* Class DialogsTest
*
* @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 DialogsTest extends TestCase
{
@ -37,6 +35,7 @@ class DialogsTest extends TestCase
*/
public function testDialogAssignError()
{
$this->expectException(\RuntimeException::class);
$client = self::getApiClient(
null,
null,
@ -47,10 +46,7 @@ class DialogsTest extends TestCase
$request = new DialogAssignRequest();
$request->setDialogId(-1);
$response = $client->dialogAssign($request);
self::assertTrue(!$response->isSuccessful());
self::assertNotEmpty($response->getErrors());
$client->dialogAssign($request);
}
/**
@ -78,13 +74,49 @@ class DialogsTest extends TestCase
self::assertTrue($response->getResponsible() instanceof Responsible);
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogUnassignError()
{
$this->expectException(\RuntimeException::class);
$client = self::getApiClient(
null,
null,
false,
$this->getErrorsResponse(400, "incorrect dialog_id")
);
$client->dialogUnassign(-1);
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogUnassign()
{
$client = self::getApiClient(
null,
null,
false,
$this->getJsonResponse('dialogUnassigned')
);
$response = $client->dialogUnassign(60);
self::assertTrue($response->isSuccessful());
self::assertTrue($response->getPreviousResponsible() instanceof Responsible);
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogCloseError()
{
self::expectException(InvalidArgumentException::class);
self::expectException(NotFoundException::class);
$client = self::getApiClient(
null,
@ -111,7 +143,183 @@ class DialogsTest extends TestCase
$response = $client->dialogClose('62');
self::assertTrue($response instanceof ErrorOnlyResponse);
self::assertInstanceOF(ErrorOnlyResponse::class, $response);
self::assertTrue($response->isSuccessful());
self::assertEmpty($response->getErrors());
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogAddTagColorError()
{
$this->expectException(NotFoundException::class);
$client = self::getApiClient(
null,
null,
false,
$this->getErrorsResponse(404,
"'color_code can contain only the following values: " .
"light-red; light-blue; light-green; light-orange; light-gray; " .
"light-grayish-blue; red; blue; green; orange; gray; grayish-blue'"
)
);
$tags[0] = new Tag();
$tags[0]->setName('tag1');
$tags[0]->setColorCode('qwerty');
$request = new DialogTagRequest();
$request->setDialogId(60);
$request->setTags($tags);
$client->dialogAddTag($request);
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogAddTagDialogError()
{
$this->expectException(NotFoundException::class);
$client = self::getApiClient(
null,
null,
false,
$this->getErrorsResponse(404, "dialog #123456789 not found")
);
$tags[0] = new Tag();
$tags[0]->setName('tag1');
$request = new DialogTagRequest();
$request->setDialogId(123456789);
$request->setTags($tags);
$client->dialogAddTag($request);
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogAddTagEmptyTagError()
{
$this->expectException(\TypeError::class);
$client = self::getApiClient();
$tags[0] = new Tag();
$request = new DialogTagRequest();
$request->setDialogId(60);
$request->setTags($tags);
$client->dialogAddTag($request);
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogAddTag()
{
$client = self::getApiClient(
null,
null,
false,
$this->getResponse('{}')
);
$tags[0] = new Tag();
$tags[0]->setName('tag1');
$tags[0]->setColorCode('red');
$tags[1] = new Tag();
$tags[1]->setName('tag2');
$request = new DialogTagRequest();
$request->setDialogId(60);
$request->setTags($tags);
$response = $client->dialogAddTag($request);
self::assertInstanceOF(ErrorOnlyResponse::class, $response);
self::assertTrue($response->isSuccessful());
self::assertEmpty($response->getErrors());
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogDeleteTagDialogError()
{
$this->expectException(NotFoundException::class);
$client = self::getApiClient(
null,
null,
false,
$this->getErrorsResponse(404, "dialog #123456789 not found")
);
$tags[0] = new Tag();
$tags[0]->setName('tag1');
$request = new DialogTagRequest();
$request->setDialogId(123456789);
$request->setTags($tags);
$client->dialogAddTag($request);
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogDeleteTagEmptyTagError()
{
$this->expectException(\TypeError::class);
$client = self::getApiClient();
$tags[0] = new Tag();
$request = new DialogTagRequest();
$request->setTags($tags);
$client->dialogDeleteTag($request);
}
/**
* @group("dialogs")
* @throws \Exception
*/
public function testDialogDeleteTag()
{
$client = self::getApiClient(
null,
null,
false,
$this->getResponse('{}')
);
$tags[0] = new Tag();
$tags[0]->setName('tag1');
$request = new DialogTagRequest();
$request->setDialogId(60);
$request->setTags($tags);
$response = $client->dialogDeleteTag($request);
self::assertInstanceOF(ErrorOnlyResponse::class, $response);
self::assertTrue($response->isSuccessful());
self::assertEmpty($response->getErrors());
}

View file

@ -6,9 +6,6 @@
* Upload file 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;
@ -22,10 +19,7 @@ use RetailCrm\Mg\Bot\Test\TestCase;
*
* Class UploadFileTest
*
* @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
* @package RetailCrm\Mg\Bot\Tests
*/
class FileTest extends TestCase
{
@ -33,17 +27,32 @@ class FileTest extends TestCase
* @group("upload")
* @throws \Exception
*/
public function testUploadFileByUrlException()
public function testUploadFileByUrlEmpty()
{
$client = self::getApiClient(
null,
null,
false,
$this->getEmptyResponse(400)
$this->getErrorsResponse(400, 'Something is not quite right.')
);
self::expectException(\InvalidArgumentException::class);
$client->uploadFileByUrl('');
}
/**
* @group("upload")
* @throws \Exception
*/
public function testUploadFileByUrlInvalid()
{
$client = self::getApiClient(
null,
null,
false,
$this->getErrorsResponse(400, 'Something is not quite right.')
);
self::expectException(\InvalidArgumentException::class);
$client->uploadFileByUrl('rar');
}
@ -83,7 +92,7 @@ class FileTest extends TestCase
$response = $client->uploadFile(__FILE__);
self::assertTrue($response instanceof UploadFileResponse);
self::assertInstanceOf(UploadFileResponse::class, $response);
self::assertEquals('b2bdba90-166c-4e0a-829d-69f26a09fd2a', $response->getId());
self::assertEquals('file', $response->getType());
self::assertEquals(214, $response->getSize());
@ -105,7 +114,10 @@ class FileTest extends TestCase
$response = $client->getFileById($fileId);
self::assertTrue($response instanceof FullFileResponse);
self::assertInstanceOf(FullFileResponse::class, $response);
self::assertEquals($fileId, $response->getId());
$fileUrl = 'https://s3.eu-central-1.amazonaws.com/mg-node-files/files/21/b2bdba90-166c-4e0a-829d-69f26a09fd2a';
self::assertEquals($fileUrl, $response->getUrl());
}
}

View file

@ -6,16 +6,25 @@
* Messages 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\Model\Constants;
use RetailCrm\Mg\Bot\Model\Entity\Message\Item;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageDelivery;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrderItem;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrderPaymentStatus;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuantity;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageStatus;
use RetailCrm\Mg\Bot\Model\Entity\Message\Suggestion;
use RetailCrm\Mg\Bot\Model\Entity\Message\TransportAttachments;
use RetailCrm\Mg\Bot\Model\Request\MessageEditRequest;
use RetailCrm\Mg\Bot\Model\Request\MessageSendRequest;
use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse;
use RetailCrm\Mg\Bot\Test\TestCase;
/**
@ -24,9 +33,6 @@ use RetailCrm\Mg\Bot\Test\TestCase;
* Class MessagesTest
*
* @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 MessagesTest extends TestCase
{
@ -36,6 +42,7 @@ class MessagesTest extends TestCase
*/
public function testMessageSendError()
{
$this->expectException(\RuntimeException::class);
$client = self::getApiClient(
null,
null,
@ -51,17 +58,14 @@ class MessagesTest extends TestCase
$request->setScope(Constants::MESSAGE_SCOPE_PUBLIC);
$request->setContent("Hello");
$response = $client->messageSend($request);
self::assertTrue(!$response->isSuccessful());
self::assertEquals(1, count($response->getErrors()));
$client->messageSend($request);
}
/**
* @group("messages")
* @throws \Exception
*/
public function testMessageSend()
public function testMessageSendText()
{
$client = self::getApiClient(
null,
@ -80,9 +84,135 @@ class MessagesTest extends TestCase
$response = $client->messageSend($request);
self::assertTrue($response->isSuccessful());
self::assertEquals(0, count($response->getErrors()));
self::assertEquals(3636, $response->getMessageId());
self::assertInstanceOf(MessageSendResponse::class, $response);
if ($response instanceof MessageSendResponse) {
self::assertTrue($response->isSuccessful());
self::assertCount(0, $response->getErrors());
self::assertEquals(3636, $response->getMessageId());
}
}
/**
* @group("messages")
* @throws \Exception
*/
public function testMessageSendOrder()
{
$client = self::getApiClient(
null,
null,
false,
$this->getResponse(
'{"message_id":3636,"time":"2019-06-24T06:02:04.434291791Z"}',
201
)
);
$cost = new MessageCost();
$cost->setCurrency("");
$cost->setValue(500);
$delivery = new MessageDelivery();
$delivery->setAddress('address');
$delivery->setComment('comment');
$delivery->setName('test delivery');
$delivery->setPrice($cost);
$quantity = new MessageQuantity();
$quantity->setUnit('pcs');
$quantity->setValue(1);
$item = new MessageOrderItem();
$item->setName('product');
$item->setPrice($cost);
$item->setImg('https://example.com/image.jpeg');
$item->setQuantity($quantity);
$item->setUrl('https://example.com');
$orderStatus = new MessageStatus();
$orderStatus->setName('name');
$orderStatus->setCode('code');
$payment = new MessageOrderPaymentStatus();
$payment->setName('card');
$payment->setPayed(true);
$order = new MessageOrder();
$order->setCost($cost);
$order->setDelivery($delivery);
$order->setDate(date('Y-m-d\TH:i:s\.u\Z'));
$order->setItems([$item]);
$order->setUrl('https://example.com');
$order->setNumber('2038C');
$order->setPayments([$payment]);
$order->setStatus($orderStatus);
$request = new MessageSendRequest();
$request->setChatId(28);
$request->setType(Constants::MESSAGE_TYPE_ORDER);
$request->setScope(Constants::MESSAGE_SCOPE_PUBLIC);
$request->setOrder($order);
$response = $client->messageSend($request);
self::assertInstanceOf(MessageSendResponse::class, $response);
if ($response instanceof MessageSendResponse) {
self::assertTrue($response->isSuccessful());
self::assertCount(0, $response->getErrors());
self::assertEquals(3636, $response->getMessageId());
}
}
/**
* @group("messages")
* @throws \Exception
*/
public function testMessageSendProduct()
{
$client = self::getApiClient(
null,
null,
false,
$this->getResponse(
'{"message_id":3636,"time":"2019-06-24T06:02:04.434291791Z"}',
201
)
);
$cost = new MessageCost();
$cost->setCurrency("");
$cost->setValue(500);
$quantity = new MessageQuantity();
$quantity->setUnit('pcs');
$quantity->setValue(1);
$product = new MessageProduct();
$product->setId(1);
$product->setName('product');
$product->setUrl('https://example.com');
$product->setImg('https://example.com/image.jpg');
$product->setQuantity($quantity);
$product->setCost($cost);
$product->setArticle('article');
$request = new MessageSendRequest();
$request->setChatId(28);
$request->setType(Constants::MESSAGE_TYPE_PRODUCT);
$request->setScope(Constants::MESSAGE_SCOPE_PUBLIC);
$request->setProduct($product);
$response = $client->messageSend($request);
self::assertInstanceOf(MessageSendResponse::class, $response);
if ($response instanceof MessageSendResponse) {
self::assertTrue($response->isSuccessful());
self::assertCount(0, $response->getErrors());
self::assertEquals(3636, $response->getMessageId());
}
}
/**
@ -91,6 +221,7 @@ class MessagesTest extends TestCase
*/
public function testMessageEditError()
{
$this->expectException(\RuntimeException::class);
$client = self::getApiClient(
null,
null,
@ -105,10 +236,7 @@ class MessagesTest extends TestCase
$request->setId(0);
$request->setContent("Hello");
$response = $client->messageEdit($request);
self::assertTrue(!$response->isSuccessful());
self::assertEquals(1, count($response->getErrors()));
$client->messageEdit($request);
}
/**
@ -131,7 +259,7 @@ class MessagesTest extends TestCase
$response = $client->messageEdit($request);
self::assertTrue($response->isSuccessful());
self::assertEquals(0, count($response->getErrors()));
self::assertCount(0, $response->getErrors());
}
/**
@ -140,6 +268,7 @@ class MessagesTest extends TestCase
*/
public function testMessageDeleteError()
{
$this->expectException(\RuntimeException::class);
$client = self::getApiClient(
null,
null,
@ -150,10 +279,7 @@ class MessagesTest extends TestCase
)
);
$response = $client->messageDelete('0');
self::assertTrue(!$response->isSuccessful());
self::assertEquals(1, count($response->getErrors()));
$client->messageDelete('0');
}
/**
@ -172,6 +298,102 @@ class MessagesTest extends TestCase
$response = $client->messageDelete('3636');
self::assertTrue($response->isSuccessful());
self::assertEquals(0, count($response->getErrors()));
self::assertCount(0, $response->getErrors());
}
/**
* @group("messages")
* @throws \Exception
*/
public function testMessageSendSuggestions()
{
$client = self::getApiClient(
null,
null,
false,
$this->getResponse(
'{"message_id":3636,"time":"2019-06-24T06:02:04.434291791Z"}',
201
)
);
$suggestionsData = [
[
'title' => 'Hello',
'type' => 'text'
],
[
'type' => 'email'
],
[
'type' => 'phone'
],
];
$suggestions = [];
foreach ($suggestionsData as $suggestionsDatum) {
$suggestion = new Suggestion();
$suggestion->setType($suggestionsDatum['type']);
if (isset($suggestionsDatum['title'])) {
$suggestion->setTitle($suggestionsDatum['title']);
}
$suggestions[] = $suggestion;
}
$transportAttachments = new TransportAttachments();
$transportAttachments->setSuggestions($suggestions);
$request = new MessageSendRequest();
$request->setChatId(28);
$request->setScope(Constants::MESSAGE_SCOPE_PUBLIC);
$request->setContent("Hello");
$request->setTransportAttachments($transportAttachments);
$response = $client->messageSend($request);
self::assertInstanceOf(MessageSendResponse::class, $response);
if ($response instanceof MessageSendResponse) {
self::assertTrue($response->isSuccessful());
self::assertCount(0, $response->getErrors());
self::assertEquals(3636, $response->getMessageId());
}
}
public function testMessageSendItems()
{
$client = self::getApiClient(
null,
null,
false,
$this->getResponse(
'{"message_id":4242,"time":"2019-06-24T06:02:04.434291791Z"}',
201
)
);
$item = new Item();
$item->setCaption('demo caption');
$item->setId('e33e5398-814a-47d6-902a-466ba120ce45');
$request = new MessageSendRequest();
$request->setChatId(28);
$request->setScope(Constants::MESSAGE_SCOPE_PUBLIC);
$request->setContent("Hello");
$request->setItems([$item]);
$request->setNote('demo note');
$response = $client->messageSend($request);
self::assertInstanceOf(MessageSendResponse::class, $response);
if ($response instanceof MessageSendResponse) {
self::assertTrue($response->isSuccessful());
self::assertCount(0, $response->getErrors());
self::assertEquals(4242, $response->getMessageId());
}
}
}

View file

@ -0,0 +1,57 @@
<?php
namespace RetailCrm\Mg\Bot\Tests\Model;
use PHPStan\Testing\TestCase;
use RetailCrm\Common\Serializer;
use RetailCrm\Mg\Bot\Model\Request\BotsRequest;
use RetailCrm\Mg\Bot\Model\Request\ChannelsRequest;
use RetailCrm\Mg\Bot\Model\Request\ChatsRequest;
use RetailCrm\Mg\Bot\Model\Request\CustomersRequest;
use RetailCrm\Mg\Bot\Model\Request\DialogsRequest;
use RetailCrm\Mg\Bot\Model\Request\MembersRequest;
use RetailCrm\Mg\Bot\Model\Request\UsersRequest;
class ListEntityRequestTest extends TestCase
{
private const LIMIT = 100;
public function testListRequestsWithLimit(): void
{
$expected = json_encode(['limit' => self::LIMIT]);
$request = new BotsRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new ChannelsRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new ChatsRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new CustomersRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new DialogsRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new MembersRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new UsersRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
}
}

View file

@ -0,0 +1,94 @@
<?php
namespace RetailCrm\Mg\Bot\Tests\Model;
use RetailCrm\Common\Serializer;
use RetailCrm\Mg\Bot\Model\Entity\Message\Message;
use PHPUnit\Framework\TestCase;
class MessageTest extends TestCase
{
/**
* @dataProvider dataProvider_noContent
* @param $content
*/
public function testDeserialization_NoContent($content): void
{
$item = ['content' => $content];
/** @var Message $result */
$result = Serializer::deserialize($item, Message::class, Serializer::S_ARRAY);
self::assertNull($result->getContent());
}
/**
* @dataProvider dataProvider_withContent
* @param $content
*/
public function testDeserialization_WithContent($content): void
{
$item = ['content' => $content];
/** @var Message $result */
$result = Serializer::deserialize($item, Message::class, Serializer::S_ARRAY);
self::assertNotNull($result->getContent());
self::assertEquals($content, $result->getContent());
}
public function testDeserializationWithQuoute(): void
{
$json = file_get_contents(__DIR__ . '/../../../Resources/messageWithQuote.json');
/** @var Message $message */
$message = Serializer::deserialize($json, Message::class);
self::assertEquals(3373, $message->getId());
self::assertNotNull($message->getQuote());
self::assertEquals("22144962", $message->getQuote()->getId());
self::assertEquals("text", $message->getQuote()->getType());
self::assertEquals("11111", $message->getQuote()->getFrom()->getId());
self::assertEquals("Something content", $message->getQuote()->getContent());
self::assertNotNull($message->getQuote()->getTime());
}
public function testSerialization_NoContent(): void
{
$item = new Message();
$result = Serializer::serialize($item);
self::assertEquals('{}', $result);
}
/**
* @dataProvider dataProvider_withContent
* @param $content
* @param $json
*/
public function testSerialization_WithContent($content, $json): void
{
$item = new Message();
$item->setContent($content);
$result = Serializer::serialize($item);
self::assertEquals($json, $result);
}
public function dataProvider_noContent(): array
{
return [
[null],
];
}
public function dataProvider_withContent(): array
{
return [
['', '{"content":""}'],
['0', '{"content":"0"}'],
['Something', '{"content":"Something"}'],
];
}
}

View file

@ -0,0 +1,87 @@
<?php
/**
* PHP version 7.1
*
* RegisterTest.php
*
*/
namespace RetailCrm\Mg\Bot\Tests;
use RetailCrm\Common\Register;
use RetailCrm\Mg\Bot\Test\TestCase;
/**
* PHP version 7.0
*
* Class RegisterTest
*
* @package RetailCrm\Mg\Bot\Tests
*/
class RegisterTest extends TestCase
{
/** @var Register $register */
private static $register;
/**
* testGetArrayConfiguration
* @group("register")
*/
public function testGetArrayConfiguration()
{
static::assertRegister(static::getRegister()->getArrayConfiguration());
}
/**
* testGetJsonConfiguration
* @group("register")
*/
public function testGetJsonConfiguration()
{
static::assertRegister(json_decode(static::getRegister()->getJsonConfiguration(), true));
}
/**
* assertRegister asserts passed array properties with current register object
*
* @param array $serialized
*/
private static function assertRegister(array $serialized): void
{
static::assertNotEmpty($serialized, 'ERROR: Serialized array is empty');
if (!empty($serialized)) {
static::assertEquals(static::getRegister()->getName(), $serialized['name']);
static::assertEquals(static::getRegister()->getCode(), $serialized['code']);
static::assertEquals(static::getRegister()->getBaseUrl(), $serialized['baseUrl']);
static::assertEquals(static::getRegister()->getLogo(), $serialized['logo']);
static::assertEquals(static::getRegister()->getAccountUrl(), $serialized['accountUrl']);
static::assertEquals(static::getRegister()->getActions(), $serialized['actions']);
static::assertEquals(static::getRegister()->getActive(), $serialized['active']);
static::assertEquals(static::getRegister()->getAvailableCountries(), $serialized['availableCountries']);
static::assertEquals(static::getRegister()->getClientId(), $serialized['clientId']);
static::assertEquals(static::getRegister()->getIntegrationCode(), $serialized['integrationCode']);
static::assertEquals(static::getRegister()->getIntegrations(), $serialized['integrations']);
}
}
private static function getRegister(): Register
{
if (empty(static::$register)) {
static::$register = new Register();
static::$register->setName('name');
static::$register->setCode('code');
static::$register->setBaseUrl('https://example.com');
static::$register->setLogo('https://example.com/logo.png');
static::$register->setAccountUrl('https://example.com/account');
static::$register->setActions(['/activity']);
static::$register->setActive(true);
static::$register->setAvailableCountries(['RU']);
static::$register->setClientId('long random hash of /dev/urandom');
static::$register->setIntegrationCode('integrationCode');
static::$register->setIntegrations(['mgBot' => []]);
}
return static::$register;
}
}

View file

@ -0,0 +1,113 @@
<?php
namespace RetailCrm\Mg\Bot\Tests;
use RetailCrm\Common\Exception\NotFoundException;
use RetailCrm\Mg\Bot\Model\Request\TemplateSendRequest;
use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse;
use RetailCrm\Mg\Bot\Test\TestCase;
use RetailCrm\Mg\Bot\Model\Entity\Template;
/**
* PHP version 7.0
*
* Class TemplatesTest
*
* @package RetailCrm\Mg\Bot\Tests
*/
class TemplatesTest extends TestCase
{
/**
* @group("templates")
* @throws \Exception
*/
public function testTemplatesList()
{
$client = self::getApiClient(
null,
null,
false,
$this->getJsonResponse('templates')
);
$response = $client->templates();
static::assertCount(2, $response, "Incorrect templates count");
static::assertInstanceOf(Template\Template::class, $response[0], "Incorrect template instance");
$templateType = $response[0]->getHeader()['content']['type'];
static::assertStringContainsString("video", $templateType, "Incorrect template type");
}
/**
* @group("templates")
* @throws \Exception
*/
public function testTemplateSendNotFound()
{
$this->expectException(NotFoundException::class);
$client = self::getApiClient(
null,
null,
false,
$this->getErrorsResponse(404, "template id=3 was not found")
);
$request = new TemplateSendRequest();
$request->setPhone('123');
$client->templateSend(3, $request);
}
/**
* @group("templates")
* @throws \Exception
*/
public function testTemplateSendVariablesError()
{
$this->expectException(NotFoundException::class);
$client = self::getApiClient(
null,
null,
false,
$this->getErrorsResponse(404, "variables number doesn't match template")
);
$request = new TemplateSendRequest();
$request->setPhone('123');
$client->templateSend(2, $request);
}
/**
* @group("templates")
* @throws \Exception
*/
public function testTemplateSendSuccess()
{
$client = self::getApiClient(
null,
null,
false,
$this->getResponse(
'{"message_id":4242,"time":"2019-06-24T06:02:04.434291791Z"}',
201
)
);
$request = new TemplateSendRequest();
$request->setPhone('123');
$response = $client->templateSend(1, $request);
self::assertInstanceOf(MessageSendResponse::class, $response);
if ($response instanceof MessageSendResponse) {
self::assertTrue($response->isSuccessful());
self::assertCount(0, $response->getErrors());
self::assertEquals(4242, $response->getMessageId());
}
}
}

View file

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.1
*
* Class RegisterTest
*
* @package RetailCrm\Common\Tests
*/
namespace RetailCrm\Common\Tests;
use RetailCrm\Common\Register;
use PHPUnit\Framework\TestCase;
/**
* Class RegisterTest
*
* @package RetailCrm\Mg\Bot\Tests
*/
class RegisterTest extends TestCase
{
/**
* testGetArrayConfiguration
*/
public function testGetArrayConfiguration()
{
$register = new Register();
$register->setAccountUrl('https://example.com/settings');
$register->setActions(['ativity' => '/activity']);
$register->setActive(true);
$register->setBaseUrl('http:s//example.com');
$register->setClientId(hash('ripemd160', time()));
$register->setCode('somecode');
$register->setIntegrationCode('somecode');
$register->setLogo('https://example.com/logo.svg');
$register->setName('somename');
$array = $register->getArrayConfiguration();
self::assertArrayHasKey('baseUrl', $array);
self::assertArrayHasKey('integrationCode', $array);
self::assertArrayHasKey('clientId', $array);
}
}

View file

@ -42,5 +42,21 @@
"is_active": true,
"is_self": false,
"is_system": false
},
{
"id": 5,
"name": "Weird date formats bot",
"events": null,
"client_id": "identifier_4",
"avatar_url": "https://s3.retailcrm.pro/eu-central-1/retailcrm-billing/images/5b97bfd983d2b-bot-logo-2.svg",
"roles": [
"responsible"
],
"created_at": "2018-09-06T13:40:02Z",
"updated_at": "2018-09-12T06:15:32Z",
"deactivated_at": "2019-09-12T06:15:32Z",
"is_active": true,
"is_self": false,
"is_system": false
}
]
]

Some files were not shown because too many files have changed in this diff Show more