Файл: sngine-v2.8/Script/includes/libs/Twilio/Rest/Conversations/V1/Conversation/MessageContext.php
Строк: 168
<?php
/**
* This code was generated by
* / _ _ _| _ _
* | (_)/(_)(_|/| |(/_ v1.0.0
* / /
*/
namespace TwilioRestConversationsV1Conversation;
use TwilioExceptionsTwilioException;
use TwilioInstanceContext;
use TwilioOptions;
use TwilioSerialize;
use TwilioValues;
use TwilioVersion;
/**
* PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
*/
class MessageContext extends InstanceContext {
/**
* Initialize the MessageContext
*
* @param Version $version Version that contains the resource
* @param string $conversationSid The unique id of the Conversation for this
* message.
* @param string $sid A 34 character string that uniquely identifies this
* resource.
*/
public function __construct(Version $version, $conversationSid, $sid) {
parent::__construct($version);
// Path Solution
$this->solution = ['conversationSid' => $conversationSid, 'sid' => $sid, ];
$this->uri = '/Conversations/' . rawurlencode($conversationSid) . '/Messages/' . rawurlencode($sid) . '';
}
/**
* Update the MessageInstance
*
* @param array|Options $options Optional Arguments
* @return MessageInstance Updated MessageInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function update(array $options = []): MessageInstance {
$options = new Values($options);
$data = Values::of([
'Author' => $options['author'],
'Body' => $options['body'],
'DateCreated' => Serialize::iso8601DateTime($options['dateCreated']),
'DateUpdated' => Serialize::iso8601DateTime($options['dateUpdated']),
'Attributes' => $options['attributes'],
]);
$headers = Values::of(['X-Twilio-Webhook-Enabled' => $options['xTwilioWebhookEnabled'], ]);
$payload = $this->version->update('POST', $this->uri, [], $data, $headers);
return new MessageInstance(
$this->version,
$payload,
$this->solution['conversationSid'],
$this->solution['sid']
);
}
/**
* Delete the MessageInstance
*
* @param array|Options $options Optional Arguments
* @return bool True if delete succeeds, false otherwise
* @throws TwilioException When an HTTP error occurs.
*/
public function delete(array $options = []): bool {
$options = new Values($options);
$headers = Values::of(['X-Twilio-Webhook-Enabled' => $options['xTwilioWebhookEnabled'], ]);
return $this->version->delete('DELETE', $this->uri, [], [], $headers);
}
/**
* Fetch the MessageInstance
*
* @return MessageInstance Fetched MessageInstance
* @throws TwilioException When an HTTP error occurs.
*/
public function fetch(): MessageInstance {
$payload = $this->version->fetch('GET', $this->uri);
return new MessageInstance(
$this->version,
$payload,
$this->solution['conversationSid'],
$this->solution['sid']
);
}
/**
* Provide a friendly representation
*
* @return string Machine friendly representation
*/
public function __toString(): string {
$context = [];
foreach ($this->solution as $key => $value) {
$context[] = "$key=$value";
}
return '[Twilio.Conversations.V1.MessageContext ' . implode(' ', $context) . ']';
}
}