ldc-crm/app/Enums/ApiError.php

45 lines
2 KiB
PHP
Raw Normal View History

2021-03-14 10:45:42 +01:00
<?php
namespace App\Enums;
2023-09-04 13:08:34 +02:00
use App\Traits\Enums\BaseEnum;
2021-03-14 10:45:42 +01:00
2023-09-04 13:08:34 +02:00
enum ApiError: int
2021-03-14 10:45:42 +01:00
{
2023-09-04 13:08:34 +02:00
use BaseEnum;
case modelNotFound = 101;
case validationFailed = 102;
case customerExists = 103;
case customerAlreadyActive = 110;
case customerNotActivated = 116;
case authFailed = 117;
case apiAuthFailed = 119;
case singleOptinCustomerExists = 120;
case methodNotAllowed = 150;
case wrongTimeStamp = 151;
case missingParameter = 400;
case authorizationException = 403;
case throttleRequestsException = 429;
2021-03-14 10:45:42 +01:00
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
/**
2023-09-04 13:08:34 +02:00
* Optionnal labels definition
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
*/
2023-09-04 13:08:34 +02:00
private const LABELS = [
self::modelNotFound->name => '%s introuvable.',
self::validationFailed->name => 'Impossible de valider les données',
self::customerExists->name => 'L\'utilisateur est déjà enregistré sur ce site',
self::customerNotActivated->name => 'Le compte n\'est pas activé',
self::customerAlreadyActive->name => 'Le compte est déjà activé',
self::singleOptinCustomerExists->name => 'Le single optin ne peut être ajouté car un compte existe.',
self::authFailed->name => 'Echec de l\'authentification du compte',
self::apiAuthFailed->name => 'Echec de l\'authentification client à l\'Api LDC-CRM pour ce service',
self::methodNotAllowed->name => 'This method is not allowed for this request',
self::wrongTimeStamp->name => 'Your request is malformed, please check timestamp header and
parameter',
self::missingParameter->name => 'The request is missing some parameters',
self::authorizationException->name => 'You are not autorized to access this',
self::throttleRequestsException->name => 'Throttle: too many request have been attempted, please retry later'
];
2021-03-14 10:45:42 +01:00
}