1 | <?php |
||
9 | class SendMessageRequest extends BaseRequest |
||
10 | { |
||
11 | use MessagePropertiesForSend; |
||
12 | |||
13 | private $queueName; |
||
14 | |||
15 | // boolean, whether the message body will be encoded in base64 |
||
16 | private $base64; |
||
17 | |||
18 | public function __construct($messageBody, $delaySeconds = NULL, $priority = NULL, $base64 = TRUE) |
||
19 | { |
||
20 | parent::__construct('post', NULL); |
||
21 | |||
22 | $this->queueName = NULL; |
||
23 | $this->messageBody = $messageBody; |
||
24 | $this->delaySeconds = $delaySeconds; |
||
25 | $this->priority = $priority; |
||
26 | $this->base64 = $base64; |
||
27 | } |
||
28 | |||
29 | public function setBase64($base64) |
||
30 | { |
||
31 | $this->base64 = $base64; |
||
32 | } |
||
33 | |||
34 | public function isBase64() |
||
35 | { |
||
36 | return ($this->base64 == TRUE); |
||
37 | } |
||
38 | |||
39 | public function setQueueName($queueName) |
||
40 | { |
||
41 | $this->queueName = $queueName; |
||
42 | $this->resourcePath = 'queues/' . $queueName . '/messages'; |
||
43 | } |
||
44 | |||
45 | public function getQueueName() |
||
46 | { |
||
47 | return $this->queueName; |
||
48 | } |
||
49 | |||
50 | public function generateBody() |
||
51 | { |
||
52 | $xmlWriter = new \XMLWriter; |
||
53 | $xmlWriter->openMemory(); |
||
54 | $xmlWriter->startDocument("1.0", "UTF-8"); |
||
55 | $xmlWriter->startElementNS(NULL, "Message", Constants::MNS_XML_NAMESPACE); |
||
56 | $this->writeMessagePropertiesForSendXML($xmlWriter, $this->base64); |
||
57 | $xmlWriter->endElement(); |
||
58 | $xmlWriter->endDocument(); |
||
59 | return $xmlWriter->outputMemory(); |
||
60 | } |
||
61 | |||
62 | public function generateQueryString() |
||
63 | { |
||
64 | return NULL; |
||
65 | } |
||
66 | } |
||
67 | ?> |
||
68 |