ldc-crm/app/Http/Requests/Api/V2/SendArchadiaDefaultMailRequest.php

113 lines
4.3 KiB
PHP
Raw Permalink Normal View History

2021-03-14 10:45:42 +01:00
<?php
namespace App\Http\Requests\Api\V2;
2021-03-14 10:45:42 +01:00
use App\Enums\ArcadiaOrderType;
use App\Http\Sanitizers\RemoveSpaces;
2021-03-14 10:45:42 +01:00
use ArondeParon\RequestSanitizer\Sanitizers\RemoveNonNumeric;
use ArondeParon\RequestSanitizer\Sanitizers\Trim;
use ArondeParon\RequestSanitizer\Traits\SanitizesInputs;
2023-09-04 13:08:34 +02:00
use Illuminate\Validation\Rules\Enum;
2021-03-14 10:45:42 +01:00
/**
* @codeCoverageIgnore
*/
class SendArchadiaDefaultMailRequest extends BaseApiRequest
2021-03-14 10:45:42 +01:00
{
use SanitizesInputs;
Version 3.0.0 This removes api authentification with token in favor of signature method. Refactorize code and clean up. It add more unit test plus code coverage in test/converage. - Added config.api.timestampTimeout - Added Helper::signRequest This calculates the request signature - Added more unit tests and extend code coverage. - Added rate limiter for web routes - Added RemoveSpaces Sanitizer on api requests - Added stress test suite - Changed AuthServiceProvider api-token to api-hmac - Changed CustomerSeeder to have at least of customer activated (for unit tests) - Changed used transation for saveing multiple models - Changed, in ServiceController generateApiToken to generateServicePassword - Changed, timestamp has to be send in request with a DateTime format, it also has to a UTC value - Composer added brianium/paratest - Composer update - Fixed case where removing single optin could be the wrong one (not for the good service) - Fixed customer delete - Fixed customer would not be resolved by brand. - Fixed Really check that request is json checking body content, preventing sending malformed requests - Remove ApiError::needAuth - Removed api_token - Removed ApiController::authenticate - Removed config.api.tokenTimeout - Removed Header check or usage because of HAProxy doing weird stuff - Removed lock files from gitignore - Removed memcached dependency - Removed unused questions resources api routes - Removed workspace file Migrations - Added unique index on services.bearer_token - Changed customer_id on customer_answer is nullable - Changed services.bearer_pwd length to 312 (the size of the token) - Dropped services.api_token and service.api_token_date
2021-12-19 15:57:24 +01:00
/**
* Using these sanitizers before proceeding the request.
*
Version 3.0.0 This removes api authentification with token in favor of signature method. Refactorize code and clean up. It add more unit test plus code coverage in test/converage. - Added config.api.timestampTimeout - Added Helper::signRequest This calculates the request signature - Added more unit tests and extend code coverage. - Added rate limiter for web routes - Added RemoveSpaces Sanitizer on api requests - Added stress test suite - Changed AuthServiceProvider api-token to api-hmac - Changed CustomerSeeder to have at least of customer activated (for unit tests) - Changed used transation for saveing multiple models - Changed, in ServiceController generateApiToken to generateServicePassword - Changed, timestamp has to be send in request with a DateTime format, it also has to a UTC value - Composer added brianium/paratest - Composer update - Fixed case where removing single optin could be the wrong one (not for the good service) - Fixed customer delete - Fixed customer would not be resolved by brand. - Fixed Really check that request is json checking body content, preventing sending malformed requests - Remove ApiError::needAuth - Removed api_token - Removed ApiController::authenticate - Removed config.api.tokenTimeout - Removed Header check or usage because of HAProxy doing weird stuff - Removed lock files from gitignore - Removed memcached dependency - Removed unused questions resources api routes - Removed workspace file Migrations - Added unique index on services.bearer_token - Changed customer_id on customer_answer is nullable - Changed services.bearer_pwd length to 312 (the size of the token) - Dropped services.api_token and service.api_token_date
2021-12-19 15:57:24 +01:00
* @var array
*/
2021-03-14 10:45:42 +01:00
protected $sanitizers = [
2023-09-04 13:08:34 +02:00
'label_type_support' => Trim::class,
'operation' => Trim::class,
'order_date' => Trim::class,
'order_num' => RemoveNonNumeric::class,
2021-03-14 10:45:42 +01:00
'package_unit_weight' => RemoveNonNumeric::class,
2023-09-04 13:08:34 +02:00
'support_code' => Trim::class,
'deliver.firstname' => Trim::class,
'deliver.lastname' => Trim::class,
'deliver.email' => Trim::class,
'deliver.address' => Trim::class,
'deliver.address2' => Trim::class,
'deliver.city' => Trim::class,
'deliver.postcode' => Trim::class,
'deliver.phone' => [Trim::class, RemoveSpaces::class]
2021-03-14 10:45:42 +01:00
];
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
2023-09-04 13:08:34 +02:00
'label_type_support' => 'required|string',
'operation' => 'required|int',
'order_date' => 'required|date',
'order_num' => 'required|numeric',
'package_unit_weight' => 'required|integer',
2023-09-04 13:08:34 +02:00
'state_order' => [
'required',
2023-09-04 13:08:34 +02:00
new Enum(ArcadiaOrderType::class)
2021-03-14 10:45:42 +01:00
],
2023-09-04 13:08:34 +02:00
'support_code' => 'required|int',
'deliver' => 'required|array',
'deliver.firstname' => 'required|string|min:1|max:255',
'deliver.lastname' => 'required|string|min:1|max:255',
'deliver.email' => 'required|email:rfc,dns,spoof,filter|max:255',
'deliver.address' => 'required|string|min:2|max:255',
'deliver.address2' => 'sometimes|string|min:2|max:255',
'deliver.city' => 'required|string|min:2|max:255',
'deliver.postcode' => 'required|string|postal_code:FR|max:255',
'deliver.phone' => 'present|string|nullable|phone:FR|max:255',
];
}
Version 3.0.0 This removes api authentification with token in favor of signature method. Refactorize code and clean up. It add more unit test plus code coverage in test/converage. - Added config.api.timestampTimeout - Added Helper::signRequest This calculates the request signature - Added more unit tests and extend code coverage. - Added rate limiter for web routes - Added RemoveSpaces Sanitizer on api requests - Added stress test suite - Changed AuthServiceProvider api-token to api-hmac - Changed CustomerSeeder to have at least of customer activated (for unit tests) - Changed used transation for saveing multiple models - Changed, in ServiceController generateApiToken to generateServicePassword - Changed, timestamp has to be send in request with a DateTime format, it also has to a UTC value - Composer added brianium/paratest - Composer update - Fixed case where removing single optin could be the wrong one (not for the good service) - Fixed customer delete - Fixed customer would not be resolved by brand. - Fixed Really check that request is json checking body content, preventing sending malformed requests - Remove ApiError::needAuth - Removed api_token - Removed ApiController::authenticate - Removed config.api.tokenTimeout - Removed Header check or usage because of HAProxy doing weird stuff - Removed lock files from gitignore - Removed memcached dependency - Removed unused questions resources api routes - Removed workspace file Migrations - Added unique index on services.bearer_token - Changed customer_id on customer_answer is nullable - Changed services.bearer_pwd length to 312 (the size of the token) - Dropped services.api_token and service.api_token_date
2021-12-19 15:57:24 +01:00
/**
* Attributes.
Version 3.0.0 This removes api authentification with token in favor of signature method. Refactorize code and clean up. It add more unit test plus code coverage in test/converage. - Added config.api.timestampTimeout - Added Helper::signRequest This calculates the request signature - Added more unit tests and extend code coverage. - Added rate limiter for web routes - Added RemoveSpaces Sanitizer on api requests - Added stress test suite - Changed AuthServiceProvider api-token to api-hmac - Changed CustomerSeeder to have at least of customer activated (for unit tests) - Changed used transation for saveing multiple models - Changed, in ServiceController generateApiToken to generateServicePassword - Changed, timestamp has to be send in request with a DateTime format, it also has to a UTC value - Composer added brianium/paratest - Composer update - Fixed case where removing single optin could be the wrong one (not for the good service) - Fixed customer delete - Fixed customer would not be resolved by brand. - Fixed Really check that request is json checking body content, preventing sending malformed requests - Remove ApiError::needAuth - Removed api_token - Removed ApiController::authenticate - Removed config.api.tokenTimeout - Removed Header check or usage because of HAProxy doing weird stuff - Removed lock files from gitignore - Removed memcached dependency - Removed unused questions resources api routes - Removed workspace file Migrations - Added unique index on services.bearer_token - Changed customer_id on customer_answer is nullable - Changed services.bearer_pwd length to 312 (the size of the token) - Dropped services.api_token and service.api_token_date
2021-12-19 15:57:24 +01:00
*
* @return array
*/
public function attributes(): array
{
return [
2023-09-04 13:08:34 +02:00
'label_type_support' => trans('label type support'),
'operation' => trans('code opération'),
'order_date' => trans('date de la commande'),
'order_num' => trans('numero de commande'),
'package_unit_weight' => trans('poids unitaire du paquet'),
2023-09-04 13:08:34 +02:00
'state_order' => trans('type de commande arcadia'),
'support_code' => trans('code de support'),
'deliver' => trans('coordonées de livraison'),
'deliver.civility' => trans('civilitée dans coordonées de livraison'),
'deliver.firstname' => trans('prénom dans coordonées de livraison'),
'deliver.lastname' => trans('nom dans coordonées de livraison'),
'deliver.address' => trans('adresse dans coordonées de livraison'),
'deliver.postcode' => trans('code postal dans coordonées de livraison'),
'deliver.phone' => trans('téléphone dans coordonées de livraison'),
'deliver.city' => trans('ville dans coordonées de livraison'),
'deliver.email' => trans('e-mail dans coordonées de livraison'),
];
}
Version 3.0.0 This removes api authentification with token in favor of signature method. Refactorize code and clean up. It add more unit test plus code coverage in test/converage. - Added config.api.timestampTimeout - Added Helper::signRequest This calculates the request signature - Added more unit tests and extend code coverage. - Added rate limiter for web routes - Added RemoveSpaces Sanitizer on api requests - Added stress test suite - Changed AuthServiceProvider api-token to api-hmac - Changed CustomerSeeder to have at least of customer activated (for unit tests) - Changed used transation for saveing multiple models - Changed, in ServiceController generateApiToken to generateServicePassword - Changed, timestamp has to be send in request with a DateTime format, it also has to a UTC value - Composer added brianium/paratest - Composer update - Fixed case where removing single optin could be the wrong one (not for the good service) - Fixed customer delete - Fixed customer would not be resolved by brand. - Fixed Really check that request is json checking body content, preventing sending malformed requests - Remove ApiError::needAuth - Removed api_token - Removed ApiController::authenticate - Removed config.api.tokenTimeout - Removed Header check or usage because of HAProxy doing weird stuff - Removed lock files from gitignore - Removed memcached dependency - Removed unused questions resources api routes - Removed workspace file Migrations - Added unique index on services.bearer_token - Changed customer_id on customer_answer is nullable - Changed services.bearer_pwd length to 312 (the size of the token) - Dropped services.api_token and service.api_token_date
2021-12-19 15:57:24 +01:00
/**
* Messages.
Version 3.0.0 This removes api authentification with token in favor of signature method. Refactorize code and clean up. It add more unit test plus code coverage in test/converage. - Added config.api.timestampTimeout - Added Helper::signRequest This calculates the request signature - Added more unit tests and extend code coverage. - Added rate limiter for web routes - Added RemoveSpaces Sanitizer on api requests - Added stress test suite - Changed AuthServiceProvider api-token to api-hmac - Changed CustomerSeeder to have at least of customer activated (for unit tests) - Changed used transation for saveing multiple models - Changed, in ServiceController generateApiToken to generateServicePassword - Changed, timestamp has to be send in request with a DateTime format, it also has to a UTC value - Composer added brianium/paratest - Composer update - Fixed case where removing single optin could be the wrong one (not for the good service) - Fixed customer delete - Fixed customer would not be resolved by brand. - Fixed Really check that request is json checking body content, preventing sending malformed requests - Remove ApiError::needAuth - Removed api_token - Removed ApiController::authenticate - Removed config.api.tokenTimeout - Removed Header check or usage because of HAProxy doing weird stuff - Removed lock files from gitignore - Removed memcached dependency - Removed unused questions resources api routes - Removed workspace file Migrations - Added unique index on services.bearer_token - Changed customer_id on customer_answer is nullable - Changed services.bearer_pwd length to 312 (the size of the token) - Dropped services.api_token and service.api_token_date
2021-12-19 15:57:24 +01:00
*
* @return array
*/
public function messages(): array
{
return [
2023-09-04 13:08:34 +02:00
'deliver.phone.phone' => trans('Le champ :attribute est invalide, il accepte les numéros
des pays suivants: France.'),
'deliver.postcode.postal_code' => trans('Le champ :attribute accepte les codes postaux des pays
suivants :countries comme par exemple :examples.'),
2021-03-14 10:45:42 +01:00
];
}
}