Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
33.33% covered (danger)
33.33%
6 / 18
60.00% covered (warning)
60.00%
3 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
BulkSmsBdChannel
33.33% covered (danger)
33.33%
6 / 18
60.00% covered (warning)
60.00%
3 / 5
26.96
0.00% covered (danger)
0.00%
0 / 1
 key
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 label
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 configSchema
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 send
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
20
 isImplemented
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Services\Notification\Channels;
4
5use App\Services\Notification\Contracts\NotificationChannelContract;
6use Illuminate\Support\Facades\Http;
7
8/**
9 * bulksmsbd.net — a common Bangladeshi SMS gateway, simple GET-based API.
10 * Implemented per their publicly documented API; verify against the
11 * operator's real API key before relying on it in production.
12 */
13class BulkSmsBdChannel implements NotificationChannelContract
14{
15    public function key(): string
16    {
17        return 'bulksmsbd';
18    }
19
20    public function label(): string
21    {
22        return 'SMS — BulkSMSBD';
23    }
24
25    public function configSchema(): array
26    {
27        return [
28            'api_key' => ['type' => 'password', 'label' => 'API Key', 'required' => true],
29            'sender_id' => ['type' => 'text', 'label' => 'Sender ID', 'required' => true],
30        ];
31    }
32
33    public function send(string $to, string $subject, string $body, array $config): array
34    {
35        if (empty($config['api_key']) || empty($config['sender_id'])) {
36            return ['ok' => false, 'response' => 'BulkSMSBD is not configured.'];
37        }
38
39        $response = Http::get('http://bulksmsbd.net/api/smsapi', [
40            'api_key' => $config['api_key'],
41            'type' => 'text',
42            'number' => $to,
43            'senderid' => $config['sender_id'],
44            'message' => $body,
45        ]);
46
47        // Their API replies 202 with a numeric response_code — anything else is a failure.
48        $ok = $response->successful() && (int) data_get($response->json(), 'response_code') === 202;
49
50        return ['ok' => $ok, 'response' => $response->body()];
51    }
52
53    public function isImplemented(): bool
54    {
55        return true;
56    }
57}