/libraries/fabrik/vendor/twilio/sdk/src/Twilio/Rest/Taskrouter/V1/Workspace/EventInstance.php

https://github.com/trob/fabrik · PHP · 135 lines · 62 code · 13 blank · 60 comment · 3 complexity · d8467b97df97405f78823a7cfdfd8369 MD5 · raw file

  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Taskrouter\V1\Workspace;
  9. use Twilio\Deserialize;
  10. use Twilio\Exceptions\TwilioException;
  11. use Twilio\InstanceResource;
  12. use Twilio\Values;
  13. use Twilio\Version;
  14. /**
  15. * @property string $accountSid
  16. * @property string $actorSid
  17. * @property string $actorType
  18. * @property string $actorUrl
  19. * @property string $description
  20. * @property array $eventData
  21. * @property \DateTime $eventDate
  22. * @property string $eventDateMs
  23. * @property string $eventType
  24. * @property string $resourceSid
  25. * @property string $resourceType
  26. * @property string $resourceUrl
  27. * @property string $sid
  28. * @property string $source
  29. * @property string $sourceIpAddress
  30. * @property string $url
  31. * @property string $workspaceSid
  32. */
  33. class EventInstance extends InstanceResource {
  34. /**
  35. * Initialize the EventInstance
  36. *
  37. * @param \Twilio\Version $version Version that contains the resource
  38. * @param mixed[] $payload The response payload
  39. * @param string $workspaceSid The SID of the Workspace that contains the Event
  40. * @param string $sid The SID of the resource to fetch
  41. * @return \Twilio\Rest\Taskrouter\V1\Workspace\EventInstance
  42. */
  43. public function __construct(Version $version, array $payload, $workspaceSid, $sid = null) {
  44. parent::__construct($version);
  45. // Marshaled Properties
  46. $this->properties = array(
  47. 'accountSid' => Values::array_get($payload, 'account_sid'),
  48. 'actorSid' => Values::array_get($payload, 'actor_sid'),
  49. 'actorType' => Values::array_get($payload, 'actor_type'),
  50. 'actorUrl' => Values::array_get($payload, 'actor_url'),
  51. 'description' => Values::array_get($payload, 'description'),
  52. 'eventData' => Values::array_get($payload, 'event_data'),
  53. 'eventDate' => Deserialize::dateTime(Values::array_get($payload, 'event_date')),
  54. 'eventDateMs' => Values::array_get($payload, 'event_date_ms'),
  55. 'eventType' => Values::array_get($payload, 'event_type'),
  56. 'resourceSid' => Values::array_get($payload, 'resource_sid'),
  57. 'resourceType' => Values::array_get($payload, 'resource_type'),
  58. 'resourceUrl' => Values::array_get($payload, 'resource_url'),
  59. 'sid' => Values::array_get($payload, 'sid'),
  60. 'source' => Values::array_get($payload, 'source'),
  61. 'sourceIpAddress' => Values::array_get($payload, 'source_ip_address'),
  62. 'url' => Values::array_get($payload, 'url'),
  63. 'workspaceSid' => Values::array_get($payload, 'workspace_sid'),
  64. );
  65. $this->solution = array('workspaceSid' => $workspaceSid, 'sid' => $sid ?: $this->properties['sid'], );
  66. }
  67. /**
  68. * Generate an instance context for the instance, the context is capable of
  69. * performing various actions. All instance actions are proxied to the context
  70. *
  71. * @return \Twilio\Rest\Taskrouter\V1\Workspace\EventContext Context for this
  72. * EventInstance
  73. */
  74. protected function proxy() {
  75. if (!$this->context) {
  76. $this->context = new EventContext(
  77. $this->version,
  78. $this->solution['workspaceSid'],
  79. $this->solution['sid']
  80. );
  81. }
  82. return $this->context;
  83. }
  84. /**
  85. * Fetch a EventInstance
  86. *
  87. * @return EventInstance Fetched EventInstance
  88. * @throws TwilioException When an HTTP error occurs.
  89. */
  90. public function fetch() {
  91. return $this->proxy()->fetch();
  92. }
  93. /**
  94. * Magic getter to access properties
  95. *
  96. * @param string $name Property to access
  97. * @return mixed The requested property
  98. * @throws TwilioException For unknown properties
  99. */
  100. public function __get($name) {
  101. if (\array_key_exists($name, $this->properties)) {
  102. return $this->properties[$name];
  103. }
  104. if (\property_exists($this, '_' . $name)) {
  105. $method = 'get' . \ucfirst($name);
  106. return $this->$method();
  107. }
  108. throw new TwilioException('Unknown property: ' . $name);
  109. }
  110. /**
  111. * Provide a friendly representation
  112. *
  113. * @return string Machine friendly representation
  114. */
  115. public function __toString() {
  116. $context = array();
  117. foreach ($this->solution as $key => $value) {
  118. $context[] = "$key=$value";
  119. }
  120. return '[Twilio.Taskrouter.V1.EventInstance ' . \implode(' ', $context) . ']';
  121. }
  122. }