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