Build the notification payload.

@return array
766256
public function build()
    {
        $params = [
            'external_user_ids' => $this->externalUserIds,
            'segment_id' => $this->segmentId,
            'campaign_id' => $this->campaignId,
            'override_frequency_capping' => $this->overrideFrequencyCapping,
            'recipient_subscription_state' => $this->recipientSubscriptionState,
            'messages' => $this->messages,
        ];

        return array_filter($params, function ($param) {
            return $param !== null;
        });
    }
840291
public function build()
    {
        $this->checkIfOneTopicExist();

        if ($this->hasOnlyOneTopic()) {
            foreach ($this->conditions[0] as $topic) {
                return '/topics/'.$topic;
            }
        }

        return [
            'condition' => $this->topicsForFcm($this->conditions),
        ];
    }
1198318
public function updateNotProcessedNotifications()
    {

        $this->_debugData = array();

        $this->_debugData['processPosResponse begin'] = 'Begin to process cronjob for updating notifications from the queue';

        $this->_updateNotProcessedNotifications();

        $this->_debugData['processPosResponse end'] = 'Cronjob ends';

        return $this->_debugData;
    }
773411
public function getMessages()
	{
		return array_merge($this->fatals, $this->errors, $this->warnings, $this->notices);
	}
1162217
public function generateResponse()
    {
        $uniqueId = $this->isWPFNotification() ? 'wpf_unique_id' : 'unique_id';

        $structure = [
            'notification_echo' => [
                $uniqueId => $this->unique_id
            ]
        ];

        $builder = new \Genesis\Builder('xml');
        $builder->parseStructure($structure);

        return $builder->getDocument();
    }
161279
public function notifynderNotifications()
    {
        $model = app('notifynder.resolver.model')->getModel(Notification::class);
        if (notifynder_config()->isPolymorphic()) {
            return $this->morphMany($model, 'to');
        }

        return $this->hasMany($model, 'to_id');
    }
435694
public function build()
    {
        $subjectKey = 'user.emails.email_confirmation.subject';

        return $this->subject($this->getSubject($subjectKey))
            ->to($this->petition->new_email)
            ->view('emails.newEmailConfirmation', [
                'name' => Auth::user()->fullName,
                'route' => $this->route(),
        ]);
    }
1341070
public function getMessages()
    {
        if (empty($this->messages)) {
            $this->messages = [
                new IncomingMessage($this->event->get('text'), $this->event->get('msisdn'), $this->event->get('to'), $this->payload),
            ];
        }

        return $this->messages;
    }
610170
public function getNotificationDetails()
    {
        $resource = $this->getResource();
        $notificationDetails = array_merge($this->details, array());
        $notificationDetails['resource'] = array(
            'id' => $resource->getId(),
            'name' => $resource->getName(),
            'type' => $resource->getResourceType()->getName(),
        );

        return $notificationDetails;
    }
969940
public function serialize(PlannedNotification $notification, array $options)
    {
        return [
            'id' => $notification->getUuid(),
            'message' => $this->messageSerializer->serialize($notification->getMessage()),
            'workspace' => $this->workspaceSerializer->serialize($notification->getWorkspace(), [Options::SERIALIZE_MINIMAL]),
            'parameters' => [
                'action' => $notification->getAction(),
                'interval' => $notification->getInterval(),
                'byMail' => $notification->isByMail(),
                'byMessage' => $notification->isByMessage(),
            ],
            'roles' => array_map(function (Role $role) {
                return $this->roleSerializer->serialize($role, [Options::SERIALIZE_MINIMAL]);
            }, $notification->getRoles()->toArray()),
        ];
    }
172246
public function getBriefInfoMessages()
    {
        $array = imap_headers($this->imap);
        $newArray = [];
        foreach ($array as $key => $string) {
            $newArray[] = ['id'=>$key+1, 'info' => $string];
        };
        return $newArray;
    }
104404
public function getBinaryMessage()
    {
        $encodedPayload = $this->jsonEncode($this->payload->getPayload());

        return chr(0).
               chr(0).
               chr(32).
               pack('H*', $this->deviceToken).
               chr(0).chr(strlen($encodedPayload)).
               $encodedPayload;
    }
32670
public function getPayload()
    {
        $payload = $this->payload;

        // The "message" property is deprecated and replaced by "error_description"
        // TODO: remove "message" property
        if (isset($payload['error_description']) && !isset($payload['message'])) {
            $payload['message'] = $payload['error_description'];
        }

        return $payload;
    }
