Skip to content

Commit 5752f76

Browse files
committed
documentation
1 parent b7e7225 commit 5752f76

15 files changed

+275
-517
lines changed

README.md

Lines changed: 77 additions & 416 deletions
Large diffs are not rendered by default.

docs/bulk.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
1-
## Bulk SMS (Campaign)
1+
Bulk SMS (Campaign)
2+
===================
23

34
The class `BulkGate\Sdk\Message\Bulk` represents the object, which connects all types of messages (`BulkGate\Sdk\Message\Sms`, `BulkGate\Sdk\Message\Viber`, `BulkGate\Sdk\Message\MultiChannel`) to a bulk message (campaign).
45

56
```php
6-
$sms_message = new Sms('420777777777', new SimpleText("test <variable>", ["variable" => "message"]));
7+
use BulkGate\Sdk\Message\{Sms, Viber, MultiChannel, Bulk};
8+
use BulkGate\Sdk\Message\Component\{SimpleText, Button}
9+
```
10+
11+
```php
12+
$sms_message = new Sms('420777777777', new SimpleText('test <variable>', ['variable' => 'message']));
713

814
$viber_message = new Viber(
915
'420777777777',
10-
new SimpleText("test <variable>", ["variable" => "message"]),
11-
"Sender",
12-
new Button("Caption", "https://www.bulkgate.com/")
16+
new SimpleText('test <variable>', ['variable' => 'message']),
17+
'Sender',
18+
new Button('Caption', 'https://www.bulkgate.com/')
1319
);
1420

1521
$multi_channel_message = new MultiChannel($phone_number);
16-
$multi_channel_message->sms(new SimpleText("test <variable>", ["variable" => "message"]));
22+
$multi_channel_message->sms(new SimpleText('test <variable>', ['variable' => 'message']));
1723
$multi_channel_message->viber(
18-
new SimpleText("test <variable>", ["variable" => "message"]),
19-
"Sender",
20-
new Button("GO TO BULKGATE", "https://www.bulkgate.com/")
24+
new SimpleText('test <variable>', ['variable' => 'message']),
25+
'Sender',
26+
new Button('Go to BulkGate', 'https://www.bulkgate.com/')
2127
);
2228

2329
$message = new Bulk([$sms_message, $viber_message, $multi_channel_message]);
2430
```
2531

2632
### Adding messages
27-
Also you can adding message via `\ArrayAccess` interface.
33+
You can add message via `\ArrayAccess` interface.
2834

