Skip to content

Commit

Permalink
[EasyWebhook] Define constants for options (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
natepage committed Jan 13, 2021
1 parent b79d78e commit bbac331
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/EasyWebhook/src/AbstractWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ abstract class AbstractWebhook implements WebhookInterface
/**
* @var string[]
*/
protected static $integers = ['current_attempt', 'max_attempt'];
protected static $integers = [self::OPTION_CURRENT_ATTEMPT, self::OPTION_MAX_ATTEMPT];

/**
* @var string[]
*/
protected static $setters = [
'body' => 'body',
'current_attempt' => 'currentAttempt',
'event' => 'event',
'http_options' => 'httpClientOptions',
'max_attempt' => 'maxAttempt',
'method' => 'method',
'status' => 'status',
'url' => 'url',
self::OPTION_BODY => 'body',
self::OPTION_CURRENT_ATTEMPT => 'currentAttempt',
self::OPTION_EVENT => 'event',
self::OPTION_HTTP_OPTIONS => 'httpClientOptions',
self::OPTION_MAX_ATTEMPT => 'maxAttempt',
self::OPTION_METHOD => 'method',
self::OPTION_STATUS => 'status',
self::OPTION_URL => 'url',
];

/**
Expand Down
64 changes: 64 additions & 0 deletions packages/EasyWebhook/src/Interfaces/WebhookInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,70 @@ interface WebhookInterface
*/
public const DEFAULT_METHOD = 'POST';

/**
* @var string
*/
public const OPTIONS = [
self::OPTION_BODY,
self::OPTION_CURRENT_ATTEMPT,
self::OPTION_EVENT,
self::OPTION_HTTP_OPTIONS,
self::OPTION_MAX_ATTEMPT,
self::OPTION_METHOD,
self::OPTION_STATUS,
self::OPTION_URL,
];

/**
* @var string
*/
public const OPTION_BODY = 'body';

/**
* @var string
*/
public const OPTION_CURRENT_ATTEMPT = 'current_attempt';

/**
* @var string
*/
public const OPTION_EVENT = 'event';

/**
* @var string
*/
public const OPTION_HTTP_OPTIONS = 'http_options';

/**
* @var string
*/
public const OPTION_MAX_ATTEMPT = 'max_attempt';

/**
* @var string
*/
public const OPTION_METHOD = 'method';

/**
* @var string
*/
public const OPTION_STATUS = 'status';

/**
* @var string
*/
public const OPTION_URL = 'url';

/**
* @var string[]
*/
public const STATUSES = [
self::STATUS_FAILED,
self::STATUS_FAILED_PENDING_RETRY,
self::STATUS_PENDING,
self::STATUS_SUCCESS,
];

/**
* @var string
*/
Expand Down

0 comments on commit bbac331

Please sign in to comment.