@param array $payload

@return \Kerox\Messenger\Model\Common\Address
170416
public static function fromPayload(array $payload): self
    {
        $address = self::create(
            $payload['street_1'],
            $payload['city'],
            $payload['postal_code'],
            $payload['state'],
            $payload['country']
        );

        if (isset($payload['street_2'])) {
            $address->setAdditionalStreet($payload['street_2']);
        }

        if (isset($payload['id'])) {
            $address->setId($payload['id']);
        }

        if (isset($payload['name'])) {
            $address->setName($payload['name']);
        }

        return $address;
    }
1254044
public static function simplePayload(array $payload) : array
    {
        $payload = array_filter($payload, function ($val) {
            if ($val instanceof PayloadInterface) {
                $val = $val->getPayload();
            }

            // this will effectively remove empty arrays
            if (is_array($val) && empty($val)) {
                return false;
            }

            if (is_null($val)) {
                return false;
            }

            if ($val === '') {
                return false;
            }

            return true;
        });

        foreach ($payload as $key => $val) {
            if (is_array($val)) {
                $payload[$key] = static::simplePayload($val);
            } elseif ($val instanceof PayloadInterface) {
                $payload[$key] = static::simplePayload($val->getPayload());
            }
        }

        return $payload;
    }
133060
public static function createAccountLinkingEvent(array $payload)
    {
        $accountLinking = AccountLinking::create($payload['account_linking']);
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];

        return new AccountLinkingEvent($senderId, $recipientId, $timestamp, $accountLinking);
    }
322627
public function validPayload($payload)
    {
        return is_array($payload) && isset($payload['iv'], $payload['value'], $payload['mac']) &&
               strlen(base64_decode($payload['iv'], true)) === openssl_cipher_iv_length($this->cipher);
    }
1110217
private function sign(array $payload): string
    {
        $jsonConverter = new StandardConverter();
        $payload = array_merge(
            $payload,
            $this->getAdditionalPayload()
        );
        $headers = $this->getSignatureHeader();
        $signatureKey = $this->signatureKeyset->get($this->signatureKeyIndex);
        if ($signatureKey->has('kid')) {
            $headers['kid'] = $signatureKey->get('kid');
        }

        $jws = $this->jwsBuilder
            ->create()
            ->withPayload($jsonConverter->encode($payload))
            ->addSignature($signatureKey, $headers)
            ->build();

        $serializer = new JWSCompactSerializer($jsonConverter);

        return $serializer->serialize($jws, 0);
    }
438009
public static function create(array $payload): self
    {
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $delivery = Delivery::create($payload['delivery']);

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

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

        return new static($job, $data, [], $payload);
    }
479236
public function sendSMS($payload = [])
    {
        if (empty($payload)) {
            throw IsEmpty::create("Message Payload can not be empty. Please fill the appropriate details");
        }

        $this->performPostRequest('/smsapi/send_sms', $payload);

        return $this;
    }
633822
private function setPayload($payload = null)
    {
        if (!$payload && $this->contactClient) {
            $payload = $this->contactClient->getApiPayload();
        }
        if (!$payload) {
            throw new ContactClientException(
                'API instructions not set.',
                0,
                null,
                Stat::TYPE_INVALID,
                false,
                null,
                $this->contactClient ? $this->contactClient->toArray() : null
            );
        }

        $jsonHelper = new JSONHelper();
        try {
            $this->payload = $jsonHelper->decodeObject($payload, 'Payload');
        } catch (\Exception $e) {
            throw new ContactClientException(
                'API instructions malformed.',
                0,
                $e,
                Stat::TYPE_INVALID,
                false,
                null,
                $this->contactClient ? $this->contactClient->toArray() : null
            );
        }
        $this->setSettings(!empty($this->payload->settings) ? $this->payload->settings : null);

        return $this;
    }
744467
public static function create(array $payload): self
    {
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];
        $payment = PreCheckout::create($payload['pre_checkout']);

        return new static($senderId, $recipientId, $timestamp, $payment);
    }
1262829
public function setPayload($payload)
    {
        $this->payload = $payload;

        $this->setPayloadType(gettype($payload));

        if ($payload instanceof EntityDataModel) {
            $this->setPayloadType("EntityDataModel");
        }

        if ($payload instanceof EntityCollection) {
            $this->setPayloadType("EntityCollection");
            if ($payload->isPaginated()) {
                $this->setPayloadMeta([
                    'total' => $payload->getOriginalCount(),
                    'returned' => $payload->getCount(),
                    'page' => $payload->getPage(),
                    'perPage' => $payload->getPerPage()
                ]);
            }
        }

        return $this;
    }
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;
    }
481823
public function encode(array $payload)
    {
        try {
            $this->jws->setPayload($payload)->sign($this->getSigningKey(), $this->getPassphrase());

            return (string) $this->jws->getTokenString();
        } catch (Exception $e) {
            throw new JwTException('Could not create token: '.$e->getMessage(), $e->getCode(), $e);
        }
    }
124754
public function process($payload)
    {
        foreach ($this->stages as $stage) {
            $payload = call_user_func($stage, $payload);
        }
        return $payload;
    }
768421
protected function transformPayload($payload)
    {
        if($payload instanceof Collection) {
            return $this->transformCollectionPayload($payload);
        }

        if($payload instanceof AbstractPaginator) {
            return $this->transformPaginatorPayload($payload);
        }
            
        return $this->transformer->transform($payload);
    }
1171980
public static function unserializeMessagePayload($payload)
    {
        $message = json_decode($payload, true);
        if (json_last_error() === JSON_ERROR_NONE) {
            return $message;
        }

        return $payload;
    }
307217
public function parse($payload)
    {
        if (function_exists('msgpack_unpack')) {
            if ($payload) {
                $prevHandler = set_error_handler(function ($errno, $errstr, $errfile, $errline, $errcontext) {
                    throw new \Exception($errstr);  // @codeCoverageIgnore
                });

                try {
                    $msg = msgpack_unpack(trim($payload));
                    if ( ! $msg) {
                        throw new \Exception('Unknown error');  // @codeCoverageIgnore
                    }
                } catch (\Exception $e) {
                    set_error_handler($prevHandler);
                    throw new ParserException('Failed To Parse MSGPack - ' . $e->getMessage());
                }

                set_error_handler($prevHandler);

                return $msg;
            }
            return [];
        }

        throw new ParserException('Failed To Parse MSGPack - Supporting Library Not Available');  // @codeCoverageIgnore
    }