1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cryptommer\Smsir\Classes; |
4
|
|
|
|
5
|
|
|
use Cryptommer\Smsir\Exceptions\HttpException; |
6
|
|
|
use Cryptommer\Smsir\Objects\BulkResponse; |
7
|
|
|
use Cryptommer\Smsir\Objects\LikeToLikeResponse; |
8
|
|
|
use Cryptommer\Smsir\Objects\Parameters; |
9
|
|
|
use Cryptommer\Smsir\Objects\ScheduleResponse; |
10
|
|
|
use Cryptommer\Smsir\Objects\VerifyResponse; |
11
|
|
|
use GuzzleHttp\Exception\GuzzleException; |
12
|
|
|
use JsonException; |
13
|
|
|
|
14
|
|
|
class Send { |
15
|
|
|
|
16
|
|
|
private $smsir; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param Smsir $smsir |
20
|
|
|
*/ |
21
|
|
|
public function __construct(Smsir $smsir) { |
22
|
|
|
$this->smsir = $smsir; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* send bulk message |
27
|
|
|
* |
28
|
|
|
* @param $message string |
29
|
|
|
* @param $mobiles string[] |
30
|
|
|
* @param $send_at int|null unixtime |
31
|
|
|
* @param int|null $line_number |
32
|
|
|
* @return BulkResponse |
33
|
|
|
* @throws HttpException|GuzzleException|JsonException |
34
|
|
|
*/ |
35
|
|
|
public function Bulk(string $message, array $mobiles, int $send_at = null, int $line_number = null): BulkResponse |
36
|
|
|
{ |
37
|
|
|
$response = $this->smsir->post('/v1/send/bulk', [ |
38
|
|
|
'lineNumber' => $line_number ?? $this->smsir->LineNumber, |
39
|
|
|
'MessageText' => $message, |
40
|
|
|
'Mobiles' => $mobiles, |
41
|
|
|
'SendDateTime' => $send_at |
42
|
|
|
]); |
43
|
|
|
return new BulkResponse($response); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* send like to like message |
48
|
|
|
* mobiles and messages counts must be equal |
49
|
|
|
* |
50
|
|
|
* @param array $messages |
51
|
|
|
* @param array $mobiles |
52
|
|
|
* @param int|null $send_at |
53
|
|
|
* @param int|null $line_number |
54
|
|
|
* @return LikeToLikeResponse |
55
|
|
|
* @throws HttpException|GuzzleException|JsonException |
56
|
|
|
*/ |
57
|
|
|
public function LikeToLike(array $messages, array $mobiles, int $send_at = null, int $line_number = null): LikeToLikeResponse |
58
|
|
|
{ |
59
|
|
|
$response = $this->smsir->post('/v1/send/likeToLike', [ |
60
|
|
|
'lineNumber' => $line_number ?? $this->smsir->LineNumber, |
61
|
|
|
'MessageTexts' => $messages, |
62
|
|
|
'Mobiles' => $mobiles, |
63
|
|
|
'SendDateTime' => $send_at |
64
|
|
|
]); |
65
|
|
|
return new LikeToLikeResponse($response); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* delete scheduled messages with message pack id |
70
|
|
|
* |
71
|
|
|
* @param $PackId |
72
|
|
|
* @return ScheduleResponse |
73
|
|
|
* @throws HttpException|GuzzleException|JsonException |
74
|
|
|
*/ |
75
|
|
|
public function deleteScheduled($PackId): ScheduleResponse { |
76
|
|
|
$response = $this->smsir->delete('/v1/send/scheduled/'.$PackId); |
77
|
|
|
return new ScheduleResponse($response); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* send verification message |
82
|
|
|
* |
83
|
|
|
* @param string $mobile |
84
|
|
|
* @param int $template_id |
85
|
|
|
* @param Parameters[] $parameters |
86
|
|
|
* @return VerifyResponse |
87
|
|
|
*@throws HttpException|GuzzleException|JsonException |
88
|
|
|
*/ |
89
|
|
|
public function Verify(string $mobile, int $template_id, array $parameters): VerifyResponse { |
90
|
|
|
$response = $this->smsir->post('/v1/send/verify', [ |
91
|
|
|
'Mobile' => $mobile, |
92
|
|
|
'TemplateId' => $template_id, |
93
|
|
|
'Parameters' => $parameters, |
94
|
|
|
]); |
95
|
|
|
return new VerifyResponse($response); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|