ldc-crm-client/src/Enums/ApiError.php

104 lines
3.6 KiB
PHP
Raw Normal View History

<?php
namespace LDC\LDCCRM\Enums;
2021-08-13 12:35:35 +02:00
use Kwaadpepper\Enum\BaseEnum;
/**
* This describes an API error.
*
* @method static self modelNotFound()
* The request model was not found (typically the customer)
*
* @method static self validationFailed()
* This means some data could not be validated,
* you may have to look into message to get the details
*
* @method static self customerExists()
* The customer already exists
*
* @method static self customerNotActivated()
* The customer account is not activated and cannot perform
* this action
*
* @method static self customerAlreadyActive()
* You have requested to activate a customer account,
* but it is already active
*
* @method static self singleOptinCustomerExists()
* You have requested to create a single optin for an email,
* but it already exists
*
* @method static self apiAuthFailed()
* The authentification to the api failed. You may have to
* check into config or .env file for your brand credentials
*
* @method static self authFailed()
* The authentification for this customer failed because of wrong credentials
*
* @method static self needAuth()
* This action requires to be authenticated
*
* @method static self methodNotAllowed()
* This http method is not allowed
*
* @method static self wrongTimeStamp()
* The timestamp given is wrong. This would happen in case if
* a replay attack scenario. Timestamps are provided in headers
* and in the http body
*
* @method static self throttleRequestsException()
* Too many requests have been attempted. The is a throttle security.
* Normally you should not trigger this.
* If this happens fill a ticket on https://supportweb.ldc.fr
2021-08-12 14:49:27 +02:00
* with some technical details
*
* @method static self authorizationException()
* You are maybe trying to access data that is out of your range.
* This should not happen normally, it is here to allow you to handle this case.
* If this happens fill a ticket on https://supportweb.ldc.fr
* with some technical details
*
* @package LDCCrmClient
* @subpackage enums
*/
2021-08-13 12:35:35 +02:00
class ApiError extends BaseEnum
{
public static function values(): array
{
return [
'modelNotFound' => 101,
'validationFailed' => 102,
'customerExists' => 103,
'customerAlreadyActive' => 110,
'customerNotActivated' => 116,
'authFailed' => 117,
'needAuth' => 118,
'apiAuthFailed' => 119,
'singleOptinCustomerExists' => 120,
'methodNotAllowed' => 150,
'wrongTimeStamp' => 151,
2021-08-12 14:49:27 +02:00
'authorizationException' => 403,
'throttleRequestsException' => 429
];
}
public static function labels(): array
{
return [
2021-08-16 13:22:56 +02:00
'modelNotFound' => '%s introuvable.',
'validationFailed' => 'Impossible de valider les données',
'customerExists' => 'L\'utilisateur est déjà enregistré sur ce site',
'customerNotActivated' => 'Le comtpe n\'est pas activé',
'customerAlreadyActive' => 'Le compte est déjà activé',
'singleOptinCustomerExists' => 'Le signle optin ne peut être ajouté car un compte existe.',
'authFailed' => 'Echec de l\'authentification',
'needAuth' => 'Vous devez être authentifié',
2021-08-16 08:06:54 +02:00
'methodNotAllowed' => 'This method is not allowed for this request',
'wrongTimeStamp' => 'Your request is malformed, please check timestamp header and parameter',
'authorizationException' => 'You are not autorized to access this',
'throttleRequestsException' => 'Throttle: too many request have been attempted, please retry later'
];
}
}