Skip to content

Commit

Permalink
documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspijak committed Dec 21, 2021
1 parent b7e7225 commit 5752f76
Show file tree
Hide file tree
Showing 15 changed files with 275 additions and 517 deletions.
493 changes: 77 additions & 416 deletions README.md

Large diffs are not rendered by default.

36 changes: 22 additions & 14 deletions docs/bulk.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
## Bulk SMS (Campaign)
Bulk SMS (Campaign)
===================

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).

```php
$sms_message = new Sms('420777777777', new SimpleText("test <variable>", ["variable" => "message"]));
use BulkGate\Sdk\Message\{Sms, Viber, MultiChannel, Bulk};
use BulkGate\Sdk\Message\Component\{SimpleText, Button}
```

```php
$sms_message = new Sms('420777777777', new SimpleText('test <variable>', ['variable' => 'message']));

$viber_message = new Viber(
'420777777777',
new SimpleText("test <variable>", ["variable" => "message"]),
"Sender",
new Button("Caption", "https://www.bulkgate.com/")
new SimpleText('test <variable>', ['variable' => 'message']),
'Sender',
new Button('Caption', 'https://www.bulkgate.com/')
);

$multi_channel_message = new MultiChannel($phone_number);
$multi_channel_message->sms(new SimpleText("test <variable>", ["variable" => "message"]));
$multi_channel_message->sms(new SimpleText('test <variable>', ['variable' => 'message']));
$multi_channel_message->viber(
new SimpleText("test <variable>", ["variable" => "message"]),
"Sender",
new Button("GO TO BULKGATE", "https://www.bulkgate.com/")
new SimpleText('test <variable>', ['variable' => 'message']),
'Sender',
new Button('Go to BulkGate', 'https://www.bulkgate.com/')
);

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

### Adding messages
Also you can adding message via `\ArrayAccess` interface.
You can add message via `\ArrayAccess` interface.

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

### Iterator

You can go through messsages in bulk message using the foreach cycle
You can go through messages in bulk message using the foreach cycle

```php
/**
Expand All @@ -47,14 +53,16 @@ foreach($bulk_message as $message)
}
```

You can basicaly treat the bulk message as an array
You can basically treat the bulk message as an array

```php
$bulk_message['sms'] = new Sms("420777777777", "text_message");
$bulk_message['sms'] = new Sms('420777777777', 'text_message');

isset(bulk_message);
isset($bulk_message['sms']); // true

count($bulk_message);

unset($bulk_message['sms']);

isset($bulk_message['sms']); // false
```
12 changes: 7 additions & 5 deletions docs/configurators.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Configurators
Configurators
=============

Configurators are classes that provides specialized interface for all message types

## Sms configurator

This particular configurator provides methods for setting all sender types

```php
use BulkGate\Sdk\Country;
use BulkGate\Sdk\MessageSender;
use BulkGate\Sdk\Message\Component\SmsSender;
use BulkGate\Sdk\Configurator\{SmsConfigurator, SmsCountryConfigurator, ViberConfigurator}
```

## Sms configurator

This particular configurator provides methods for setting all sender types


```php
$message = new Sms('420777777777', 'text_message');
$sms_configurator = new SmsConfigurator();
Expand Down
19 changes: 10 additions & 9 deletions docs/multichannel_message.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
## Multichannel message
Multichannel message
====================

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

```php
$phone_number = new PhoneNumber("420777777777", "cz");
$text = new SimpleText("test <variable>", ["variable" => "message"]);
$button = new Button("Caption", "url");
$image = new Image("image url", false);
$phone_number = new PhoneNumber('420777777777', 'cz');
$text = new SimpleText('test <variable>', ['variable' => 'message']);
$button = new Button('Caption', 'url');
$image = new Image('image url', false);
$timeout = 5;

$message = new MultiChannel($phone_number);

$message->sms($text, "gText", "Sender", false);
$message->viber($text, "Sender", $button, $image, $timeout);
$message->sms($text, 'gText', 'Sender', false);
$message->viber($text, 'Sender', $button, $image, $timeout);

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

```php
$message->configure(Channel::SMS, $sender_id, $sender_id_value, $unicode);
$message->configure(Channel::VIBER, "sender", $button, $image, $timeout);
$message->configure(Channel::VIBER, 'sender', $button, $image, $timeout);
```

### Setting channel

Based on used settings interface method channel can be used.

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

$message->channel($settings);
```
Expand Down
49 changes: 46 additions & 3 deletions docs/number_checker.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,56 @@
Number checker will validate format and an existence of input phone numbers.

```php
$connection = new ConnectionStream("application_id", "application_token");
$connection = new ConnectionStream('application_id', 'application_token');

$number_checker = new NumberChecker($connection);

$result = $number_checker->check(['608123456', '777777777', '420777777777', new PhoneNumber('603777777'), '42061110'], 'cz');
```

The output is array where keys are phone numbers and values are true or false
The `$result` is array where keys are phone numbers.

```php
["420777777777" => false]
[
608123456 => [
'phone_number' => '420608123456',
'valid' => true,
'country' => 'cz',
'call_prefix' => 420,
'network_code' => '23003',
'network_name' => 'Vodafone',
],
777777777 => [
'phone_number' => '420777777777',
'valid' => true,
'country' => 'cz',
'call_prefix' => 420,
'network_code' => '23003',
'network_name' => 'Vodafone',
],
420777777777 => [
'phone_number' => '420777777777',
'valid' => true,
'country' => 'cz',
'call_prefix' => 420,
'network_code' => '23003',
'network_name' => 'Vodafone',
],
603777777 => [
'phone_number' => '420603777777',
'valid' => true,
'country' => 'cz',
'call_prefix' => 420,
'network_code' => '23002',
'network_name' => 'T-Mobile',
],
42061110: {
'phone_number': '42061110',
'valid': false,
'country': 'cz',
'call_prefix': 420,
'network_code': null,
'network_name': 'unknown'
},
]
```
15 changes: 9 additions & 6 deletions docs/schedulers.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
# Schedulers
Schedulers
==========

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

## Simple scheduler

Simple scheduler for sending messages at particular time
Simple scheduler for sending messages at particular time.

```php
$scheduler = new Simple(new \DateTime());
$scheduler = new Simple(new DateTime('2025-12-13 12:00'));

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

## Campaign

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.
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.

```php
$scheduler = new Campaign(new \DateTime());
$scheduler->restriction(2, 2, "hours");
$scheduler = new Campaign(new DateTime('2025-12-13 12:00'));

$scheduler->restriction(100 /* messages */, 2, 'hours');

