Send multiple short messages using the JetSms services.

@param  ShortMessageCollection $shortMessageCollection

@return JetSmsResponseInterface
439088
public function sendShortMessages(ShortMessageCollection $shortMessageCollection)
    {
        $guzzleResponse = $this->httpClient->request('POST', $this->url, [
            'form_params' => array_merge(
                $shortMessageCollection->toArray(),
                $this->getSendDate(),
                $this->getCredentials()
            ),
        ]);

        return new JetSmsHttpResponse((string) $guzzleResponse->getBody());
    }
541103
protected function loadMessages()
    {
        $messages = Collection::make($this->event->get('messaging'));
        $messages = $messages->transform(function ($msg) {
            $message = new IncomingMessage('', $this->getMessageSender($msg), $this->getMessageRecipient($msg), $msg);
            if (isset($msg['message']['text']) && ! isset($msg['message']['quick_reply']['payload'])) {
                $message->setText($msg['message']['text']);

                if (isset($msg['message']['nlp'])) {
                    $message->addExtras('nlp', $msg['message']['nlp']);
                }
            } elseif (isset($msg['postback']['payload'])) {
                $this->isPostback = true;

                $message->setText($msg['postback']['payload']);
            } elseif (isset($msg['message']['quick_reply']['payload'])) {
                $this->isPostback = true;

                $message->setText($msg['message']['quick_reply']['payload']);
            }

            return $message;
        })->toArray();

        if (count($messages) === 0) {
            $messages = [new IncomingMessage('', '', '')];
        }

        $this->messages = $messages;
    }
450060
public function batchSendMessage($messages, $delay = 0)
    {
        foreach ($messages as $key => $message) {
            $messages[$key] = new SendMessageRequestItem(Json::encode($message), $delay, null);
        }
        $count = count($messages);
        $size = ceil(count($count) / 16);
        $messages = array_chunk($messages, $size);
        $responses = [];
        foreach ($messages as $message) {
            $request = new BatchSendMessageRequest($message, $this->base64);
            try {
                $response = $this->queue->batchSendMessage($request);
                if ($response->isSucceed()) {
                    $responses = array_merge($responses, $response->getSendMessageResponseItems());
                }
            } catch (MnsException $e) {
                Yii::trace(sprintf('send Message Failed:  `%s`...', $e));
            }
        }
        return $responses;
    }
139405
protected function addFlashMessage(FlashMessage $flashMessage)
    {
        if (!($this->flashMessageService instanceof FlashMessageService)) {
            $this->flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
        }
        /** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
        $defaultFlashMessageQueue = $this->flashMessageService->getMessageQueueByIdentifier();
        $defaultFlashMessageQueue->enqueue($flashMessage);
    }
767487
public function recallMessage($msgSeq)
    {
        $msgSeqList = is_array($msgSeq) ? $msgSeq : [$msgSeq];
        $request = new RecallGroupMessageRequest($this->groupId, $msgSeqList);
        $response = new BaseResponse();
        return $this->client->sendRequest($request, $response);
    }
422565
protected function mapMessagesToElementCollection(array $messages, ElementCollection $children)
    {
        $children->forAll(function (ElementInterface $element) use ($messages) {
            $this->mapMessagesToElement($messages, $element);
        });
    }
1326031
public function registerAll(array $shortcodes): ManagerInterface
    {
        foreach ($shortcodes as $k => $s) {
            $this[$k] = $s;
        }

        return $this;
    }
344773
public function sendMessage(SendGroupMessageRequest $request)
    {
        $response = new SendGroupMessageResponse();
        return $this->client->sendRequest($request, $response);
    }
1120550
function (msg) {
    var self = this;
    if (! _.has(msg, 'collection')) {
      return '';
    } else if (typeof(msg.collection) === 'string') {
      if (msg.collection === '')
        throw Error("Message has empty collection!");
      return msg.collection;
    } else {
      throw Error("Message has non-string collection!");
    }
  }
427526
public function send(\Swift_Mime_Message $message, &$failedRecipients = null)
    {
        $failedRecipients = (array) $failedRecipients;

        if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
            $this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
            if ($evt->bubbleCancelled()) {
                return 0;
            }
        }

        $count = (
            \count((array) $message->getTo())
            + \count((array) $message->getCc())
            + \count((array) $message->getBcc())
        );

        $filename = 'Mail_' . \time() . '_' . \mt_rand() . '.eml';
        $file     = $this->path . '/' . $filename;
        $email    = $message->toString();

        if (false === @\file_put_contents($file, $email)) {
            throw new \Swift_TransportException(\sprintf(
                'Unable to write mail to file (directory "%s")',
                $this->path
            ));
        }

        if ($evt) {
            $evt->setResult(\Swift_Events_SendEvent::RESULT_SUCCESS);
            $evt->setFailedRecipients($failedRecipients);
            $this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
        }

        return $count;
    }
1208634
public function msend(Message $msg)
    {
        if (ZMQ::SOCKET_ROUTER === $this->getSocketType()) {
            $msg->prepend($msg->getRoutingInformation());
        }

        if ($this->verbose) {
            $this->getLogger()->debug('SEND: '.$this->id);
            $this->getLogger()->debug($msg);
        }
        $parts = $msg->toArray();
        $iMax = count($parts)-1;
        if ($iMax < 0) {
            throw new RuntimeException('No parts to send.');
        }
        for ($i = 0; $i < $iMax; $i++) {
            $this->send($parts[$i], ZMQ::MODE_SNDMORE);
        }
        $this->send($parts[$iMax]);
        if ($this->verbose) {
            $this->getLogger()->debug('Message sent.');
        }

        return $this;
    }
621837
public function send(Message $message, Phone ...$recipients): ResultCollection
    {
        return $this->adapter->send($message, ...$recipients);
    }
43116
protected function _addMessage(array &$messages, array $item)
    {
        if (empty($item['ids']['singular']) && empty($item['ids']['plural'])) {
            return;
        }

        $singular = stripcslashes($item['ids']['singular']);
        $context = isset($item['context']) ? $item['context'] : null;
        $translation = $item['translated'];

        if (is_array($translation)) {
            $translation = $translation[0];
        }

        $translation = stripcslashes($translation);

        if ($context !== null && !isset($messages[$singular]['_context'][$context])) {
            $messages[$singular]['_context'][$context] = $translation;
        } elseif (!isset($messages[$singular]['_context'][''])) {
            $messages[$singular]['_context'][''] = $translation;
        }

        if (isset($item['ids']['plural'])) {
            $plurals = $item['translated'];
            // PO are by definition indexed so sort by index.
            ksort($plurals);

            // Make sure every index is filled.
            end($plurals);
            $count = key($plurals);

            // Fill missing spots with an empty string.
            $empties = array_fill(0, $count + 1, '');
            $plurals += $empties;
            ksort($plurals);

            $plurals = array_map('stripcslashes', $plurals);
            $key = stripcslashes($item['ids']['plural']);

            if ($context !== null) {
                $messages[Translator::PLURAL_PREFIX . $key]['_context'][$context] = $plurals;
            } else {
                $messages[Translator::PLURAL_PREFIX . $key]['_context'][''] = $plurals;
            }
        }
    }
944801
public function send(MessageInterface $message, $skipErrors = true) {
        if (count($message->getRecipient()) > self::MAX_RECIPIENS) {
            throw new ConfigurationException('Too many recipiens. For SerwerSms gateway limit is ' . self::MAX_RECIPIENS);
        }

        $client = $this->getClient();

        // details must be always true
        $extraParams = $this->getParam('extra');
        if (!isset($extraParams['details']) || $extraParams['details'] === false) {
            $extraParams['details'] = true;
        }

        try {
            $response = $client->messages->sendSms(
                $message->getRecipients(),
                $message->getText(),
                $this->getParam('sender'),
                $extraParams
            );

            if ((int)$response->unsent > 0) {
                foreach ($response->items as $item) {
                    // @see http://dev.serwersms.pl/https-api-v2/wysylanie-wiadomosci-sms-o-jednakowej-tresci
                    if ($item->status === 'unsent') {
                        $this->addError(new SendingError($item->phone, $item->error_code, $item->error_message . 'id:' . $item->id));
                        if (!$skipErrors) {
                            throw new \RuntimeException($item->error_message, $item->error_code);
                        }
                    }
                }
            }
        }
        catch (Exception $e) {
            $this->addError(new SendingError('', $e->getCode(), $e->getMessage()));
            if (!$skipErrors) {
                throw new \RuntimeException($e->getMessage());
            }
        }
        return $this->getErrors()->count() === 0;
    }
597264
public function addFlashMessage(FlashMessage $flashMessage)
    {
        $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
        $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($this->messageQueueByIdentifier);
        $flashMessageQueue->enqueue($flashMessage);
    }
432271
public function send(MessageInterface $message, $skipErrors = true) {

        $mobitex = $this->getClient();
        
        foreach ($message->getRecipient() as $recipient) {
            try {
                $mobitex->sendMessage($recipient, $message->getText());
            }
            catch (Exception $e) {
                $this->addError(new SendingError($recipient, $e->getCode(), $e->getMessage()));
                if (!$skipErrors) {
                    throw new \RuntimeException($e->getMessage(), $e->getCode());
                }
            }
        }
        return $this->getErrors()->count() === 0;
    }
1059189
public function buildMessage()
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        foreach ($this->texts as $text) {
            $this->message[] = [
                'type' => MessageType::TEXT,
                'text' => $text,
            ];
        }

        if ($this->quickReply) {
            $lastKey = count($this->message) - 1;

            // If the user receives multiple message objects.
            // The quickReply property of the last message object is displayed.
            $this->message[$lastKey]['quickReply'] = $this->quickReply->buildQuickReply();
        }

        return $this->message;
    }