aboutsummaryrefslogtreecommitdiff
path: root/src/messages/RequestMessage.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/messages/RequestMessage.php')
-rw-r--r--src/messages/RequestMessage.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/messages/RequestMessage.php b/src/messages/RequestMessage.php
new file mode 100644
index 0000000..12ab7ad
--- /dev/null
+++ b/src/messages/RequestMessage.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace jobd\messages;
+
+class RequestMessage extends Message {
+
+ protected $requestNo;
+ protected $requestType;
+ protected $requestData;
+ protected $password;
+
+ /**
+ * Request constructor.
+ * @param string $request_type
+ * @param null|array $request_data
+ */
+ public function __construct(string $request_type, $request_data = null)
+ {
+ parent::__construct(Message::REQUEST);
+
+ $this->requestData = $request_data;
+ $this->requestType = $request_type;
+ }
+
+ /**
+ * @param string $password
+ */
+ public function setPassword(string $password)
+ {
+ $this->password = $password;
+ }
+
+ /**
+ * @param int $no
+ */
+ public function setRequestNo(int $no)
+ {
+ $this->requestNo = $no;
+ }
+
+ /**
+ * @return string[]
+ */
+ protected function getContent(): array
+ {
+ $request = [
+ 'type' => $this->requestType,
+ 'no' => $this->requestNo,
+ ];
+
+ if (!is_null($this->requestData))
+ $request['data'] = (object)$this->requestData;
+
+ if (!is_null($this->password))
+ $request['password'] = $this->password;
+
+ return $request;
+ }
+
+} \ No newline at end of file