2935
```php
3036
$message = new Bulk();
@@ -34,7 +40,7 @@ $message[] = new Sms('420777777777', 'test SMS');
3440

3541
### Iterator
3642

37-
You can go through messsages in bulk message using the foreach cycle
43+
You can go through messages in bulk message using the foreach cycle
3844

3945
```php
4046
/**
@@ -47,14 +53,16 @@ foreach($bulk_message as $message)
4753
}
4854
```
4955

50-
You can basicaly treat the bulk message as an array
56+
You can basically treat the bulk message as an array
5157

5258
```php
53-
$bulk_message['sms'] = new Sms("420777777777", "text_message");
59+
$bulk_message['sms'] = new Sms('420777777777', 'text_message');
5460

55-
isset(bulk_message);
61+
isset($bulk_message['sms']); // true
5662

5763
count($bulk_message);
5864

5965
unset($bulk_message['sms']);
66+
67+
isset($bulk_message['sms']); // false
6068
```

docs/configurators.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
# Configurators
1+
Configurators
2+
=============
23

34
Configurators are classes that provides specialized interface for all message types
45

5-
## Sms configurator
6-
7-
This particular configurator provides methods for setting all sender types
8-
96
```php
107
use BulkGate\Sdk\Country;
118
use BulkGate\Sdk\MessageSender;
129
use BulkGate\Sdk\Message\Component\SmsSender;
1310
use BulkGate\Sdk\Configurator\{SmsConfigurator, SmsCountryConfigurator, ViberConfigurator}
1411
```
1512

13+
## Sms configurator
14+
15+
This particular configurator provides methods for setting all sender types
16+
17+
1618
```php
1719
$message = new Sms('420777777777', 'text_message');
1820
$sms_configurator = new SmsConfigurator();

docs/multichannel_message.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
## Multichannel message
1+
Multichannel message
2+
====================
23

34
Multichannel allows you to send message via Viber and in case recipient does not own Viber account, SMS message will be send instead.
45

56
```php
6-
$phone_number = new PhoneNumber("420777777777", "cz");
7-
$text = new SimpleText("test <variable>", ["variable" => "message"]);
8-
$button = new Button("Caption", "url");
9-
$image = new Image("image url", false);
7+
$phone_number = new PhoneNumber('420777777777', 'cz');
8+
$text = new SimpleText('test <variable>', ['variable' => 'message']);
9+
$button = new Button('Caption', 'url');
10+
$image = new Image('image url', false);
1011
$timeout = 5;
1112

1213
$message = new MultiChannel($phone_number);
1314

14-
$message->sms($text, "gText", "Sender", false);
15-
$message->viber($text, "Sender", $button, $image, $timeout);
15+
$message->sms($text, 'gText', 'Sender', false);
16+
$message->viber($text, 'Sender', $button, $image, $timeout);
1617

1718
$this->sender->send($message);
1819
```
@@ -23,15 +24,15 @@ You can also change the settings of individual channels after the fact
2324

2425
```php
2526
$message->configure(Channel::SMS, $sender_id, $sender_id_value, $unicode);
26-
$message->configure(Channel::VIBER, "sender", $button, $image, $timeout);
27+
$message->configure(Channel::VIBER, 'sender', $button, $image, $timeout);
2728
```
2829

2930
### Setting channel
3031

3132
Based on used settings interface method channel can be used.
3233

3334
```php
34-
$settings = new \BulkGate\Sdk\Message\Settings\Viber(new SimpleText("text_message"), "sender", $button, $image, $timeout);
35+
$settings = new \BulkGate\Sdk\Message\Settings\Viber(new SimpleText('text_message'), 'sender', $button, $image, $timeout);
3536

3637
$message->channel($settings);
3738
```

docs/number_checker.md

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,56 @@
33
Number checker will validate format and an existence of input phone numbers.
44

55
```php
6-
$connection = new ConnectionStream("application_id", "application_token");
6+
$connection = new ConnectionStream('application_id', 'application_token');
77

88
$number_checker = new NumberChecker($connection);
9+
10+
$result = $number_checker->check(['608123456', '777777777', '420777777777', new PhoneNumber('603777777'), '42061110'], 'cz');
911
```
1012

11-
The output is array where keys are phone numbers and values are true or false
13+
The `$result` is array where keys are phone numbers.
1214

1315
```php
14-
["420777777777" => false]
16+
[
17+
608123456 => [
18+
'phone_number' => '420608123456',
19+
'valid' => true,
20+
'country' => 'cz',
21+
'call_prefix' => 420,
22+
'network_code' => '23003',
23+
'network_name' => 'Vodafone',
24+
],
25+
777777777 => [
26+
'phone_number' => '420777777777',
27+
'valid' => true,
28+
'country' => 'cz',
29+
'call_prefix' => 420,
30+
'network_code' => '23003',
31+
'network_name' => 'Vodafone',
32+
],
33+
420777777777 => [
34+
'phone_number' => '420777777777',
35+
'valid' => true,
36+
'country' => 'cz',
37+
'call_prefix' => 420,
38+
'network_code' => '23003',
39+
'network_name' => 'Vodafone',
40+
],
41+
603777777 => [
42+
'phone_number' => '420603777777',
43+
'valid' => true,
44+
'country' => 'cz',
45+
'call_prefix' => 420,
46+
'network_code' => '23002',
47+
'network_name' => 'T-Mobile',
48+
],
49+
42061110: {
50+
'phone_number': '42061110',
51+
'valid': false,
52+
'country': 'cz',
53+
'call_prefix': 420,
54+
'network_code': null,
55+
'network_name': 'unknown'
56+
},
57+
]
1558
```

docs/schedulers.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
# Schedulers
1+
Schedulers
2+
==========
23

34
Schedulers are classes that allow scheduling messages at certain intervals or in particular times.
45

56
## Simple scheduler
67

7-
Simple scheduler for sending messages at particular time
8+
Simple scheduler for sending messages at particular time.
89

910
```php
10-
$scheduler = new Simple(new \DateTime());
11+
$scheduler = new Simple(new DateTime('2025-12-13 12:00'));
12+
1113
$scheduler->schedule($message);
1214
```
1315

1416
## Campaign
1517

16-
Campaign scheduler allows you to start sending messages from particular time by at defined intervals. You can also define how many planned messages will be send out after certain interval.
18+
Campaign scheduler allows you to start sending messages from particular time by at defined intervals. You can also define how many planned messages will be sent out after certain interval.
1719

1820
```php
19-
$scheduler = new Campaign(new \DateTime());
20-
$scheduler->restriction(2, 2, "hours");
21+
$scheduler = new Campaign(new DateTime('2025-12-13 12:00'));
22+
23+
$scheduler->restriction(100 /* messages */, 2, 'hours');
2124

