Create a new MessageInstance

@param string $body The body
@param array|Options $options Optional Arguments
@return MessageInstance Newly created MessageInstance
@throws TwilioException When an HTTP error occurs.
976103
public function create($body, $options = array()) {
        $options = new Values($options);

        $data = Values::of(array(
            'Body' => $body,
            'From' => $options['from'],
            'Attributes' => $options['attributes'],
        ));

        $payload = $this->version->create(
            'POST',
            $this->uri,
            array(),
            $data
        );

        return new MessageInstance(
            $this->version,
            $payload,
            $this->solution['serviceSid'],
            $this->solution['channelSid']
        );
    }
100611
public function createRequest($method = 'GET', $uri = null, $headers = null, $body = null, array $options = array())
    {
        $uri = '{+base_path}/' . ltrim($uri, '/');
        return parent::createRequest($method, $uri, $headers, $body, $options);
    }
24829
public function createSms($body, array $recipients, $sender)
    {
        $sms = $this->createEmptySms();
        $sms->setBody($body);
        $sms->setRecipients($recipients);
        $sms->setSender($sender);

        return $sms;
    }
1260938
public function createSms($body, $recipients, $sender)
    {
        if (is_array($recipients)) {
            $sms = $this->factory->createSms($body, $recipients, $sender);
        } else {
            $sms = $this->factory->createSms($body, array($recipients), $sender);
        }

        return $sms;
    }
735045
public function addBody($body)
    {
        Assert::stringNotEmpty($body, 'The method body must be a non-empty string. Got: %s');

        if ($this->body) {
            $this->body .= "\n".$body;
        } else {
            $this->body = $body;
        }

        return $this;
    }
1228319
public function createSwooleServer(array $options = array())
    {
        if (array() === $options) {
            $options = array(
                'daemonize' => false,
                'worker_num' => 1,
            );
        }

        return new SwooleServer(
            new SwooleMessageTransformer($this->getPsr7Factory()),
            new SwooleServerOptions($options)
        );
    }
71045
public static function create(array $body, $collectionUrl, ClientInterface $client)
    {
        if ($errors = static::checkNew($body)) {
            $message = "Cannot create resource due to validation error(s): " . implode('; ', $errors);
            throw new \InvalidArgumentException($message);
        }

        $request = new Request('post', $collectionUrl, [], \GuzzleHttp\json_encode($body));
        $data = self::send($request, $client);

        return new Result($data, $collectionUrl, $client, get_called_class());
    }
77047
public static function create(
        $body,
        TypeResolver $typeResolver = null,
        DescriptionFactory $descriptionFactory = null,
        TypeContext $context = null
    )
    {
        Assert::stringNotEmpty($body);
        Assert::allNotNull([$typeResolver, $descriptionFactory]);

        preg_match(self::REGEXP, $body, $parts);

        $description = null;

        if (null !== $descriptionFactory) {
            $descriptionStr = isset($parts['description']) ? trim($parts['description']) : '';
            $description = $descriptionFactory->create($descriptionStr, $context);
        }

        $typeStr = isset($parts['type']) ? trim($parts['type']) : 'mixed';
        $typeExtended = $parts['typeFormat'] ?? null;
        $variableName = $parts['variableName'] ?? 'variable';

        $type = CustomTypeResolver::resolve($typeStr, $typeExtended);

        /** @var static $param */
        $param = new static($variableName, $type, $description);

        $param->setOptional(empty($parts['require']));

        if (!empty($parts['defaultValue'])) {
            $param->setDefault(self::getRealValue($parts['defaultValue']));
        }
        if (!empty($parts['exampleValue'])) {
            $param->setExample(self::getRealValue($parts['exampleValue']));
        }

        return $param;
    }
463796
protected function createMessage($body)
    {
        $now = new \DateTime('now', new \DateTimezone('UTC'));
        $message = new Message();
        $message->setAttributes([
            'id'         => $this->redis->incr($this->id.self::MESSAGE_ID),
            'status'     => Message::AVAILABLE,
            'created_on' => $now->format('Y-m-d H:i:s'),
            'sender_id'  => Yii::$app->has('user') ? Yii::$app->user->getId() : null,
            'body'       => $body,
        ]);

        return $this->formatMessage($message);
    }