$scheduler->schedule($message);
```
79 changes: 59 additions & 20 deletions docs/sender.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
BulkGate SMS - PHP SDK
=============
Message sender
==============

[![Downloads](https://img.shields.io/packagist/dt/bulkgate/sms.svg)](https://packagist.org/packages/bulkgate/sms)
[![Latest Stable Version](https://img.shields.io/github/release/bulkgate/sms.svg)](https://github.com/bulkgate/sms/releases)
[![License](https://img.shields.io/github/license/bulkgate/sms.svg)](https://github.com/BulkGate/sms/blob/master/LICENSE)

- [BulkGate portal](https://portal.bulkgate.com/)
- [BulkGate](https://www.bulkgate.com/)

## Basic instalation
## Basic installation

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.

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

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

``` php
```php
require_once __DIR__ . '/vendor/autoload.php';
```

```php
use BulkGate\Sdk\Connection\ConnectionStream;
use BulkGate\Sdk\MessageSender;
use BulkGate\Sdk\Scheduler\Simple;
use BulkGate\Sdk\Configurator\ViberConfigurator;
```


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.

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

$sender = new BulkGate\Sdk\MessageSender($connection);
$sender = new MessageSender($connection);
```

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

``` php
$message = new Sms("420603902776", "test_text");
```php
$message = new Sms('420603902776', 'test_text');

$sender->send($message);
```

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

## Nette instalation
### Optional configuration

```php
$sender->setTag('your identificator');
```

If you want to use national phone numbers you must set default country.
```php
$sender->setDefaultCountry('sk');
```

You can add [configurators](configurators.md) to sender.

```php
$viber_configurator = new ViberConfigurator('Sender');

$sender->addSenderConfigurator($viber_configurator);
```

For scheduling you can add instance of `BulkGate\Sdk\Scheduler\Scheduler`.

```php
$scheduler = new Simple(new DateTime('2022-05-14 20:00:00'));

$sender->setScheduler($scheduler);
```

## Nette installation

You can also use DI container to install this SDK

Expand All @@ -51,13 +81,22 @@ sdk:
application_id: 0000
application_token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
sender:
tag: 'sdk'
default_country: cz
tag: 'sdk' # Optional
default_country: cz # Optional
configurator:
sms:
sms: # Optional
sender_id: gText
sender_id_value: 'Example'
unicode: true
viber: # Optional
sender: Sender
button:
caption: 'Button Caption'
url: 'https://www.bulkgate.com/'
image:
url: 'https://www.example.com/example.png'
zoom: true
expiration: 3600 # seconds
```

## API administration & tokens
Expand Down
Loading

0 comments on commit 5752f76

Please sign in to comment.