Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
apple.php
1<?php
2
4
6
7class Apple extends BaseService
8{
9 protected int $sandboxModifier = 1;
10 protected int $productionModifier = 2;
11
19 public function getBatch(array $messages = []): string
20 {
21 $arGroupedMessages = self::getGroupedByServiceMode($messages);
22 if (empty($arGroupedMessages))
23 {
24 return '';
25 }
26
27 $batch = $this->getProductionBatch($arGroupedMessages["PRODUCTION"]);
28 $batch .= $this->getSandboxBatch($arGroupedMessages["SANDBOX"]);
29
30 return $batch;
31 }
32
36 function getMessageInstance(string $token): AppleMessage
37 {
38 return new AppleMessage($token, 2048);
39 }
40
48 public function getSandboxBatch($appMessages)
49 {
50 return $this->getBatchWithModifier($appMessages, ";" . $this->sandboxModifier . ";");
51 }
52
60 public function getProductionBatch($appMessages)
61 {
62 return $this->getBatchWithModifier($appMessages, ";" . $this->productionModifier . ";");
63 }
64
65 public static function shouldBeSent(array $messageRowData): bool
66 {
67 $params = $messageRowData["ADVANCED_PARAMS"];
68 return !($params && !$params["senderName"] && mb_strlen($params["senderMessage"]) > 0);
69 }
70}
getBatch(array $messages=[])
Definition apple.php:19
getMessageInstance(string $token)
Definition apple.php:36
static shouldBeSent(array $messageRowData)
Definition apple.php:65
getProductionBatch($appMessages)
Definition apple.php:60
getSandboxBatch($appMessages)
Definition apple.php:48
getBatchWithModifier($appMessages=Array(), $modifier="")
static getGroupedByServiceMode($arMessages)