Skip to content

Commit 6470d69

Browse files
author
Glamazda Sergey
committed
change method smsSend
1 parent 37e3de5 commit 6470d69

File tree

1 file changed

+52
-44
lines changed

1 file changed

+52
-44
lines changed

src/ApiClient.php

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,50 +1406,58 @@ public function smsCreateCampaign(
14061406
return $this->handleResult($requestResult);
14071407
}
14081408

1409-
/**
1410-
* Create a campaign by phones
1411-
*
1412-
* @param $senderName
1413-
* @param array $phones
1414-
* @param $body
1415-
* @param null $date
1416-
* @param null $transliterate
1417-
* @return stdClass
1418-
*/
1419-
public function smsSend(
1420-
$senderName,
1421-
array $phones,
1422-
$body,
1423-
$date = null,
1424-
$transliterate = null
1425-
) {
1426-
if (empty($senderName)) {
1427-
return $this->handleError('Empty sender name');
1428-
}
1429-
if (empty($phones)) {
1430-
return $this->handleError('Phone list is empty');
1431-
}
1432-
if (empty($body)) {
1433-
return $this->handleError('Empty sms body');
1434-
}
1435-
if (!empty($date)) {
1436-
$checkDate = \DateTime::createFromFormat('Y-m-d H:i:s', $date);
1437-
if (!$checkDate || $checkDate->format('Y-m-d H:i:s') !== $date) {
1438-
return $this->handleError('Sending date is incorrect');
1439-
}
1440-
}
1441-
$data = array(
1442-
'sender' => $senderName,
1443-
'phones' => json_encode($phones),
1444-
'body' => $body,
1445-
'date' => $date,
1446-
'transliterate' => $transliterate,
1447-
);
1448-
1449-
$requestResult = $this->sendRequest('sms/send', 'POST', $data);
1450-
1451-
return $this->handleResult($requestResult);
1452-
}
1409+
/**
1410+
* Create a campaign by phones
1411+
*
1412+
* @param $senderName
1413+
* @param array $phones
1414+
* @param $body
1415+
* @param null $date
1416+
* @param null $transliterate
1417+
* @param array $route
1418+
*
1419+
* @return stdClass
1420+
*/
1421+
public function smsSend(
1422+
$senderName,
1423+
array $phones,
1424+
$body,
1425+
$date = null,
1426+
$transliterate = null,
1427+
array $route = null
1428+
) {
1429+
if (empty($senderName)) {
1430+
return $this->handleError('Empty sender name');
1431+
}
1432+
if (empty($phones) ) {
1433+
return $this->handleError('Phone list is empty');
1434+
}
1435+
if (empty($body)) {
1436+
return $this->handleError('Empty sms body');
1437+
}
1438+
if (!empty($date)) {
1439+
$checkDate = \DateTime::createFromFormat('Y-m-d H:i:s', $date);
1440+
if (!$checkDate || $checkDate->format('Y-m-d H:i:s') !== $date) {
1441+
return $this->handleError('Sending date is incorrect');
1442+
}
1443+
}
1444+
if(null !== $route && empty($route) ) {
1445+
return $this->handleError('The "rout" parameter must be either NULL or a full array');
1446+
}
1447+
1448+
$data = array(
1449+
'sender' => $senderName,
1450+
'phones' => json_encode($phones),
1451+
'body' => $body,
1452+
'date' => $date,
1453+
'transliterate' => $transliterate,
1454+
'route' => json_encode($route),
1455+
);
1456+
1457+
$requestResult = $this->sendRequest('sms/send', 'POST', $data);
1458+
1459+
return $this->handleResult($requestResult);
1460+
}
14531461

14541462
/**
14551463
* Get list of campaigns that was sent by SMS

0 commit comments

Comments
 (0)