1: <?php
2:
3: namespace SMSApi\Api\Action\Mms;
4:
5: use SMSApi\Api\Action\AbstractAction;
6: use SMSApi\Api\Response\CountableResponse;
7: use SMSApi\Proxy\Uri;
8:
9: /**
10: * Class Delete
11: * @package SMSApi\Api\Action\Mms
12: *
13: * @method CountableResponse execute()
14: */
15: class Delete extends AbstractAction
16: {
17: /**
18: * @var \ArrayObject
19: */
20: private $id;
21:
22: /**
23: *
24: */
25: function __construct() {
26: $this->id = new \ArrayObject();
27: }
28:
29: /**
30: * @param $data
31: * @return CountableResponse
32: */
33: protected function response($data)
34: {
35: return new CountableResponse($data);
36: }
37:
38: /**
39: * @return Uri
40: */
41: public function uri() {
42:
43: $query = "";
44:
45: $query .= $this->paramsLoginToQuery();
46:
47: $query .= $this->paramsOther();
48:
49: $query .= "&sch_del=" . implode( "|", $this->id->getArrayCopy() );
50:
51: return new Uri( $this->proxy->getProtocol(), $this->proxy->getHost(), $this->proxy->getPort(), "/api/mms.do", $query );
52: }
53:
54: /**
55: * Set ID of messages to delete.
56: *
57: * This id was returned after sending message.
58: *
59: * @param $id
60: * @return $this
61: * @throws \SMSApi\Exception\ActionException
62: */
63: public function filterById( $id ) {
64: if ( !is_string( $id ) ) {
65: throw new \SMSApi\Exception\ActionException( 'Invalid value id' );
66: }
67:
68: $this->id->append( $id );
69: return $this;
70: }
71:
72: /**
73: *
74: * Set array IDs of messages to delete.
75: *
76: * This id was returned after sending message.
77: *
78: * @param $ids
79: * @return $this
80: * @throws \SMSApi\Exception\ActionException
81: */
82: public function filterByIds( array $ids ) {
83:
84: $this->id->exchangeArray( $ids );
85: return $this;
86: }
87:
88: /**
89: * @deprecated since v1.0.0
90: */
91: public function ids($array) {
92: return $this->filterByIds($array);
93: }
94:
95: /**
96: * @deprecated since v1.0.0
97: */
98: public function id($id) {
99: return $this->filterById($id);
100: }
101:
102: }
103:
104: