<?php
class SmsMsg implements JsonSerializable {
private $template_id;
private $msg_type;
private $phone;
private $vars;
private $signature;
private $timestamp;
public function setTemplateId($template_id) {
$this->template_id = $template_id;
}
public function getTemplateId() {
return $this->template_id;
}
public function setMsgType($msgType) {
$this->msg_type = $msgType;
}
public function getMsgType() {
return $this->msg_type;
}
public function addPhoneList($phone) {
if (! is_array ( $phone )) {
array_push ( $this->phone, $phone );
} else {
foreach ( $phone as $key => $value ) {
$this->phone [] = $value;
}
}
}
public function getPhoneList() {
return $this->phone;
}
public function addVars($key, $value) {
$this->vars [$key] = $value;
}
public function addMapVars($map) {
foreach ( $map as $key => $value ) {
$this->vars [$key] = $value;
}
}
public function getVars() {
return $this->vars;
}
public function setTimestamp($timestamp) {
$this->timestamp = $timestamp;
}
public function getTimestamp() {
return $this->timestamp;
}
public function setSignature($signature) {
$this->setSignature ( $signature );
}
public function getSignature() {
return $this->signature;
}
public function jsonSerialize() {
return array_filter ( [
'templateId' => $this->getTemplateId (),
'msgType' => $this->getMsgType (),
'phone' => $this->getPhoneList (),
'vars' => $this->getVars (),
'signature' => $this->getSignature ()
] );
}
}
class VoiceMsg implements JsonSerializable {
private $phone;
private $code;
private $signature;
private $timestamp;
public function setPhone($phone) {
$this->phone = $phone;
}
public function getPhone() {
return $this->phone;
}
public function setCode($code) {
$this->code = $code;
}
public function getCode() {
return $this->code;
}
public function setSignature($signature) {
$this->signature = $signature;
}
public function getSignature() {
return $this->signature;
}
public function setTimestamp($timestamp) {
$this->timestamp = $timestamp;
}
public function getTimestamp() {
return $this->timestamp;
}
public function jsonSerialize() {
return array_filter ( [
'phone' => $this->getPhone (),
'code' => $this->getCode (),
'signature' => $this->getSignature (),
'timestamp' => $this->getTimestamp ()
] );
}
}
class MsgType {
const SMS = 0;
const MMS = 1;
const INTERNAT_SMS = 2;
const VOICE = 3;
}