Skip to content

Commit 65a61e7

Browse files
authored
Merge pull request #2 from binary-cats/update-documentation
Fix Readme documentation
2 parents ed236ae + 59430fc commit 65a61e7

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

README.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ return [
4747

4848
/*
4949
* The classname of the model to be used. The class should equal or extend
50-
* BinaryCats\MailgunWebhooks\WebhookCall which is a child of Spatie\WebhookClient\Models\WebhookCall
50+
* Spatie\WebhookClient\Models\WebhookCall
5151
*/
52-
'model' => \BinaryCats\MailgunWebhooks\WebhookCall::class,
52+
'model' => \Spatie\WebhookClient\Models\WebhookCall::class,
5353

5454
/*
5555
* The classname of the model to be used. The class should equal or extend
@@ -77,17 +77,18 @@ php artisan migrate
7777
### Routing
7878
Finally, take care of the routing: At [the Mailgun dashboard](https://app.mailgun.com/app/sending/domains) you must configure at what url Mailgun webhooks should hit your app. In the routes file of your app you must pass that route to `Route::mailgunWebhooks()`:
7979

80-
I like to group functionality by domain, so would suggest `webwooks\mailgun`
80+
I like to group functionality by domain, so I would suggest `webwooks/mailgun` (especially if you plan to have more webhooks), but it is up to you.
8181

8282
```php
83-
Route::mailgunWebhooks('webwooks\mailgun');
83+
# routes\web.php
84+
Route::mailgunWebhooks('webwooks/mailgun');
8485
```
8586

8687
Behind the scenes this will register a `POST` route to a controller provided by this package. Because Mailgun has no way of getting a csrf-token, you must add that route to the `except` array of the `VerifyCsrfToken` middleware:
8788

8889
```php
8990
protected $except = [
90-
'webwooks\mailgun',
91+
'webwooks/mailgun',
9192
];
9293
```
9394

@@ -118,13 +119,13 @@ use Illuminate\Bus\Queueable;
118119
use Illuminate\Queue\SerializesModels;
119120
use Illuminate\Queue\InteractsWithQueue;
120121
use Illuminate\Contracts\Queue\ShouldQueue;
121-
use BinaryCats\MailgunWebhooks\WebhookCall;
122+
use Spatie\WebhookClient\Models\WebhookCall;
122123

123-
class HandleDeliveredSource implements ShouldQueue
124+
class HandleDelivered implements ShouldQueue
124125
{
125126
use InteractsWithQueue, Queueable, SerializesModels;
126127

127-
/** @var \BinaryCats\MailgunWebhooks\WebhookCall */
128+
/** @var \Spatie\WebhookClient\Models\WebhookCall */
128129
public $webhookCall;
129130

130131
public function __construct(WebhookCall $webhookCall)
@@ -206,7 +207,7 @@ The above example is only one way to handle events in Laravel. To learn the othe
206207
All incoming webhook requests are written to the database. This is incredibly valuable when something goes wrong while handling a webhook call. You can easily retry processing the webhook call, after you've investigated and fixed the cause of failure, like this:
207208

208209
```php
209-
use BinaryCats\MailgunWebhooks\WebhookCall;
210+
use Spatie\WebhookClient\Models\WebhookCall;
210211
use BinaryCats\MailgunWebhooks\ProcessMailgunWebhookJob;
211212

212213
dispatch(new ProcessMailgunWebhookJob(WebhookCall::find($id)));
@@ -240,24 +241,24 @@ When needed might want to the package to handle multiple endpoints and secrets.
240241
If you are using the `Route::mailgunWebhooks` macro, you can append the `configKey` as follows:
241242

242243
```php
243-
Route::mailgunWebhooks('webhook-url/{configKey}');
244+
Route::mailgunWebhooks('webwooks/mailgun/{configKey}');
244245
```
245246

246247
Alternatively, if you are manually defining the route, you can add `configKey` like so:
247248

248249
```php
249-
Route::post('webhook-url/{configKey}', 'BinaryCats\MailgunWebhooks\MailgunWebhooksController');
250+
Route::post('webwooks/mailgun/{configKey}', 'BinaryCats\MailgunWebhooks\MailgunWebhooksController');
250251
```
251252

252-
If this route parameter is present the verify middleware will look for the secret using a different config key, by appending the given the parameter value to the default config key. E.g. If Mailgun posts to `webhook-url/my-named-secret` you'd add a new config named `signing_secret_my-named-secret`.
253+
If this route parameter is present the verify middleware will look for the secret using a different config key, by appending the given the parameter value to the default config key. E.g. If Mailgun posts to `webwooks/mailgun/my-named-secret` you'd add a new config named `signing_secret_my-named-secret`.
253254

254255
Example config might look like:
255256

256257
```php
257-
// secret for when Mailgun posts to webhook-url/account
258+
// secret for when Mailgun posts to webwooks/mailgun/account
258259
'signing_secret_account' => 'whsec_abc',
259-
// secret for when Mailgun posts to webhook-url/connect
260-
'signing_secret_connect' => 'whsec_123',
260+
// secret for when Mailgun posts to webwooks/mailgun/my-named-secret
261+
'signing_secret_my-named-secret' => 'whsec_123',
261262
```
262263

263264
### About Mailgun

src/Event.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct($attributes)
2828
*
2929
* @return Event
3030
*/
31-
public static function constructFrom($data) : self
31+
public static function constructFrom($data): self
3232
{
3333
return new static($data);
3434
}

src/Exceptions/WebhookFailed.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class WebhookFailed extends Exception
99
{
10-
public static function signingSecretNotSet() : self
10+
public static function signingSecretNotSet(): self
1111
{
1212
return new static('The webhook signing secret is not set. Make sure that the `signing_secret` config key is set to the correct value.');
1313
}

src/Webhook.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Webhook
1212
* @param string $secret
1313
* @return BinaryCats\MailgunWebhooks\Event
1414
*/
15-
public static function constructEvent(array $payload, array $signature, string $secret) : Event
15+
public static function constructEvent(array $payload, array $signature, string $secret): Event
1616
{
1717
// verify we are good, else throw an expection
1818
WebhookSignature::make($signature, $secret)->verify();

src/WebhookSignature.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static function make($signatureArray, string $secret)
4949
*
5050
* @return bool
5151
*/
52-
public function verify() : bool
52+
public function verify(): bool
5353
{
5454
return hash_equals($this->signature, $this->computeSignature());
5555
}

0 commit comments

Comments
 (0)