Build up a JSON payload for the Slack webhook.

@param  \Illuminate\Notifications\Messages\SlackMessage  $message
@return array
344353
protected function buildJsonPayload(SlackMessage $message)
    {
        $optionalFields = array_filter([
            'channel' => data_get($message, 'channel'),
            'icon_emoji' => data_get($message, 'icon'),
            'icon_url' => data_get($message, 'image'),
            'link_names' => data_get($message, 'linkNames'),
            'unfurl_links' => data_get($message, 'unfurlLinks'),
            'unfurl_media' => data_get($message, 'unfurlMedia'),
            'username' => data_get($message, 'username'),
        ]);

        return array_merge([
            'json' => array_merge([
                'text' => $message->content,
                'attachments' => $this->attachments($message),
            ], $optionalFields),
        ], $message->http);
    }
920786
protected function errorJson($message = null)
    {
        $model = new JsonModel(array(
                'success' => false,
                'message' => $message,
            ));
        return $model->setTerminal(true);
    }
1218822
public function parseResponse($message)
    {
        if (!($parts = $this->parseMessage($message))) {
            return false;
        }

        list($protocol, $version) = explode('/', trim($parts['start_line'][0]));

        return [
            'protocol'         => $protocol,
            'protocol_version' => $version,
            'code'             => $parts['start_line'][1],
            'reason_phrase'    => isset($parts['start_line'][2]) ? $parts['start_line'][2] : '',
            'headers'          => $parts['headers'],
            'body'             => $parts['body']
        ];
    }
1061837
private function getFrom(Swift_Mime_SimpleMessage $message)
    {
        if ($message->getFrom()) {
            foreach ($message->getFrom() as $email => $name) {
                return ['email' => $email, 'name' => $name];
            }
        }
        return [];
    }
1097730
public function push(QueueMessage $message)
    {
        $time = new \DateTimeImmutable('now');

        $data = [
            'queue' => $message->getQueueName() ?: $this->queue,
            'body' => json_encode($message),
            'attempts' => 0,
            'created' => $time->format('Y-m-d H:i:s'),
            'visibility' => $time->modify(sprintf('+%dseconds', $message->getDelay()))->format('Y-m-d H:i:s'),
            'reserved' => null,
        ];

        $this->db->getWriter()->insertOne($this->table, $data, 'id');

        return $data['id'];
    }
862005
private function formatNewsForPush (News $message)
    {
        $articles = [];

        foreach ($message->getItems() as $item) {
            $article = [
                'title' => $item->getTitle(),
                'description' => $item->getDescription(),
            ];
            
            if ($item->getURL() !== null) {
                $article['url'] = $item->getURL();
            }
            
            if ($item->getImageURL() !== null) {
                $article['picurl'] = $item->getImageURL();
            }
            
            $articles[] = $article;
        }

        return ['articles' => $articles];
    }
619310
public function send(Message $message)
    {
        return $this->guzzleClient->post(
            $this->getApiUrl(),
            [
                'headers' => [
                    'Authorization' => sprintf('key=%s', $this->apiKey),
                    'Content-Type' => 'application/json'
                ],
                'body' => json_encode($message)
            ]
        );
    }
1013053
public function split(Message $message) : array
    {
        $splittedMessages = [];
        $messageName      = $message->getHeaders()->get(MessageFlowModule::INTEGRATION_MESSAGING_CQRS_MESSAGE_NAME_HEADER);

        foreach($this->messageFlowMapper->getFlowRegistrationsFor($messageName) as $messageFlowRegistration) {
            $registrationMessage     = MessageBuilder::fromMessage($message)
                ->setHeader(MessageFlowModule::INTEGRATION_MESSAGING_CQRS_MESSAGE_FLOW_REGISTRATION_HEADER, $messageFlowRegistration);

            if (!$messageFlowRegistration->isExternalFlow()) {
                $registrationMessage = $registrationMessage
                    ->setHeader(MessageFlowModule::INTEGRATION_MESSAGING_CQRS_MESSAGE_CLASS_HEADER, $messageFlowRegistration->getMessageClassName());
            }

            $splittedMessages[] = $registrationMessage
                                    ->build();
        }

        return $splittedMessages;
    }