1126217
public function toArray(): array
    {
        $payload = [
            'code' => $this->getCode()
        ];

        if (! empty($this->getMessage())) {
            $payload['message'] = $this->getMessage();
        }

        if (! empty($this->getError())) {
            $payload['error'] = $this->getError();
        }

        if (! empty($this->getData())) {
            $payload['data'] = $this->getData();
        }

        if (! empty($this->getOptions())) {
            $payload += $this->getOptions();
        }

        return $payload;
    }
1278457
public function buildMessage()
    {
        if (!empty($this->message)) {
            return $this->message;
        }

        $sticker = [
            'type' => MessageType::STICKER,
            'packageId' => $this->packageId,
            'stickerId' => $this->stickerId,
        ];

        if ($this->quickReply) {
            $sticker['quickReply'] = $this->quickReply->buildQuickReply();
        }

        $this->message[] = $sticker;

        return $this->message;
    }
784972
public function notify() : array
  {
    return Mail::make()
            ->to($this->email)
            ->subject('Verify Email Address')
            ->title('Hello!')
            ->line('Please click the button below to verify your email.')
            ->action('Verify Email Address', url("/account/verify?token={$this->token}", true))
            ->line('If you did not create an account, no futher action is required.')
            ->separate()
            ->small('If you\'re having trouble clicking the "Verify Email Address" button, copy and paste the URL below into your browser. ' . url("/account/verify?token={$this->token}", true))
            ->view('app.mail.default')
            ->send();
  }
1083119
private function prepare(array $notifications): array
    {
        $requests = [];
        /** @var Notification $notification */
        foreach ($notifications as $notification) {
            $subscription = $notification->getSubscription();
            $endpoint = $subscription->getEndpoint();
            $userPublicKey = $subscription->getPublicKey();
            $userAuthToken = $subscription->getAuthToken();
            $contentEncoding = $subscription->getContentEncoding();
            $payload = $notification->getPayload();
            $options = $notification->getOptions($this->getDefaultOptions());
            $auth = $notification->getAuth($this->auth);

            if (!empty($payload) && !empty($userPublicKey) && !empty($userAuthToken)) {
                if (!$contentEncoding) {
                    throw new \ErrorException('Subscription should have a content encoding');
                }

                $encrypted = Encryption::encrypt($payload, $userPublicKey, $userAuthToken, $contentEncoding);
                $cipherText = $encrypted['cipherText'];
                $salt = $encrypted['salt'];
                $localPublicKey = $encrypted['localPublicKey'];

                $headers = [
                    'Content-Type' => 'application/octet-stream',
                    'Content-Encoding' => $contentEncoding,
                ];

                if ($contentEncoding === "aesgcm") {
                    $headers['Encryption'] = 'salt='.Base64Url::encode($salt);
                    $headers['Crypto-Key'] = 'dh='.Base64Url::encode($localPublicKey);
                }

                $encryptionContentCodingHeader = Encryption::getContentCodingHeader($salt, $localPublicKey, $contentEncoding);
                $content = $encryptionContentCodingHeader.$cipherText;

                $headers['Content-Length'] = Utils::safeStrlen($content);
            } else {
                $headers = [
                    'Content-Length' => 0,
                ];

                $content = '';
            }

            $headers['TTL'] = $options['TTL'];

            if (isset($options['urgency'])) {
                $headers['Urgency'] = $options['urgency'];
            }

            if (isset($options['topic'])) {
                $headers['Topic'] = $options['topic'];
            }

            // if GCM
            if (substr($endpoint, 0, strlen(self::GCM_URL)) === self::GCM_URL) {
                if (array_key_exists('GCM', $auth)) {
                    $headers['Authorization'] = 'key='.$auth['GCM'];
                } else {
                    throw new \ErrorException('No GCM API Key specified.');
                }
            }
            // if VAPID (GCM doesn't support it but FCM does)
            elseif (array_key_exists('VAPID', $auth) && $contentEncoding) {
                $audience = parse_url($endpoint, PHP_URL_SCHEME).'://'.parse_url($endpoint, PHP_URL_HOST);
                if (!parse_url($audience)) {
                    throw new \ErrorException('Audience "'.$audience.'"" could not be generated.');
                }

                $vapidHeaders = $this->getVAPIDHeaders($audience, $contentEncoding, $auth['VAPID']);

                $headers['Authorization'] = $vapidHeaders['Authorization'];

                if ($contentEncoding === 'aesgcm') {
                    if (array_key_exists('Crypto-Key', $headers)) {
                        $headers['Crypto-Key'] .= ';'.$vapidHeaders['Crypto-Key'];
                    } else {
                        $headers['Crypto-Key'] = $vapidHeaders['Crypto-Key'];
                    }
                }
            }

            $requests[] = new Request('POST', $endpoint, $headers, $content);
        }

        return $requests;
    }