AvailablePhoneNumbers.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. class Services_Twilio_Rest_AvailablePhoneNumbers
  3. extends Services_Twilio_ListResource
  4. {
  5. public function getLocal($country) {
  6. $curried = new Services_Twilio_PartialApplicationHelper();
  7. $curried->set(
  8. 'getList',
  9. array($this, 'getList'),
  10. array($country, 'Local')
  11. );
  12. return $curried;
  13. }
  14. public function getTollFree($country) {
  15. $curried = new Services_Twilio_PartialApplicationHelper();
  16. $curried->set(
  17. 'getList',
  18. array($this, 'getList'),
  19. array($country, 'TollFree')
  20. );
  21. return $curried;
  22. }
  23. public function getMobile($country)
  24. {
  25. $curried = new Services_Twilio_PartialApplicationHelper();
  26. $curried->set(
  27. 'getList',
  28. array($this, 'getList'),
  29. array($country, 'Mobile')
  30. );
  31. return $curried;
  32. }
  33. /**
  34. * Get a list of available phone numbers.
  35. *
  36. * @param string $country The 2-digit country code you'd like to search for
  37. * numbers e.g. ('US', 'CA', 'GB')
  38. * @param string $type The type of number ('Local', 'TollFree', or 'Mobile')
  39. * @return object The object representation of the resource
  40. */
  41. public function getList($country, $type, array $params = array())
  42. {
  43. return $this->client->retrieveData($this->uri . "/$country/$type", $params);
  44. }
  45. public function getResourceName($camelized = false) {
  46. // You can't page through the list of available phone numbers.
  47. $this->instance_name = 'Services_Twilio_Rest_AvailablePhoneNumber';
  48. return $camelized ? 'Countries' : 'countries';
  49. }
  50. }