[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/externals/twilio-php/Services/Twilio/Rest/ -> IncomingPhoneNumbers.php (source)

   1  <?php
   2  
   3  /**
   4   * For more information, see the
   5   * `IncomingPhoneNumbers API Resource
   6   * <http://www.twilio.com/docs/api/rest/incoming-phone-numbers#local>`_
   7   * documentation at twilio.com.
   8   */
   9  class Services_Twilio_Rest_IncomingPhoneNumbers extends Services_Twilio_ListResource {
  10      function init($client, $uri) {
  11          $this->setupSubresources(
  12              'local',
  13              'toll_free',
  14              'mobile'
  15          );
  16      }
  17  
  18      function create(array $params = array()) {
  19          return parent::_create($params);
  20      }
  21  
  22      function getList($type, array $params = array())
  23      {
  24          return $this->client->retrieveData($this->uri . "/$type", $params);
  25      }
  26  
  27      /**
  28       * Return a phone number instance from its E.164 representation. If more
  29       * than one number matches the search string, returns the first one.
  30       *
  31       * Example usage:
  32       *
  33       * .. code-block:: php
  34       *
  35       *      $number = $client->account->incoming_phone_numbers->getNumber('+14105551234');
  36       *      echo $number->sid;
  37       *
  38       * :param string $number: The number in E.164 format, eg "+684105551234"
  39       * :return:  A :php:class:`Services_Twilio_Rest_IncomingPhoneNumber` object, or null
  40       * :raises: a A :php:class:`Services_Twilio_RestException` if the number is
  41       *      invalid, not provided in E.164 format or for any other API exception.
  42       */
  43      public function getNumber($number) {
  44          $page = $this->getPage(0, 1, array(
  45              'PhoneNumber' => $number
  46          ));
  47          $items = $page->getItems();
  48          if (is_null($items) || empty($items)) {
  49              return null;
  50          }
  51          return $items[0];
  52      }
  53  }
  54  
  55  class Services_Twilio_Rest_Local extends Services_Twilio_NumberType { }
  56  
  57  class Services_Twilio_Rest_Mobile extends Services_Twilio_NumberType { }
  58  
  59  class Services_Twilio_Rest_TollFree extends Services_Twilio_NumberType { }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1