Skip to content

Commit

Permalink
Registering pending webhook into container
Browse files Browse the repository at this point in the history
  • Loading branch information
JustSteveKing committed May 31, 2023
1 parent 99ab727 commit 0c2e671
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Builder/PendingWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
final class PendingWebhook implements PendingWebhookContract
{
/**
* @param string $url
* @param SigningContract $signer
* @param null|string $url
* @param array $payload
* @param bool $signed
* @param string|null $signature
* @param PendingRequest|null $request
*/
public function __construct(
public readonly string $url,
public readonly SigningContract $signer,
public readonly null|string $url = null,
public array $payload = [],
public bool $signed = true,
public null|string $signature = null,
Expand Down
11 changes: 11 additions & 0 deletions src/Providers/PackageServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace JustSteveKing\Webhooks\Providers;

use Illuminate\Support\ServiceProvider;
use JustSteveKing\Webhooks\Builder\PendingWebhook;
use JustSteveKing\Webhooks\Contracts\Builder\PendingWebhookContract;
use JustSteveKing\Webhooks\Contracts\Signing\SigningContract;
use JustSteveKing\Webhooks\Signing\WebhookSigner;

Expand All @@ -28,5 +30,14 @@ public function register(): void
key: strval(config('webhooks.signing.key')),
),
);

$this->app->singleton(
abstract: PendingWebhookContract::class,
concrete: fn () => new PendingWebhook(
signer: $this->app->make(
abstract: SigningContract::class,
),
),
);
}
}
1 change: 0 additions & 1 deletion tests/Channels/WebhookChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

declare(strict_types=1);

use Illuminate\Http\Client\Response;
use Illuminate\Support\Facades\Http;
use JustSteveKing\Webhooks\Channels\WebhookChannel;
use JustSteveKing\Webhooks\Tests\Stubs\TestNotifiable;
Expand Down

0 comments on commit 0c2e671

Please sign in to comment.