From bbac331fdcbdffa9f1b38f789234da2439763a69 Mon Sep 17 00:00:00 2001 From: Nathan Page Date: Wed, 13 Jan 2021 11:28:40 +1100 Subject: [PATCH] [EasyWebhook] Define constants for options (#458) --- packages/EasyWebhook/src/AbstractWebhook.php | 18 +++--- .../src/Interfaces/WebhookInterface.php | 64 +++++++++++++++++++ 2 files changed, 73 insertions(+), 9 deletions(-) diff --git a/packages/EasyWebhook/src/AbstractWebhook.php b/packages/EasyWebhook/src/AbstractWebhook.php index 4ceece8ab..71ce56710 100644 --- a/packages/EasyWebhook/src/AbstractWebhook.php +++ b/packages/EasyWebhook/src/AbstractWebhook.php @@ -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', ]; /** diff --git a/packages/EasyWebhook/src/Interfaces/WebhookInterface.php b/packages/EasyWebhook/src/Interfaces/WebhookInterface.php index 537fa762e..5716e866a 100644 --- a/packages/EasyWebhook/src/Interfaces/WebhookInterface.php +++ b/packages/EasyWebhook/src/Interfaces/WebhookInterface.php @@ -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 */