1088912
final public function withBody(StreamInterface $body): self
    {
        $message = clone $this;
        $message->body = $body;

        return $message;
    }
517867
public function create($collection = null, $body = null, array $urlQuery = [], array $options = [])
    {

        /** @var AbstractHttpRequest $request */
        $request          = $this->getRequest();
        $request->options = $options;
        $request->body    = $body;

        if (is_array($request->body)) {
            $request->body = json_encode($request->body);
        }

        $request->path = $this->client->fullDatabasePath . static::API_PATH;

        if (null !== $collection) {
            $urlQuery = array_merge(
                $urlQuery ?: [],
                ['collection' => $collection]
            );
        }

        $urlQueryStr = $request->buildUrlQuery($urlQuery);

        $request->path .= $urlQueryStr;

        $request->method = static::METHOD_POST;

        return $this->getReturnObject($request);
    }
451967
public function createForm($entity, $options = [])
    {
        $options = array_merge($this->type()['formFields']['_create'], $options);

        return $this->Form->create($entity, $options);
    }
1400
public function create($options = array()) {
        $options = new Values($options);

        $data = Values::of(array(
            'Identity' => Serialize::map($options['identity'], function($e) { return $e; }),
            'Tag' => Serialize::map($options['tag'], function($e) { return $e; }),
            'Body' => $options['body'],
            'Priority' => $options['priority'],
            'Ttl' => $options['ttl'],
            'Title' => $options['title'],
            'Sound' => $options['sound'],
            'Action' => $options['action'],
            'Data' => Serialize::jsonObject($options['data']),
            'Apn' => Serialize::jsonObject($options['apn']),
            'Gcm' => Serialize::jsonObject($options['gcm']),
            'Sms' => Serialize::jsonObject($options['sms']),
            'FacebookMessenger' => Serialize::jsonObject($options['facebookMessenger']),
            'Fcm' => Serialize::jsonObject($options['fcm']),
            'Segment' => Serialize::map($options['segment'], function($e) { return $e; }),
            'Alexa' => Serialize::jsonObject($options['alexa']),
            'ToBinding' => Serialize::map($options['toBinding'], function($e) { return $e; }),
        ));

        $payload = $this->version->create(
            'POST',
            $this->uri,
            array(),
            $data
        );

        return new NotificationInstance($this->version, $payload, $this->solution['serviceSid']);
    }
212691
public function create(array $options = [])
    {
        foreach (['host', 'port', 'username', 'secret'] as $key) {
            $options[$key] = Arr::get($options, $key, null);
        }
        $promise = $this->connector->create($options['host'], $options['port'])->then(function (Stream $stream) {
            return new Client($stream, new Parser());
        });
        if (!is_null($options['username'])) {
            $promise = $promise->then(function (Client $client) use ($options) {
                $sender = new ActionSender($client);

                return $sender->login($options['username'], $options['secret'])->then(
                    function () use ($client) {
                        return $client;
                    },
                    function ($error) use ($client) {
                        $client->close();
                        throw $error;
                    }
                );
            }, function ($error) {
                throw $error;
            });
        }

        return $promise;
    }
780446
public function createRequest($method, $url, array $options = [])
    {
        $headers = isset($options['headers']) ? $options['headers'] : [];

        $body = isset($options['body']) ? $options['body'] : null;

        return new Request($method, $url, $headers, $body);
    }
700143
public function message($protocolVersion, $headers, $body)
    {
        return new Messages\Message\Implementation(
            $protocolVersion,
            $headers,
            $body
        );
    }
1251056
public function addTransientMessage($message, $options = null) {
		$options = $this->_mergeOptions($options);
		$options['message'] = $message;

		$messages = (array)Configure::read('TransientFlash.' . $options['key']);
		if ($messages && count($messages) > $this->getConfig('limit')) {
			array_shift($messages);
		}
		$messages[] = $options;
		Configure::write('TransientFlash.' . $options['key'], $messages);
	}