Merge tag '2.1.1'
This commit is contained in:
commit
0b2c4b4ec3
5 changed files with 506 additions and 109 deletions
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"tokenTimeout": 60,
|
||||
"apiRequestRatePerMinute": 256
|
||||
"apiRequestRatePerMinute": 256,
|
||||
"servicesDBCache": 10
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
"type": "library",
|
||||
"description": "LDC CRM Client V2",
|
||||
"license": "MIT",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jérémy Munsch",
|
||||
|
|
@ -19,12 +19,14 @@
|
|||
"LDC"
|
||||
],
|
||||
"require": {
|
||||
"ext-memcached": "^3.1",
|
||||
"ext-curl": "^7.3",
|
||||
"php": "^7.3",
|
||||
"kwaadpepper/enum": "^2.0",
|
||||
"vlucas/phpdotenv": "^5.3",
|
||||
"guzzlehttp/guzzle": "^7.3",
|
||||
"respect/validation": "^2.2"
|
||||
"respect/validation": "^2.2",
|
||||
"cache/memcached-adapter": "^1.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~9.0",
|
||||
|
|
|
|||
516
composer.lock
generated
516
composer.lock
generated
|
|
@ -4,8 +4,271 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "ce52e2d36e04d753ed0f376f03042c7a",
|
||||
"content-hash": "9be13d218529e5e1aa6290b563b1fcda",
|
||||
"packages": [
|
||||
{
|
||||
"name": "cache/adapter-common",
|
||||
"version": "1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-cache/adapter-common.git",
|
||||
"reference": "6b87c5cbdf03be42437b595dbe5de8e97cd1d497"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-cache/adapter-common/zipball/6b87c5cbdf03be42437b595dbe5de8e97cd1d497",
|
||||
"reference": "6b87c5cbdf03be42437b595dbe5de8e97cd1d497",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"cache/tag-interop": "^1.0",
|
||||
"php": "^5.6 || ^7.0 || ^8.0",
|
||||
"psr/cache": "^1.0",
|
||||
"psr/log": "^1.0",
|
||||
"psr/simple-cache": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"cache/integration-tests": "^0.16",
|
||||
"phpunit/phpunit": "^5.7.21"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Cache\\Adapter\\Common\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aaron Scherer",
|
||||
"email": "aequasi@gmail.com",
|
||||
"homepage": "https://github.com/aequasi"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Nyholm",
|
||||
"email": "tobias.nyholm@gmail.com",
|
||||
"homepage": "https://github.com/nyholm"
|
||||
}
|
||||
],
|
||||
"description": "Common classes for PSR-6 adapters",
|
||||
"homepage": "http://www.php-cache.com/en/latest/",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"psr-6",
|
||||
"tag"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-cache/adapter-common/tree/1.2.0"
|
||||
},
|
||||
"time": "2020-12-14T12:17:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "cache/hierarchical-cache",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-cache/hierarchical-cache.git",
|
||||
"reference": "ba3746c65461b17154fb855068403670fd7fa2d3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-cache/hierarchical-cache/zipball/ba3746c65461b17154fb855068403670fd7fa2d3",
|
||||
"reference": "ba3746c65461b17154fb855068403670fd7fa2d3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"cache/adapter-common": "^1.0",
|
||||
"php": "^5.6 || ^7.0 || ^8.0",
|
||||
"psr/cache": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7.21"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Cache\\Hierarchy\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aaron Scherer",
|
||||
"email": "aequasi@gmail.com",
|
||||
"homepage": "https://github.com/aequasi"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Nyholm",
|
||||
"email": "tobias.nyholm@gmail.com",
|
||||
"homepage": "https://github.com/nyholm"
|
||||
}
|
||||
],
|
||||
"description": "A helper trait and interface to your PSR-6 cache to support hierarchical keys.",
|
||||
"homepage": "http://www.php-cache.com/en/latest/",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"hierarchical",
|
||||
"hierarchy",
|
||||
"psr-6"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-cache/hierarchical-cache/tree/1.1.0"
|
||||
},
|
||||
"time": "2020-12-14T12:17:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "cache/memcached-adapter",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-cache/memcached-adapter.git",
|
||||
"reference": "3e2105684bc2813646c2f44ce9c403020ff2145f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-cache/memcached-adapter/zipball/3e2105684bc2813646c2f44ce9c403020ff2145f",
|
||||
"reference": "3e2105684bc2813646c2f44ce9c403020ff2145f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"cache/adapter-common": "^1.0",
|
||||
"cache/hierarchical-cache": "^1.0",
|
||||
"php": "^5.6 || ^7.0 || ^8.0",
|
||||
"psr/cache": "^1.0",
|
||||
"psr/simple-cache": "^1.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/cache-implementation": "^1.0",
|
||||
"psr/simple-cache-implementation": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"cache/integration-tests": "^0.16",
|
||||
"phpunit/phpunit": "^5.7.21"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-memcached": "The extension required to use this pool."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Cache\\Adapter\\Memcached\\": ""
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Aaron Scherer",
|
||||
"email": "aequasi@gmail.com",
|
||||
"homepage": "https://github.com/aequasi"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Nyholm",
|
||||
"email": "tobias.nyholm@gmail.com",
|
||||
"homepage": "https://github.com/nyholm"
|
||||
}
|
||||
],
|
||||
"description": "A PSR-6 cache implementation using Memcached. This implementation supports tags",
|
||||
"homepage": "http://www.php-cache.com/en/latest/",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"memcached",
|
||||
"psr-6",
|
||||
"tag"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-cache/memcached-adapter/tree/1.1.0"
|
||||
},
|
||||
"time": "2020-12-14T12:17:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "cache/tag-interop",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-cache/tag-interop.git",
|
||||
"reference": "909a5df87e698f1665724a9e84851c11c45fbfb9"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-cache/tag-interop/zipball/909a5df87e698f1665724a9e84851c11c45fbfb9",
|
||||
"reference": "909a5df87e698f1665724a9e84851c11c45fbfb9",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.5 || ^7.0 || ^8.0",
|
||||
"psr/cache": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Cache\\TagInterop\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Tobias Nyholm",
|
||||
"email": "tobias.nyholm@gmail.com",
|
||||
"homepage": "https://github.com/nyholm"
|
||||
},
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com",
|
||||
"homepage": "https://github.com/nicolas-grekas"
|
||||
}
|
||||
],
|
||||
"description": "Framework interoperable interfaces for tags",
|
||||
"homepage": "https://www.php-cache.com/en/latest/",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"psr",
|
||||
"psr6",
|
||||
"tag"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/php-cache/tag-interop/issues",
|
||||
"source": "https://github.com/php-cache/tag-interop/tree/1.0.1"
|
||||
},
|
||||
"time": "2020-12-04T14:11:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "graham-campbell/result-type",
|
||||
"version": "v1.0.1",
|
||||
|
|
@ -434,6 +697,55 @@
|
|||
],
|
||||
"time": "2020-07-20T17:29:33+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/cache",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/cache.git",
|
||||
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
|
||||
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Cache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for caching libraries",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"psr",
|
||||
"psr-6"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/cache/tree/master"
|
||||
},
|
||||
"time": "2016-08-06T20:24:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/http-client",
|
||||
"version": "1.0.1",
|
||||
|
|
@ -594,6 +906,107 @@
|
|||
},
|
||||
"time": "2016-08-06T14:39:51+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
|
||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Log\\": "Psr/Log/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for logging libraries",
|
||||
"homepage": "https://github.com/php-fig/log",
|
||||
"keywords": [
|
||||
"log",
|
||||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/log/tree/1.1.4"
|
||||
},
|
||||
"time": "2021-05-03T11:20:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/simple-cache",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/simple-cache.git",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\SimpleCache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for simple caching",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"psr",
|
||||
"psr-16",
|
||||
"simple-cache"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/simple-cache/tree/master"
|
||||
},
|
||||
"time": "2017-10-23T01:57:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ralouphie/getallheaders",
|
||||
"version": "3.0.3",
|
||||
|
|
@ -3617,107 +4030,6 @@
|
|||
},
|
||||
"time": "2019-01-08T18:20:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.1.4",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
|
||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Log\\": "Psr/Log/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for logging libraries",
|
||||
"homepage": "https://github.com/php-fig/log",
|
||||
"keywords": [
|
||||
"log",
|
||||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/log/tree/1.1.4"
|
||||
},
|
||||
"time": "2021-05-03T11:20:27+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/simple-cache",
|
||||
"version": "1.0.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/simple-cache.git",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\SimpleCache\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interfaces for simple caching",
|
||||
"keywords": [
|
||||
"cache",
|
||||
"caching",
|
||||
"psr",
|
||||
"psr-16",
|
||||
"simple-cache"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/simple-cache/tree/master"
|
||||
},
|
||||
"time": "2017-10-23T01:57:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "ramsey/collection",
|
||||
"version": "1.1.3",
|
||||
|
|
|
|||
|
|
@ -272,10 +272,10 @@ class Customer extends CrmClientModel
|
|||
'password' => 'required|min:8|max:255|mixedCase|containDigit|containSymbol',
|
||||
'birth_date' => 'required|date_format:Y-m-d',
|
||||
'phone' => 'sometimes|string|min:10|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'address' => 'sometimes|string|max:255',
|
||||
'address2' => 'sometimes|string|max:255',
|
||||
'city' => 'required|string|max:255',
|
||||
'postcode' => 'required|string|max:255',
|
||||
'city' => 'sometimes|string|max:255',
|
||||
'postcode' => 'sometimes|string|max:255',
|
||||
'country' => ['sometimes'],
|
||||
'opt_in' => 'required|bool',
|
||||
'status' => 'required|bool',
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace LDC\LDCCRM\Transport;
|
||||
|
||||
use Cache\Adapter\Memcached\MemcachedCachePool;
|
||||
use LDC\LDCCRM\Enums\ApiError;
|
||||
use LDC\LDCCRM\Enums\ApiStatus;
|
||||
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
||||
|
|
@ -60,8 +61,28 @@ class ApiInterface
|
|||
|
||||
protected static $authentification = null;
|
||||
|
||||
/**
|
||||
* Memcached client
|
||||
*
|
||||
* @var \Memcached
|
||||
*/
|
||||
protected static $memcachedCient = null;
|
||||
|
||||
/**
|
||||
* Memcached Pool
|
||||
*
|
||||
* @var \Cache\Adapter\Memcached\MemcachedCachePool
|
||||
*/
|
||||
protected static $memcachedPool = null;
|
||||
|
||||
public function __construct(string $endpoint = null, string $bearerToken = null, string $bearerPwd = null)
|
||||
{
|
||||
if (!static::$memcachedCient) {
|
||||
static::$memcachedCient = new \Memcached();
|
||||
static::$memcachedCient->addServer('127.0.0.1', 11211);
|
||||
static::$memcachedPool = new MemcachedCachePool(static::$memcachedCient);
|
||||
}
|
||||
|
||||
static::$endpoint = static::$endpoint ?: $endpoint;
|
||||
static::$bearerToken = static::$bearerToken ?: $bearerToken;
|
||||
static::$bearerPwd = static::$bearerPwd ?: $bearerPwd;
|
||||
|
|
@ -116,6 +137,7 @@ class ApiInterface
|
|||
}
|
||||
if ($response->data and isset($response->data['api_token'])) {
|
||||
static::$apiToken = $response->data['api_token'];
|
||||
$this->storeCacheValue('api_token', static::$apiToken);
|
||||
}
|
||||
} catch (ApiErrorException $e) {
|
||||
if ($e->getApiError()->equals(ApiError::needAuth()) and !$request->maxAttempted()) {
|
||||
|
|
@ -169,6 +191,20 @@ class ApiInterface
|
|||
$data = [
|
||||
'timestamp' => \time()
|
||||
];
|
||||
/**
|
||||
* Api Token à partir de memcached
|
||||
* permet d'eviter la génération de token à répétition entre de multiples
|
||||
* process php venant du client.
|
||||
* En effet les variables statiques ne sont pas partagés
|
||||
* entre les process eg: apache lance 8 process pour un site.
|
||||
* De plus entres les requetes elles ne sont pas partagés (logiquement)
|
||||
* On se retrouverai avec en permanence ds call sur login sans jamais aboutir
|
||||
* car le Api token sera régénéré en permanence
|
||||
*/
|
||||
$apiToken = $this->readCacheValue('api_token');
|
||||
if (static::$apiToken !== $apiToken) {
|
||||
static::$apiToken = $apiToken ?: null;
|
||||
}
|
||||
if (static::$apiToken) {
|
||||
$data['api_token'] = static::$apiToken;
|
||||
}
|
||||
|
|
@ -230,4 +266,50 @@ class ApiInterface
|
|||
}
|
||||
$request->setHidden($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate prefix by creating a md5 hash
|
||||
* using LDC_LDCCRM_CLIENTv2_MD5HASH
|
||||
* where MD5HASH is static::$endpoint . static::$bearerToken . static::$bearerPwd
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getMemcachedPrefix(): string
|
||||
{
|
||||
return sprintf(
|
||||
'LDC_LDCCRM_CLIENTv2_%s',
|
||||
md5(static::$endpoint . static::$bearerToken . static::$bearerPwd)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set memcached value
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @return void
|
||||
*/
|
||||
public function storeCacheValue(string $name, $value): void
|
||||
{
|
||||
static::$memcachedPool->setDirectValue(sprintf(
|
||||
'%s_%s',
|
||||
$this->getMemcachedPrefix(),
|
||||
$name
|
||||
), $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get memcached value
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function readCacheValue(string $name)
|
||||
{
|
||||
return static::$memcachedPool->getDirectValue(sprintf(
|
||||
'%s_%s',
|
||||
$this->getMemcachedPrefix(),
|
||||
$name
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue