Overview

Namespaces

  • SMSApi
    • Api
      • Action
        • Mms
        • Phonebook
        • Sender
        • Sms
        • User
        • Vms
      • Response
    • Exception
    • Proxy
      • Http

Classes

  • Delete
  • Get
  • Send
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: namespace SMSApi\Api\Action\Vms;
  4: 
  5: use SMSApi\Api\Action\AbstractAction;
  6: use SMSApi\Proxy\Uri;
  7: 
  8: /**
  9:  * Class Send
 10:  * @package SMSApi\Api\Action\Vms
 11:  */
 12: class Send extends AbstractAction {
 13: 
 14: 
 15:     const LECTOR_AGNIESZKA = "agnieszka";
 16: 
 17:     const LECTOR_EWA = "ewa";
 18: 
 19:     const LECTOR_JACEK = "jacek";
 20: 
 21:     const LECTOR_JAN = "jan";
 22: 
 23:     const LECTOR_MAJA = "maja";
 24: 
 25:     /**
 26:      * @var
 27:      */
 28:     private $tts;
 29:     /**
 30:      * @var
 31:      */
 32:     private $file;
 33: 
 34:     /**
 35:      * @param $data
 36:      * @return \SMSApi\Api\Response\StatusResponse
 37:      */
 38:     protected function response( $data ) {
 39: 
 40:         return new \SMSApi\Api\Response\StatusResponse( $data );
 41:     }
 42: 
 43:     /**
 44:      * @return Uri
 45:      * @throws \SMSApi\Exception\ActionException
 46:      */
 47:     public function uri() {
 48: 
 49:         $query = "";
 50: 
 51:         $query .= $this->paramsLoginToQuery();
 52: 
 53:         $query .= $this->paramsBasicToQuery();
 54: 
 55:         $query .= $this->paramsOther();
 56: 
 57:         if ( empty( $this->file ) && $this->tts != null ) {
 58:             $query .= "&tts=" . $this->tts;
 59:         }
 60: 
 61:         return new Uri( $this->proxy->getProtocol(), $this->proxy->getHost(), $this->proxy->getPort(), "/api/vms.do", $query );
 62:     }
 63: 
 64:     /**
 65:      * @return mixed
 66:      */
 67:     public function file() {
 68:         return $this->file;
 69:     }
 70: 
 71:     /**
 72:      * Set mobile phone number of the recipients.
 73:      *
 74:      * @param $to array|string phone number
 75:      * @return $this
 76:      */
 77:     public function setTo( $to ) {
 78: 
 79:         if ( !is_array( $to ) ) {
 80:             $to = array( $to );
 81:         }
 82: 
 83:         $this->to->exchangeArray( $to );
 84:         return $this;
 85:     }
 86: 
 87:     /**
 88:      * Set name of the group from the phone book to which message should be sent.
 89:      *
 90:      * @param string $group group name
 91:      * @return $this
 92:      */
 93:     public function setGroup( $group ) {
 94:         $this->group = $group;
 95:         return $this;
 96:     }
 97: 
 98:     /**
 99:      * Set scheduled date sending message.
100:      *
101:      * Setting a past date will result in sending message instantly.
102:      *
103:      * @param $date
104:      * @return $this
105:      */
106:     public function setDateSent( $date ) {
107:         $this->date = $date;
108:         return $this;
109:     }
110: 
111:     /**
112:      * Set optional custom value sent with SMS and sent back in CALLBACK.
113:      *
114:      * @param string|array $idx
115:      * @return $this
116:      */
117:     public function setIDx( $idx ) {
118:         if ( !is_array( $idx ) ) {
119:             $idx = array( $idx );
120:         }
121: 
122:         $this->idx->exchangeArray( $idx );
123:         return $this;
124:     }
125: 
126:     /**
127:      * Set checking idx is unique.
128:      *
129:      * Prevents from sending more than one message with the same idx.
130:      * When this parameter is set and message with the same idx was
131:      * already sent error 53 is returned.
132:      *
133:      * @param bool $check
134:      * @return $this
135:      */
136:     public function setCheckIDx( $check ) {
137:         if ( $check == true ) {
138:             $this->params[ "check_idx" ] = "1";
139:         } else if ( $check == false ) {
140:             $this->params[ "check_idx" ] = "0";
141:         }
142: 
143:         return $this;
144:     }
145: 
146:     /**
147:      * Set affiliate code.
148:      *
149:      * @param string $partner affiliate code
150:      * @return $this
151:      */
152:     public function setPartner( $partner ) {
153:         $this->params[ "partner_id" ] = $partner;
154:         return $this;
155:     }
156: 
157:     /**
158:      * Set local audio filename.
159:      *
160:      * @param $file
161:      * @return $this
162:      */
163:     public function setFile( $file ) {
164:         $this->file = $file;
165:         return $this;
166:     }
167: 
168:     /**
169:      * Set text to voice synthesizer.
170:      *
171:      * @param string $tts text to read
172:      * @return $this
173:      */
174:     public function setTts( $tts ) {
175:         $this->tts = $tts;
176:         return $this;
177:     }
178: 
179:     /**
180:      * Set flag to not send messages on cell phone numbers.
181:      *
182:      * @param $skipGsm
183:      * @return $this
184:      */
185:     public function setSkipGsm( $skipGsm ) {
186: 
187:         if ( $skipGsm == true ) {
188:             $this->params[ "skip_gsm" ] = "1";
189:         } else if ( $skipGsm == false && isset( $this->params[ "skip_gsm" ] ) ) {
190:             unset( $this->params[ "skip_gsm" ] );
191:         }
192: 
193:         return $this;
194:     }
195: 
196:     /**
197:      * Set lector name.
198:      *
199:      * @param string $lector The value of $lector can be: agnieszka, ewa, jacek, jan or maja
200:      * @return $this
201:      */
202:     public function setTtsLector( $lector ) {
203:         $this->params[ "tts_lector" ] = $lector;
204:         return $this;
205:     }
206: 
207:     /**
208:      * Set called number. Leaving the field blank causes the sending of the default number of callers.
209:      *
210:      * @param $from
211:      * @return $this
212:      */
213:     public function setFrom( $from ) {
214:         $this->params[ "from" ] = $from;
215:         return $this;
216:     }
217: 
218:     /**
219:      * Set number of connection attempts.
220:      *
221:      * @param integer $try Number of connection attempts
222:      * @return $this
223:      * @throws \OutOfRangeException
224:      */
225:     public function setTry($try)
226:     {
227:         if($try < 1 || $try > 6) {
228:             throw new \OutOfRangeException;
229:         }
230: 
231:         $this->params['try'] = $try;
232:         return $this;
233:     }
234: 
235:     /**
236:      * Set the time in seconds where the connection have to be repeated
237:      * in the case of not answer by receiver or reject this connection.
238:      *
239:      * @param integer $interval Time in seconds
240:      *
241:      * @return $this
242:      * @throws \OutOfRangeException
243:      */
244:     public function setInterval($interval)
245:     {
246:         if($interval < 300 || $interval > 7200) {
247:             throw new \OutOfRangeException;
248:         }
249: 
250:         $this->params['interval'] = $interval;
251:         return $this;
252:     }
253: 
254: }
SMSAPI api client API documentation generated by ApiGen 2.8.0