2225
$scheduler->schedule($message);
2326
```

docs/sender.md

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
BulkGate SMS - PHP SDK
2-
=============
1+
Message sender
2+
==============
33

4-
[![Downloads](https://img.shields.io/packagist/dt/bulkgate/sms.svg)](https://packagist.org/packages/bulkgate/sms)
5-
[![Latest Stable Version](https://img.shields.io/github/release/bulkgate/sms.svg)](https://github.com/bulkgate/sms/releases)
6-
[![License](https://img.shields.io/github/license/bulkgate/sms.svg)](https://github.com/BulkGate/sms/blob/master/LICENSE)
7-
8-
- [BulkGate portal](https://portal.bulkgate.com/)
9-
- [BulkGate](https://www.bulkgate.com/)
10-
11-
## Basic instalation
4+
## Basic installation
125

136
The easiest way to install [bulkgate/php-sdk](https://packagist.org/packages/bulkgate/php-sdk) into a project is by using [Composer](https://getcomposer.org/) via the command line.
147

@@ -19,27 +12,64 @@ composer require bulkgate/php-sdk
1912

2013
If you have the package installed just plug in the autoloader.
2114

22-
``` php
15+
```php
2316
require_once __DIR__ . '/vendor/autoload.php';
2417
```
2518

19+
```php
20+
use BulkGate\Sdk\Connection\ConnectionStream;
21+
use BulkGate\Sdk\MessageSender;
22+
use BulkGate\Sdk\Scheduler\Simple;
23+
use BulkGate\Sdk\Configurator\ViberConfigurator;
24+
```
25+
26+
2627
In order to send messages, you need an instance of the `BulkGate\Sdk\MessageSender` class that requires instance dependency on the `BulkGate\Sdk\Connection\Connection` class. See how to get API access data.
2728

28-
``` php
29-
$connection = new BulkGate\Sdk\Connection\ConnectionStream('APPLICATION_ID', 'APPLICATION_TOKEN');
29+
```php
30+
$connection = new ConnectionStream(/*application_id: */ 0000, /*application_token:*/ 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
3031

31-
$sender = new BulkGate\Sdk\MessageSender($connection);
32+
$sender = new MessageSender($connection);
3233
```
3334

3435
At this point, you are ready to send a message.
3536

36-
``` php
37-
$message = new Sms("420603902776", "test_text");
37+
```php
38+
$message = new Sms('420603902776', 'test_text');
39+
40+
$sender->send($message);
3841
```
3942

4043
The `send()` method will send a message `$message`.
4144

42-
## Nette instalation
45+
### Optional configuration
46+
47+
```php
48+
$sender->setTag('your identificator');
49+
```
50+
51+
If you want to use national phone numbers you must set default country.
52+
```php
53+
$sender->setDefaultCountry('sk');
54+
```
55+
56+
You can add [configurators](configurators.md) to sender.
57+
58+
```php
59+
$viber_configurator = new ViberConfigurator('Sender');
60+
61+
$sender->addSenderConfigurator($viber_configurator);
62+
```
63+
64+
For scheduling you can add instance of `BulkGate\Sdk\Scheduler\Scheduler`.
65+
66+
```php
67+
$scheduler = new Simple(new DateTime('2022-05-14 20:00:00'));
68+
69+
$sender->setScheduler($scheduler);
70+
```
71+
72+
## Nette installation
4373

4474
You can also use DI container to install this SDK
4575

@@ -51,13 +81,22 @@ sdk:
5181
application_id: 0000
5282
application_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5383
sender:
54-
tag: 'sdk'
55-
default_country: cz
84+
tag: 'sdk' # Optional
85+
default_country: cz # Optional
5686
configurator:
57-
sms:
87+
sms: # Optional
5888
sender_id: gText
5989
sender_id_value: 'Example'
6090
unicode: true
91+
viber: # Optional
92+
sender: Sender
93+
button:
94+
caption: 'Button Caption'
95+
url: 'https://www.bulkgate.com/'
96+
image:
97+
url: 'https://www.example.com/example.png'
98+
zoom: true
99+
expiration: 3600 # seconds
61100
```
62101

63102
## API administration & tokens

0 commit comments

Comments
 (0)