Skip to content

Commit e979549

Browse files
committed
register WhatsAppCloudApi superclass
1 parent b7aad6e commit e979549

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

composer.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
"description": "Laravel notification driver for WhatsApp",
44
"homepage": "https://github.com/laravel-notification-channels/whatsapp",
55
"license": "MIT",
6+
"keywords": [
7+
"whatsapp notification",
8+
"laravel",
9+
"whatsapp",
10+
"notification",
11+
"whatsapp notifications channel"
12+
],
613
"authors": [
714
{
815
"name": "Álex Albarca",
@@ -14,7 +21,8 @@
1421
"require": {
1522
"php": ">=7.4",
1623
"illuminate/notifications": "~6.0 || ~7.0 || ~8.0",
17-
"illuminate/support": "~6.0 || ~7.0 || ~8.0"
24+
"illuminate/support": "~6.0 || ~7.0 || ~8.0",
25+
"netflie/whatsapp-cloud-api": "^1.3.1"
1826
},
1927
"require-dev": {
2028
"mockery/mockery": "^1.0",
@@ -30,6 +38,13 @@
3038
"NotificationChannels\\WhatsApp\\Test\\": "tests"
3139
}
3240
},
41+
"extra": {
42+
"laravel": {
43+
"providers": [
44+
"NotificationChannels\\WhatsApp\\WhatsAppServiceProvider"
45+
]
46+
}
47+
},
3348
"scripts": {
3449
"test": "phpunit",
3550
"test:coverage": "phpunit --coverage-text --coverage-clover=coverage.clover"

src/WhatsAppServiceProvider.php

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,22 @@
33
namespace NotificationChannels\WhatsApp;
44

55
use Illuminate\Support\ServiceProvider;
6+
use Netflie\WhatsAppCloudApi\WhatsAppCloudApi;
67

78
class WhatsAppServiceProvider extends ServiceProvider
89
{
9-
/**
10-
* Bootstrap the application services.
11-
*/
12-
public function boot()
13-
{
14-
// Bootstrap code here.
15-
16-
/**
17-
* Here's some example code we use for the pusher package.
18-
19-
$this->app->when(Channel::class)
20-
->needs(Pusher::class)
21-
->give(function () {
22-
$pusherConfig = config('broadcasting.connections.pusher');
23-
24-
return new Pusher(
25-
$pusherConfig['key'],
26-
$pusherConfig['secret'],
27-
$pusherConfig['app_id']
28-
);
29-
});
30-
*/
31-
32-
}
33-
3410
/**
3511
* Register the application services.
3612
*/
3713
public function register()
3814
{
15+
$config = [
16+
'from_phone_number_id' => $this->app->make('config')->get('services.whatsapp.from-phone-number-id'),
17+
'access_token' => $this->app->make('config')->get('services.whatsapp.token'),
18+
'graph_version' => $this->app->make('config')->get('services.whatsapp.graph_version', WhatsAppCloudApi::DEFAULT_GRAPH_VERSION),
19+
'timeout' => $this->app->make('config')->get('services.whatsapp.timeout'),
20+
];
21+
22+
$this->app->bind(WhatsAppCloudApi::class, static fn () => new WhatsAppCloudApi($config));
3923
}
4024
}

0 commit comments

Comments
 (0)