1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cryptommer\Smsir\Classes; |
4
|
|
|
|
5
|
|
|
use Cryptommer\Smsir\Exceptions\HttpException; |
6
|
|
|
use Cryptommer\Smsir\Objects\ReceiveResponse; |
7
|
|
|
use Cryptommer\Smsir\Objects\ReportResponse; |
8
|
|
|
use GuzzleHttp\Exception\GuzzleException; |
9
|
|
|
|
10
|
|
|
class Report { |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var Smsir |
14
|
|
|
*/ |
15
|
|
|
private Smsir $smsir; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @param Smsir $smsir |
19
|
|
|
*/ |
20
|
|
|
public function __construct(Smsir $smsir) { |
21
|
|
|
$this->smsir = $smsir; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* get report of sent message |
26
|
|
|
* |
27
|
|
|
* @param int $message_id |
28
|
|
|
* @return ReportResponse |
29
|
|
|
* @throws HttpException |
30
|
|
|
* @throws GuzzleException |
31
|
|
|
*/ |
32
|
|
|
public function Message(int $message_id): ReportResponse { |
33
|
|
|
$response = $this->smsir->get('/v1/send/'.$message_id); |
34
|
|
|
return new ReportResponse($response); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* get report of sent pack messages |
39
|
|
|
* |
40
|
|
|
* @param string $pack_id |
41
|
|
|
* @return ReportResponse |
42
|
|
|
* @throws GuzzleException |
43
|
|
|
* @throws HttpException |
44
|
|
|
*/ |
45
|
|
|
public function Pack(string $pack_id): ReportResponse { |
46
|
|
|
$response = $this->smsir->get('/v1/send/pack/'.$pack_id); |
47
|
|
|
return new ReportResponse($response); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* get report of today messages sent |
52
|
|
|
* |
53
|
|
|
* @param int|null $pageSize |
54
|
|
|
* @param int|null $pageNumber |
55
|
|
|
* @return ReportResponse |
56
|
|
|
* @throws GuzzleException |
57
|
|
|
* @throws HttpException |
58
|
|
|
* @throws \JsonException |
59
|
|
|
*/ |
60
|
|
|
public function Today(int $pageSize = 10, int $pageNumber = 1): ReportResponse { |
61
|
|
|
$response = $this->smsir->get('/v1/send/live',[ |
62
|
|
|
'pageSize' => $pageSize, |
63
|
|
|
'pageNumber' => $pageNumber, |
64
|
|
|
]); |
65
|
|
|
return new ReportResponse($response); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* get report of archived messages sent |
70
|
|
|
* |
71
|
|
|
* @param int|null $fromDate |
72
|
|
|
* @param int|null $toDate |
73
|
|
|
* @param int $pageSize |
74
|
|
|
* @param int $pageNumber |
75
|
|
|
* @return ReportResponse |
76
|
|
|
* @throws GuzzleException |
77
|
|
|
* @throws HttpException |
78
|
|
|
*/ |
79
|
|
|
public function Archived(int $fromDate = null, int $toDate = null, int $pageSize = 10, int $pageNumber = 1): ReportResponse { |
80
|
|
|
$response = $this->smsir->get('/v1/send/archive',[ |
81
|
|
|
'fromDate' => $fromDate, |
82
|
|
|
'toDate' => $toDate, |
83
|
|
|
'pageSize' => $pageSize, |
84
|
|
|
'pageNumber' => $pageNumber, |
85
|
|
|
]); |
86
|
|
|
return new ReportResponse($response); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* get latest messages received |
91
|
|
|
* |
92
|
|
|
* @param int $count |
93
|
|
|
* @return ReceiveResponse |
94
|
|
|
* @throws GuzzleException |
95
|
|
|
* @throws HttpException |
96
|
|
|
* @throws \JsonException |
97
|
|
|
*/ |
98
|
|
|
public function LatestReceived(int $count = 100): ReceiveResponse { |
99
|
|
|
$response = $this->smsir->get('/v1/send/receive/latest',[ |
100
|
|
|
'count' => $count |
101
|
|
|
]); |
102
|
|
|
return new ReceiveResponse($response); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* get today received messages |
107
|
|
|
* |
108
|
|
|
* @param int $pageSize |
109
|
|
|
* @param int $pageNumber |
110
|
|
|
* @return ReceiveResponse |
111
|
|
|
* @throws GuzzleException |
112
|
|
|
* @throws HttpException |
113
|
|
|
* @throws \JsonException |
114
|
|
|
*/ |
115
|
|
|
public function TodayReceived(int $pageSize = 10, int $pageNumber = 1): ReceiveResponse { |
116
|
|
|
$response = $this->smsir->get('/v1/send/receive/live',[ |
117
|
|
|
'pageSize' => $pageSize, |
118
|
|
|
'pageNumber' => $pageNumber |
119
|
|
|
]); |
120
|
|
|
return new ReceiveResponse($response); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* get archived received messages |
125
|
|
|
* |
126
|
|
|
* @param int|null $fromDate |
127
|
|
|
* @param int|null $toDate |
128
|
|
|
* @param int $pageSize |
129
|
|
|
* @param int $pageNumber |
130
|
|
|
* @return ReceiveResponse |
131
|
|
|
* @throws GuzzleException |
132
|
|
|
* @throws HttpException |
133
|
|
|
* @throws \JsonException |
134
|
|
|
*/ |
135
|
|
|
public function ArchivedReceived(int $fromDate = null, int $toDate = null, int $pageSize = 10, int $pageNumber = 1): ReceiveResponse { |
136
|
|
|
$response = $this->smsir->get('/v1/send/archive',[ |
137
|
|
|
'fromDate' => $fromDate, |
138
|
|
|
'toDate' => $toDate, |
139
|
|
|
'pageSize' => $pageSize, |
140
|
|
|
'pageNumber' => $pageNumber, |
141
|
|
|
]); |
142
|
|
|
return new ReceiveResponse($response); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
} |
146
|
|
|
|