Skip to content

Commit

Permalink
Support a delay to the WebhookCall dispatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
judgej committed Jun 26, 2019
1 parent 132d0a0 commit d77e2af
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
docs
vendor
coverage
.phpunit.result.cache
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ WebhookCall::create()
->url('https://other-app.com/webhooks')
->payload(['key' => 'value'])
->useSecret('sign-using-this-secret')
->delayInSeconds(60)
->dispatch();
```

Expand Down
1 change: 0 additions & 1 deletion src/CallWebhookJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,3 @@ public function tags()
return $this->tags;
}
}

15 changes: 13 additions & 2 deletions src/WebhookCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ public static function create(): self
->verifySsl($config['verify_ssl']);
}

public function __construct()
public function __construct(CallWebhookJob $callWebhookJob = null)
{
$this->callWebhookJob = app(CallWebhookJob::class);
if ($callWebhookJob === null) {
$callWebhookJob = app(CallWebhookJob::class);
}

$this->callWebhookJob = $callWebhookJob;
}

public function url(string $url)
Expand Down Expand Up @@ -108,6 +112,13 @@ public function timeoutInSeconds(int $timeoutInSeconds)
return $this;
}

public function delayInSeconds(int $delaySeconds)
{
$this->callWebhookJob->delay($delaySeconds);

return $this;
}

public function signUsing(string $signerClass)
{
if (! is_subclass_of($signerClass, Signer::class)) {
Expand Down

0 comments on commit d77e2af

Please sign in to comment.