1314946
public function push(QueueMessage $message)
    {
        $queue = $message->getQueueName() ?: $this->queue;

        return $this->client->useTube($queue)->put(
            json_encode($message),
            PheanstalkInterface::DEFAULT_PRIORITY,
            $message->getDelay(),
            $this->timeout
        );
    }
489180
protected function getFromAddresses(Swift_Mime_Message $message)
	{
		if ($message->getFrom()) {
			foreach ($message->getFrom() as $address => $name) {
				return [$address, $name];
			}
		}
		return [];
	}
1169156
public function jsonSuccess($data = null, $message = null) {
        if (!is_array($message)) {
            $message = ['messages' => $message];
        }
        if ($data instanceof ArrayAble) {
            $data = $data->toArray();
        }
        return $this->json(array_merge(array(
            'code' => 200,
            'status' => __('success'),
            'data' => $data
        ), $message));
    }
892215
public function success($message, $data=null){
        is_object($data) && $data = (array)$data;
        $return = ['success' => true, 'message' => $message, 'data'=>$data];
        return $return;
    }
1245337
protected function buildMessage (array $message)
    {
        $doc = new DOMDocument();
        $root = $doc->createElement('xml');
        $doc->appendChild($root);
        
        $message = array_merge(
            $message,
            ['FromUserName' => $this->sender, 'ToUserName' => $this->recipient, 'CreateTime' => time()]
        );
        
        $this->fillElement($doc, $root, $message);
        
        return $doc->saveXML($doc->documentElement);
    }
781792
public function push(QueueMessage $message)
    {
        $time = new \DateTimeImmutable('now');

        $data = [
            ':queue' => $message->getQueueName() ?: $this->queue,
            ':body' => json_encode($message),
            ':attempts' => 0,
            ':created' => $time->format('Y-m-d H:i:s'),
            ':visibility' => $time->modify(sprintf('+%dseconds', $message->getDelay()))->format('Y-m-d H:i:s'),
            ':reserved' => null,
        ];

        $sql = 'INSERT INTO ' . $this->table .
            ' (queue, body, attempts, created, visibility, reserved)' .
            ' VALUES (:queue, :body, :attempts, :created, :visibility, :reserved)';

        $this->pdo->prepare($sql)->execute($data);

        return $this->pdo->lastInsertId();
    }
1085878
protected function buildFrom($message)
    {
        if (! empty($this->from)) {
            $message->from($this->from[0]['address'], $this->from[0]['name']);
        }

        return $this;
    }
49276
public function push($message)
    {
        $status = array('success' => 0, 'failure' => 0);

        foreach (static::getPlatformServices() as $platform => $service_klass) {
            $service = new $service_klass();
            $query = App::collection('push_registrations')->where('platform', $platform);
            $query->chunk(self::MAX_RECIPIENTS_PER_REQUEST, function ($registrations) use (&$platform, &$service, &$status, $message) {
                try {
                    $chunk_status = $service->push($registrations, $message);
                    $status['success'] += $chunk_status['success'];
                    $status['failure'] += $chunk_status['failure'];
                } catch (\Exception $e) {
                    Logger::debug("PushNotification: platform: {$platform} -> {$e->getMessage()}");
                }
            });
        }

        return $status;
    }
613568
public function sendMessage($message)
    {
        if ($payload = $this->getJsonPayload($message)) {
            $response = $this->getHttpClient()
                ->post($this->getWebhook(), [
                    'headers' => ['Content-Type' => 'application/json'],
                    'body' => $payload,
                ]);

            return 200 === $response->getStatusCode();
        }

        return false;
    }