WebhookInstance.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\IpMessaging\V2\Service\Channel;
  9. use Twilio\Deserialize;
  10. use Twilio\Exceptions\TwilioException;
  11. use Twilio\InstanceResource;
  12. use Twilio\Options;
  13. use Twilio\Values;
  14. use Twilio\Version;
  15. /**
  16. * @property string sid
  17. * @property string accountSid
  18. * @property string serviceSid
  19. * @property string channelSid
  20. * @property string type
  21. * @property string url
  22. * @property array configuration
  23. * @property \DateTime dateCreated
  24. * @property \DateTime dateUpdated
  25. */
  26. class WebhookInstance extends InstanceResource {
  27. /**
  28. * Initialize the WebhookInstance
  29. *
  30. * @param \Twilio\Version $version Version that contains the resource
  31. * @param mixed[] $payload The response payload
  32. * @param string $serviceSid The service_sid
  33. * @param string $channelSid The channel_sid
  34. * @param string $sid The sid
  35. * @return \Twilio\Rest\IpMessaging\V2\Service\Channel\WebhookInstance
  36. */
  37. public function __construct(Version $version, array $payload, $serviceSid, $channelSid, $sid = null) {
  38. parent::__construct($version);
  39. // Marshaled Properties
  40. $this->properties = array(
  41. 'sid' => Values::array_get($payload, 'sid'),
  42. 'accountSid' => Values::array_get($payload, 'account_sid'),
  43. 'serviceSid' => Values::array_get($payload, 'service_sid'),
  44. 'channelSid' => Values::array_get($payload, 'channel_sid'),
  45. 'type' => Values::array_get($payload, 'type'),
  46. 'url' => Values::array_get($payload, 'url'),
  47. 'configuration' => Values::array_get($payload, 'configuration'),
  48. 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
  49. 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
  50. );
  51. $this->solution = array(
  52. 'serviceSid' => $serviceSid,
  53. 'channelSid' => $channelSid,
  54. 'sid' => $sid ?: $this->properties['sid'],
  55. );
  56. }
  57. /**
  58. * Generate an instance context for the instance, the context is capable of
  59. * performing various actions. All instance actions are proxied to the context
  60. *
  61. * @return \Twilio\Rest\IpMessaging\V2\Service\Channel\WebhookContext Context
  62. * for this
  63. * WebhookInstance
  64. */
  65. protected function proxy() {
  66. if (!$this->context) {
  67. $this->context = new WebhookContext(
  68. $this->version,
  69. $this->solution['serviceSid'],
  70. $this->solution['channelSid'],
  71. $this->solution['sid']
  72. );
  73. }
  74. return $this->context;
  75. }
  76. /**
  77. * Fetch a WebhookInstance
  78. *
  79. * @return WebhookInstance Fetched WebhookInstance
  80. * @throws TwilioException When an HTTP error occurs.
  81. */
  82. public function fetch() {
  83. return $this->proxy()->fetch();
  84. }
  85. /**
  86. * Update the WebhookInstance
  87. *
  88. * @param array|Options $options Optional Arguments
  89. * @return WebhookInstance Updated WebhookInstance
  90. * @throws TwilioException When an HTTP error occurs.
  91. */
  92. public function update($options = array()) {
  93. return $this->proxy()->update($options);
  94. }
  95. /**
  96. * Deletes the WebhookInstance
  97. *
  98. * @return boolean True if delete succeeds, false otherwise
  99. * @throws TwilioException When an HTTP error occurs.
  100. */
  101. public function delete() {
  102. return $this->proxy()->delete();
  103. }
  104. /**
  105. * Magic getter to access properties
  106. *
  107. * @param string $name Property to access
  108. * @return mixed The requested property
  109. * @throws TwilioException For unknown properties
  110. */
  111. public function __get($name) {
  112. if (array_key_exists($name, $this->properties)) {
  113. return $this->properties[$name];
  114. }
  115. if (property_exists($this, '_' . $name)) {
  116. $method = 'get' . ucfirst($name);
  117. return $this->$method();
  118. }
  119. throw new TwilioException('Unknown property: ' . $name);
  120. }
  121. /**
  122. * Provide a friendly representation
  123. *
  124. * @return string Machine friendly representation
  125. */
  126. public function __toString() {
  127. $context = array();
  128. foreach ($this->solution as $key => $value) {
  129. $context[] = "$key=$value";
  130. }
  131. return '[Twilio.IpMessaging.V2.WebhookInstance ' . implode(' ', $context) . ']';
  132. }
  133. }