V2.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\IpMessaging;
  9. use Twilio\Domain;
  10. use Twilio\Exceptions\TwilioException;
  11. use Twilio\Rest\IpMessaging\V2\CredentialList;
  12. use Twilio\Rest\IpMessaging\V2\ServiceList;
  13. use Twilio\Version;
  14. /**
  15. * @property \Twilio\Rest\IpMessaging\V2\CredentialList credentials
  16. * @property \Twilio\Rest\IpMessaging\V2\ServiceList services
  17. * @method \Twilio\Rest\IpMessaging\V2\CredentialContext credentials(string $sid)
  18. * @method \Twilio\Rest\IpMessaging\V2\ServiceContext services(string $sid)
  19. */
  20. class V2 extends Version {
  21. protected $_credentials = null;
  22. protected $_services = null;
  23. /**
  24. * Construct the V2 version of IpMessaging
  25. *
  26. * @param \Twilio\Domain $domain Domain that contains the version
  27. * @return \Twilio\Rest\IpMessaging\V2 V2 version of IpMessaging
  28. */
  29. public function __construct(Domain $domain) {
  30. parent::__construct($domain);
  31. $this->version = 'v2';
  32. }
  33. /**
  34. * @return \Twilio\Rest\IpMessaging\V2\CredentialList
  35. */
  36. protected function getCredentials() {
  37. if (!$this->_credentials) {
  38. $this->_credentials = new CredentialList($this);
  39. }
  40. return $this->_credentials;
  41. }
  42. /**
  43. * @return \Twilio\Rest\IpMessaging\V2\ServiceList
  44. */
  45. protected function getServices() {
  46. if (!$this->_services) {
  47. $this->_services = new ServiceList($this);
  48. }
  49. return $this->_services;
  50. }
  51. /**
  52. * Magic getter to lazy load root resources
  53. *
  54. * @param string $name Resource to return
  55. * @return \Twilio\ListResource The requested resource
  56. * @throws \Twilio\Exceptions\TwilioException For unknown resource
  57. */
  58. public function __get($name) {
  59. $method = 'get' . ucfirst($name);
  60. if (method_exists($this, $method)) {
  61. return $this->$method();
  62. }
  63. throw new TwilioException('Unknown resource ' . $name);
  64. }
  65. /**
  66. * Magic caller to get resource contexts
  67. *
  68. * @param string $name Resource to return
  69. * @param array $arguments Context parameters
  70. * @return \Twilio\InstanceContext The requested resource context
  71. * @throws \Twilio\Exceptions\TwilioException For unknown resource
  72. */
  73. public function __call($name, $arguments) {
  74. $property = $this->$name;
  75. if (method_exists($property, 'getContext')) {
  76. return call_user_func_array(array($property, 'getContext'), $arguments);
  77. }
  78. throw new TwilioException('Resource does not have a context');
  79. }
  80. /**
  81. * Provide a friendly representation
  82. *
  83. * @return string Machine friendly representation
  84. */
  85. public function __toString() {
  86. return '[Twilio.IpMessaging.V2]';
  87. }
  88. }