| 1 | <?php |
||
| 9 | class WebhookConfig |
||
| 10 | { |
||
| 11 | public string $name; |
||
|
|
|||
| 12 | |||
| 13 | public string $signingSecret; |
||
| 14 | |||
| 15 | public string $signatureHeaderName; |
||
| 16 | |||
| 17 | public SignatureValidator $signatureValidator; |
||
| 18 | |||
| 19 | public WebhookProfile $webhookProfile; |
||
| 20 | |||
| 21 | public string $webhookModel; |
||
| 22 | |||
| 23 | public ProcessWebhookJob $processWebhookJob; |
||
| 24 | |||
| 25 | public function __construct(array $properties) |
||
| 26 | { |
||
| 27 | $this->name = $properties['name']; |
||
| 28 | |||
| 29 | $this->signingSecret = $properties['signing_secret'] ?? ''; |
||
| 30 | |||
| 31 | $this->signatureHeaderName = $properties['signature_header_name'] ?? ''; |
||
| 32 | |||
| 33 | if (! is_subclass_of($properties['signature_validator'], SignatureValidator::class)) { |
||
| 34 | throw InvalidConfig::invalidSignatureValidator($properties['signature_validator']); |
||
| 35 | } |
||
| 36 | $this->signatureValidator = app($properties['signature_validator']); |
||
| 37 | |||
| 38 | if (! is_subclass_of($properties['webhook_profile'], WebhookProfile::class)) { |
||
| 39 | throw InvalidConfig::invalidWebhookProfile($properties['webhook_profile']); |
||
| 40 | } |
||
| 41 | $this->webhookProfile = app($properties['webhook_profile']); |
||
| 42 | |||
| 43 | $this->webhookModel = $properties['webhook_model']; |
||
| 44 | |||
| 45 | if (! is_subclass_of($properties['process_webhook_job'], ProcessWebhookJob::class)) { |
||
| 46 | throw InvalidConfig::invalidProcessWebhookJob($properties['process_webhook_job']); |
||
| 47 | } |
||
| 48 | $this->processWebhookJob = app($properties['process_webhook_job']); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |