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DjLQ4IFS
 I41/I1gAm8HXVcJLxj8m2vbFFXdhptikKDmGD01NbAAHePjPjim9D2Z7r4BeSRgB
 oXVVi923OglJfVBMUSq0b3nD8GjGNNgnMucm5M3ObZrLE/zDATnXsa1JF0FtL3pb
 YlWSK3+zV+6A/2qO7O9Am46ZOMODP4QG+XkP65Y9vHDpW3FwjVJ/ELHzu3rGEfAJ
 RlABduAK
 =ainv
 -----END PGP SIGNATURE-----

Merge tag '2.2.0'

2.2.0
This commit is contained in:
Jérémy Munsch 2021-10-18 09:03:53 +02:00
commit 36709d3668
7 changed files with 286 additions and 34 deletions

View file

@ -1,5 +1,5 @@
{
"version": "2.1.8",
"version": "2.2.0",
"tokenTimeout": 60,
"apiRequestRatePerMinute": 256,
"servicesDBCache": 10

View file

@ -2,5 +2,9 @@
All notable changes to `CRM CLient V2` will be documented in this file.
# version 2.2.0
- Fixed Utils.php getResquest method
- Changed Arcadia mails, add customer parameters for these calls
# version 2.1.9
- Fixed method CrmClientModel::fill now validates data and put value to updatedValues array

View file

@ -3,7 +3,7 @@
"type": "library",
"description": "LDC CRM Client V2",
"license": "MIT",
"version": "2.1.9",
"version": "2.2.0",
"authors": [
{
"name": "Jérémy Munsch",

View file

@ -5,13 +5,21 @@ namespace LDC\LDCCRM\Models;
use LDC\LDCCRM\Enums\ApiStatus;
use LDC\LDCCRM\Enums\ArcadiaOrderType;
use LDC\LDCCRM\Utils;
use ReflectionClass;
use TypeError;
/**
* This class represents the customer info with
* the account validation status
*
* @property string $email Must be a rfc valid email on a valid domain name
* @property string $firstname The account first name
* @property string $lastname The account last name
* @property string $phone The account phone
* @property string $address The account address (street number, name, build, flat number)
* @property string $address2 The account phone (address complement)
* @property string $city The account city name
* @property string $postcode The account city postcode
*
* @property int $operation The arcadia operation code
* @property int $support_code The arcadia support code
* @property string $label_type_support The arcadia type support label
@ -27,6 +35,111 @@ use TypeError;
class ArcadiaMailDefault extends CrmClientModel
{
/**
* An RFC Valid Email
*
* Validate: rfc,dns,spoof,filter
*
* Required
* Min length N/A
* Max length 255
* Field Type varchar
*
* @var string
*/
private $email = null;
/**
* First name
*
* Required
* Min length 2
* Max length 255
* Field Type varchar
*
* @var string
*/
private $firstname = null;
/**
* Last name
*
* Required
* Min length 2
* Max length 255
* Field Type varchar
*
* @var string
*/
private $lastname = null;
/**
* The user phone
*
* Validate: sometimes,string
*
* Required
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $phone = null;
/**
* The user address (street number, name, etc)
*
* Validate: sometimes,string
*
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $address = null;
/**
* The user address 2nd part (street number, name, more, etc)
*
* Validate: sometimes,string
*
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $address2 = null;
/**
* The user address city
*
* Validate: sometimes,string
*
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $city = null;
/**
* The user address postcode
*
* Validate: string
*
* Required
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $postcode = null;
/**
* The arcadia operation code
*
@ -110,6 +223,9 @@ class ArcadiaMailDefault extends CrmClientModel
* @var array
*/
protected $modelFields = [
'email', 'firstname',
'lastname', 'phone', 'address',
'address2', 'city', 'postcode',
'operation', 'support_code', 'label_type_support',
'order_date', 'order_num', 'state_order',
'package_unit_weight',
@ -121,6 +237,14 @@ class ArcadiaMailDefault extends CrmClientModel
* @var array
*/
protected static $validation = [
'email' => 'required|email',
'firstname' => 'required|string|min:2|max:255',
'lastname' => 'required|string|min:2|max:255',
'phone' => 'sometimes|string|min:10|max:255',
'address' => 'sometimes|string|max:255',
'address2' => 'sometimes|string|max:255',
'city' => 'sometimes|string|max:255',
'postcode' => 'sometimes|string|max:255',
'operation' => 'required|int',
'support_code' => 'required|int',
'label_type_support' => 'required|string|min:2|max:255',
@ -233,20 +357,11 @@ class ArcadiaMailDefault extends CrmClientModel
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException
* If any error or \LDC\LDCCRM\Enums\ApiError occurs
*/
public function send(Customer $customer): bool
public function send(): bool
{
// validate customer hashcode
$refClass = new ReflectionClass(\get_class($customer));
$refMeth = $refClass->getMethod('validateValue');
$refMeth->setAccessible(true);
$refMeth->invokeArgs($customer, ['hashcode', $customer->hashcode]);
// Send mail
$data = $this->validateAllValues();
$this->validateAllValues();
static::setUpApiInterface(); // set apiInterface
$request = Utils::getResquest('apiV2.arcadia.outgoingMailDefault', [
'customer' => $customer->hashcode
], $data);
$request = Utils::getResquest('apiV2.arcadia.outgoingMailDefault', $this->jsonSerialize());
$response = static::$apiInterface->call($request);
if ($status = $response->status->equals(ApiStatus::OK())) {
$this->updatedValues = [];
@ -263,6 +378,16 @@ class ArcadiaMailDefault extends CrmClientModel
public function jsonSerialize()
{
return [
'deliver' => [
'email' => $this->email,
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'phone' => $this->phone,
'address' => $this->address,
'address2' => $this->address2,
'city' => $this->city,
'postcode' => $this->postcode,
],
'operation' => $this->operation,
'support_code' => $this->support_code,
'label_type_support' => $this->label_type_support,

View file

@ -5,7 +5,6 @@ namespace LDC\LDCCRM\Models;
use LDC\LDCCRM\Enums\ApiStatus;
use LDC\LDCCRM\Enums\ArcadiaOrderType;
use LDC\LDCCRM\Utils;
use ReflectionClass;
/**
* This class represents the customer info with
@ -15,6 +14,15 @@ use ReflectionClass;
* Validate: int
* Required
*
* @property string $email Must be a rfc valid email on a valid domain name
* @property string $firstname The account first name
* @property string $lastname The account last name
* @property string $phone The account phone
* @property string $address The account address (street number, name, build, flat number)
* @property string $address2 The account phone (address complement)
* @property string $city The account city name
* @property string $postcode The account city postcode
*
* @property int $support_code The arcadia support code
* @property string $label_type_support The arcadia type support label
* @property string $order_date The arcadia order date 'yyyy-mm-dd HH:ii:ss'
@ -28,6 +36,111 @@ use ReflectionClass;
class ArcadiaMailGame extends CrmClientModel
{
/**
* An RFC Valid Email
*
* Validate: rfc,dns,spoof,filter
*
* Required
* Min length N/A
* Max length 255
* Field Type varchar
*
* @var string
*/
private $email = null;
/**
* First name
*
* Required
* Min length 2
* Max length 255
* Field Type varchar
*
* @var string
*/
private $firstname = null;
/**
* Last name
*
* Required
* Min length 2
* Max length 255
* Field Type varchar
*
* @var string
*/
private $lastname = null;
/**
* The user phone
*
* Validate: sometimes,string
*
* Required
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $phone = null;
/**
* The user address (street number, name, etc)
*
* Validate: sometimes,string
*
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $address = null;
/**
* The user address 2nd part (street number, name, more, etc)
*
* Validate: sometimes,string
*
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $address2 = null;
/**
* The user address city
*
* Validate: sometimes,string
*
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $city = null;
/**
* The user address postcode
*
* Validate: string
*
* Required
* Min length NA
* Max length 255
* Field Type varchar
*
* @var string
*/
private $postcode = null;
/**
* @var int
* @access private
@ -95,6 +208,9 @@ class ArcadiaMailGame extends CrmClientModel
* @var array
*/
protected $modelFields = [
'email', 'firstname',
'lastname', 'phone', 'address',
'address2', 'city', 'postcode',
'operation', 'support_code', 'label_type_support',
'order_date', 'code_unique', 'code_on_pack'
];
@ -105,6 +221,14 @@ class ArcadiaMailGame extends CrmClientModel
* @var array
*/
protected static $validation = [
'email' => 'required|email',
'firstname' => 'required|string|min:2|max:255',
'lastname' => 'required|string|min:2|max:255',
'phone' => 'sometimes|string|min:10|max:255',
'address' => 'sometimes|string|max:255',
'address2' => 'sometimes|string|max:255',
'city' => 'sometimes|string|max:255',
'postcode' => 'sometimes|string|max:255',
'operation' => 'required|int',
'support_code' => 'required|int',
'label_type_support' => 'required|string|min:2|max:255',
@ -150,20 +274,11 @@ class ArcadiaMailGame extends CrmClientModel
* @throws \LDC\LDCCRM\Exceptions\ApiErrorException
* If any error or \LDC\LDCCRM\Enums\ApiError occurs
*/
public function send(Customer $customer): bool
public function send(): bool
{
// validate customer hashcode
$refClass = new ReflectionClass(\get_class($customer));
$refMeth = $refClass->getMethod('validateValue');
$refMeth->setAccessible(true);
$refMeth->invokeArgs($customer, ['hashcode', $customer->hashcode]);
// Send mail
$data = $this->validateAllValues();
$this->validateAllValues();
static::setUpApiInterface(); // set apiInterface
$request = Utils::getResquest('apiV2.arcadia.outgoingMailGame', [
'customer' => $customer->hashcode
], $data);
$request = Utils::getResquest('apiV2.arcadia.outgoingMailGame', $this->jsonSerialize());
$response = static::$apiInterface->call($request);
if ($status = $response->status->equals(ApiStatus::OK())) {
$this->updatedValues = [];
@ -180,6 +295,16 @@ class ArcadiaMailGame extends CrmClientModel
public function jsonSerialize()
{
return [
'deliver' => [
'email' => $this->email,
'firstname' => $this->firstname,
'lastname' => $this->lastname,
'phone' => $this->phone,
'address' => $this->address,
'address2' => $this->address2,
'city' => $this->city,
'postcode' => $this->postcode,
],
'operation' => $this->operation,
'support_code' => $this->support_code,
'label_type_support' => $this->label_type_support,

View file

@ -131,7 +131,7 @@ class Utils
return \is_string($data[$attribute]) and
\strlen($data[$attribute]) >= (int)$rParams[0];
},
'error' => self::translate($attribute) . " doit avoir moins ou $rParams[0] caratères"
'error' => self::translate($attribute) . " doit avoir au moins $rParams[0] caratères"
];
break;
case 'max':
@ -308,11 +308,9 @@ class Utils
$matchedIndex[$matches[1][$k]] = $query[$matches[1][$k]];
}
}
$query = \array_flip($query);
foreach ($matchedIndex as $key) {
foreach ($matchedIndex as $key => $value) {
unset($query[$key]);
}
$query = \array_flip($query);
if (count($query)) {
$route['uri'] = sprintf('%s?%s', $route['uri'], \http_build_query($query));
}

View file

@ -63,13 +63,13 @@
]
},
"apiV2.arcadia.outgoingMailDefault": {
"uri": "api/v2/arcadia/outgoing-mail/{customer}/default",
"uri": "api/v2/arcadia/outgoing-mail/default",
"methods": [
"POST"
]
},
"apiV2.arcadia.outgoingMailGame": {
"uri": "api/v2/arcadia/outgoing-mail/{customer}/game",
"uri": "api/v2/arcadia/outgoing-mail/game",
"methods": [
"POST"
]