Generate Payload Data

@param array $payload
@param string $container

@throws ResponderException

@return string
337157
public function generate($payload, $container = 'data')
    {
        $function      = null;
        $function_list = [
            'bson_encode',
            'MongoDB\BSON\fromPHP',
        ];

        foreach ($function_list as $bson_function) {
            if (function_exists($bson_function)) {
                $function = $bson_function;
            }
        }

        if (is_null($function)) {
            throw new ResponderException('Failed To Generate BSON - Supporting Library Not Available');  // @codeCoverageIgnore
        }

        if ($payload) {
            $prevHandler = set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
                throw new \Exception;  // @codeCoverageIgnore
            });

            try {
                $bson = $function([$container => $payload]);
                if ( ! $bson) {
                    throw new \Exception;  // @codeCoverageIgnore
                }
            } catch (\Exception $e) {
                set_error_handler($prevHandler);
                throw new ResponderException('Failed To Generate BSON');
            }

            set_error_handler($prevHandler);

            return $bson;
        }

        return '';
    }
1016839
public function respondCreatedWithPayload($payload = null, $message = "Created")
    {

        $reponse = $this->setStatusCode(ResponseHTTP::HTTP_CREATED)
            ->respondWithMessageAndPayload($payload, $message);
        return $reponse;
    }
169079
protected function buildPayHtml($endpoint, $payload, $method = 'POST'): Response
    {
        if (strtoupper($method) === 'GET') {
            return RedirectResponse::create($endpoint.'?'.http_build_query($payload));
        }

        $sHtml = "<form id='alipay_submit' name='alipay_submit' action='".$endpoint."' method='.$method.'>";
        foreach ($payload as $key => $val) {
            $val = str_replace("'", '&apos;', $val);
            $sHtml .= "<input type='hidden' name='".$key."' value='".$val."'/>";
        }
        $sHtml .= "<input type='submit' value='ok' style='display:none;'></form>";
        $sHtml .= "<script>document.forms['alipay_submit'].submit();</script>";

        return Response::create($sHtml);
    }
1171980
public static function unserializeMessagePayload($payload)
    {
        $message = json_decode($payload, true);
        if (json_last_error() === JSON_ERROR_NONE) {
            return $message;
        }

        return $payload;
    }
1052599
public static function createFromPayload(array $payload)
    {
        $job = $payload['job'];
        $data = $payload['data'];

        unset($payload['job'], $payload['data']);

        return new static($job, $data, [], $payload);
    }
1204227
protected function parseEventAndPayload($event, $payload)
    {
        if (is_object($event)) {
            list($payload, $event) = [[$event], get_class($event)];
        }

        return [$event, array_wrap($payload)];
    }
1253301
public function buildPayload(array $payload)
    {
        if ($visible = $this->getVisible()) {
            $payload = array_only($payload, $visible);
        }

        if ($hidden = $this->getHidden()) {
            $payload = array_except($payload, $hidden);
        }

        return $payload;
    }
266180
public static function createPostbackEvent(array $payload)
    {
        $postback = Postback::create($payload['postback']);
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];

        return new PostbackEvent($senderId, $recipientId, $timestamp, $postback);
    }
1007477
public function encode(Payload $payload)
    {
        $token = $this->jwt->encode($payload->get());

        return new Token($token);
    }
641040
public function respondWithMessageAndPayload($payload = null, $message = "Ok")
    {
        $data = $this->getResponseStructure(true, $payload, $message);
        $reponse = $this->respond($data);
        return $reponse;
    }
1136456
public function process($payload) {
        $result = $this->convertToObject($payload, true);

        return $this->processPayload($result);
    }
910342
public function generate($payload, $container = 'data')
    {
        if ($payload) {
            try {
                $flags = (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT_AS_MAP')) ? (SFYaml::DUMP_OBJECT_AS_MAP | SFYaml::DUMP_EXCEPTION_ON_INVALID_TYPE) : true;
                return SFYaml::dump([$container => $payload], 9999, 4, $flags);
            } catch (\Exception $ex) {
                throw new ResponderException('Failed To Generate YAML');
            }
        }

        return '';
    }
1065565
final public function process($payload)
    {
        $payload = $this->processor->processStack($payload, $this->stack);

        if ( $this->next instanceof PipeChainInterface ) {
            $payload = $this->next->process($payload);
        }

        return $payload;
    }
921627
public static function createMessageReadEvent(array $payload)
    {
        $read = Read::create($payload['read']);
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];

        return new MessageReadEvent($senderId, $recipientId, $timestamp, $read);
    }
321590
protected function redefineResponse(&$container)
    {
        // Redefine - response
        $container['response'] = function (Container $container) {
            $headers = new Headers(['Content-Type' => 'application/json;charset=utf-8']);
            $response = new Response(200, $headers);
            return $response->withProtocolVersion($container->get('settings')['httpVersion']);
        };
    }
78404
private function sendTransmission(array $payload)
    {
        try {
            /** @noinspection PhpUndefinedVariableInspection */
            $promise = $this->sparkpost->transmissions->post($payload);

            if ($promise instanceof SparkPostResponse) {
                $response = $promise;
            } else {
                $response = $promise->wait();
            }
        } catch (AnyException $exception) {
            throw $this->createAndDispatchTransportException(
                'Failed to send transmission to SparkPost',
                $exception
            );
        }

        if (!isset($response->getBody()['results'])) {
            throw $this->createAndDispatchTransportException(
                'Failed to send transmission to SparkPost',
                new Exception(json_encode($response->getBody()))
            );
        }

        return $response;
    }
214059
public function fillBlanks($payload)
    {
        $fields = ['doi', 'url', 'message', 'verbosemessage', 'responsecode', 'app_id'];
        foreach ($fields as $field) {
            if (!array_key_exists($field, $payload)) {
                $payload[$field] = "";
            }
        }
        return $payload;
    }