ldc-crm/app/Enums/ApiError.php

104 lines
3.7 KiB
PHP
Raw Normal View History

2021-03-14 10:45:42 +01:00
<?php
namespace App\Enums;
use Kwaadpepper\Enum\BaseEnum;
/**
2021-08-09 08:55:39 +02:00
* This describes an API error.
*
2021-03-14 10:45:42 +01:00
* @method static self modelNotFound()
2021-08-09 08:55:39 +02:00
* The request model was not found (typically the customer)
*
2021-03-14 10:45:42 +01:00
* @method static self validationFailed()
2021-08-09 08:55:39 +02:00
* This means some data could not be validated,
* you may have to look into message to get the details
*
2021-03-14 10:45:42 +01:00
* @method static self customerExists()
2021-08-09 08:55:39 +02:00
* The customer already exists
*
2021-03-14 10:45:42 +01:00
* @method static self customerNotActivated()
2021-08-09 08:55:39 +02:00
* The customer account is not activated and cannot perform
* this action
*
2021-03-14 10:45:42 +01:00
* @method static self customerAlreadyActive()
2021-08-09 08:55:39 +02:00
* You have requested to activate a customer account,
* but it is already active
*
2021-03-14 10:45:42 +01:00
* @method static self singleOptinCustomerExists()
2021-08-09 08:55:39 +02:00
* You have requested to create a single optin for an email,
* but it already exists
*
2021-03-14 10:45:42 +01:00
* @method static self apiAuthFailed()
2021-08-09 08:55:39 +02:00
* The authentification to the api failed. You may have to
* check into config or .env file for your brand credentials
*
2021-03-14 10:45:42 +01:00
* @method static self authFailed()
2021-08-09 08:55:39 +02:00
* The authentification for this customer failed because of wrong credentials
*
2021-03-14 10:45:42 +01:00
* @method static self needAuth()
2021-08-09 08:55:39 +02:00
* This action requires to be authenticated
*
2021-03-14 10:45:42 +01:00
* @method static self methodNotAllowed()
2021-08-09 08:55:39 +02:00
* This http method is not allowed
*
2021-03-14 10:45:42 +01:00
* @method static self wrongTimeStamp()
2021-08-09 08:55:39 +02:00
* 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
*
2021-08-04 09:33:28 +02:00
* @method static self throttleRequestsException()
2021-08-09 08:55:39 +02:00
* 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 08:56:35 +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
2021-08-09 08:55:39 +02:00
*
* @package LDCCrmClient
* @subpackage enums
2021-03-14 10:45:42 +01: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 08:56:35 +02:00
'authorizationException' => 403,
2021-08-04 09:33:28 +02:00
'throttleRequestsException' => 429
2021-03-14 10:45:42 +01:00
];
}
public static function labels(): array
{
return [
'modelNotFound' => trans('%s not found.'),
'validationFailed' => trans('Could not validate data.'),
2021-03-14 10:45:42 +01:00
'customerExists' => trans('User already registered on this site.'),
'customerNotActivated' => trans('Account is not activated.'),
'customerAlreadyActive' => trans('User already active.'),
'singleOptinCustomerExists' => trans('SingleOptin wont be added because customer exists.'),
'authFailed' => trans('Authentication failed.'),
'needAuth' => trans('You need to be authenticated'),
'methodNotAllowed' => trans('This method is not allowed for this request'),
'wrongTimeStamp' => trans('Your request is malformed, please check timestamp header and parameter'),
2021-08-12 08:56:35 +02:00
'authorizationException' => trans('You are not autorized to access this'),
2021-08-04 09:33:28 +02:00
'throttleRequestsException' => trans('Throttle: too many request have been attempted, please retry later')
2021-03-14 10:45:42 +01:00
];
}
}