[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 abstract class PhabricatorSMSImplementationAdapter { 4 5 private $fromNumber; 6 private $toNumber; 7 private $body; 8 9 public function setFrom($number) { 10 $this->fromNumber = $number; 11 return $this; 12 } 13 14 public function getFrom() { 15 return $this->fromNumber; 16 } 17 18 public function setTo($number) { 19 $this->toNumber = $number; 20 return $this; 21 } 22 23 public function getTo() { 24 return $this->toNumber; 25 } 26 27 public function setBody($body) { 28 $this->body = $body; 29 return $this; 30 } 31 32 public function getBody() { 33 return $this->body; 34 } 35 36 /** 37 * 16 characters or less, to be used in database columns and exposed 38 * to administrators during configuration directly. 39 */ 40 abstract public function getProviderShortName(); 41 42 /** 43 * Send the message. Generally, this means connecting to some service and 44 * handing data to it. SMS APIs are generally asynchronous, so truly 45 * determining success or failure is probably impossible synchronously. 46 * 47 * That said, if the adapter determines that the SMS will never be 48 * deliverable, or there is some other known failure, it should throw 49 * an exception. 50 * 51 * @return null 52 */ 53 abstract public function send(); 54 55 /** 56 * Most (all?) SMS APIs are asynchronous, but some do send back some 57 * initial information. Use this hook to determine what the updated 58 * sentStatus should be and what the provider is using for an SMS ID, 59 * as well as throw exceptions if there are any failures. 60 * 61 * @return array Tuple of ($sms_id and $sent_status) 62 */ 63 abstract public function getSMSDataFromResult($result); 64 65 /** 66 * Due to the asynchronous nature of sending SMS messages, it can be 67 * necessary to poll the provider regarding the sent status of a given 68 * sms. 69 * 70 * For now, this *MUST* be implemented and *MUST* work. 71 */ 72 abstract public function pollSMSSentStatus(PhabricatorSMS $sms); 73 74 /** 75 * Convenience function to handle sending an SMS. 76 */ 77 public static function sendSMS(array $to_numbers, $body) { 78 PhabricatorWorker::scheduleTask( 79 'PhabricatorSMSDemultiplexWorker', 80 array( 81 'toNumbers' => $to_numbers, 82 'body' => $body, 83 ), 84 PhabricatorWorker::PRIORITY_ALERTS); 85 } 86 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |