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

https://github.com/trob/fabrik · PHP · 318 lines · 153 code · 40 blank · 125 comment · 12 complexity · a6c662200431be2ed890ca339619be56 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;
  9. use Twilio\Exceptions\TwilioException;
  10. use Twilio\InstanceContext;
  11. use Twilio\Options;
  12. use Twilio\Rest\Taskrouter\V1\Workspace\ActivityList;
  13. use Twilio\Rest\Taskrouter\V1\Workspace\EventList;
  14. use Twilio\Rest\Taskrouter\V1\Workspace\TaskChannelList;
  15. use Twilio\Rest\Taskrouter\V1\Workspace\TaskList;
  16. use Twilio\Rest\Taskrouter\V1\Workspace\TaskQueueList;
  17. use Twilio\Rest\Taskrouter\V1\Workspace\WorkerList;
  18. use Twilio\Rest\Taskrouter\V1\Workspace\WorkflowList;
  19. use Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceCumulativeStatisticsList;
  20. use Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceRealTimeStatisticsList;
  21. use Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceStatisticsList;
  22. use Twilio\Serialize;
  23. use Twilio\Values;
  24. use Twilio\Version;
  25. /**
  26. * @property \Twilio\Rest\Taskrouter\V1\Workspace\ActivityList $activities
  27. * @property \Twilio\Rest\Taskrouter\V1\Workspace\EventList $events
  28. * @property \Twilio\Rest\Taskrouter\V1\Workspace\TaskList $tasks
  29. * @property \Twilio\Rest\Taskrouter\V1\Workspace\TaskQueueList $taskQueues
  30. * @property \Twilio\Rest\Taskrouter\V1\Workspace\WorkerList $workers
  31. * @property \Twilio\Rest\Taskrouter\V1\Workspace\WorkflowList $workflows
  32. * @property \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceStatisticsList $statistics
  33. * @property \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceRealTimeStatisticsList $realTimeStatistics
  34. * @property \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceCumulativeStatisticsList $cumulativeStatistics
  35. * @property \Twilio\Rest\Taskrouter\V1\Workspace\TaskChannelList $taskChannels
  36. * @method \Twilio\Rest\Taskrouter\V1\Workspace\ActivityContext activities(string $sid)
  37. * @method \Twilio\Rest\Taskrouter\V1\Workspace\EventContext events(string $sid)
  38. * @method \Twilio\Rest\Taskrouter\V1\Workspace\TaskContext tasks(string $sid)
  39. * @method \Twilio\Rest\Taskrouter\V1\Workspace\TaskQueueContext taskQueues(string $sid)
  40. * @method \Twilio\Rest\Taskrouter\V1\Workspace\WorkerContext workers(string $sid)
  41. * @method \Twilio\Rest\Taskrouter\V1\Workspace\WorkflowContext workflows(string $sid)
  42. * @method \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceStatisticsContext statistics()
  43. * @method \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceRealTimeStatisticsContext realTimeStatistics()
  44. * @method \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceCumulativeStatisticsContext cumulativeStatistics()
  45. * @method \Twilio\Rest\Taskrouter\V1\Workspace\TaskChannelContext taskChannels(string $sid)
  46. */
  47. class WorkspaceContext extends InstanceContext {
  48. protected $_activities = null;
  49. protected $_events = null;
  50. protected $_tasks = null;
  51. protected $_taskQueues = null;
  52. protected $_workers = null;
  53. protected $_workflows = null;
  54. protected $_statistics = null;
  55. protected $_realTimeStatistics = null;
  56. protected $_cumulativeStatistics = null;
  57. protected $_taskChannels = null;
  58. /**
  59. * Initialize the WorkspaceContext
  60. *
  61. * @param \Twilio\Version $version Version that contains the resource
  62. * @param string $sid The SID of the resource to fetch
  63. * @return \Twilio\Rest\Taskrouter\V1\WorkspaceContext
  64. */
  65. public function __construct(Version $version, $sid) {
  66. parent::__construct($version);
  67. // Path Solution
  68. $this->solution = array('sid' => $sid, );
  69. $this->uri = '/Workspaces/' . \rawurlencode($sid) . '';
  70. }
  71. /**
  72. * Fetch a WorkspaceInstance
  73. *
  74. * @return WorkspaceInstance Fetched WorkspaceInstance
  75. * @throws TwilioException When an HTTP error occurs.
  76. */
  77. public function fetch() {
  78. $params = Values::of(array());
  79. $payload = $this->version->fetch(
  80. 'GET',
  81. $this->uri,
  82. $params
  83. );
  84. return new WorkspaceInstance($this->version, $payload, $this->solution['sid']);
  85. }
  86. /**
  87. * Update the WorkspaceInstance
  88. *
  89. * @param array|Options $options Optional Arguments
  90. * @return WorkspaceInstance Updated WorkspaceInstance
  91. * @throws TwilioException When an HTTP error occurs.
  92. */
  93. public function update($options = array()) {
  94. $options = new Values($options);
  95. $data = Values::of(array(
  96. 'DefaultActivitySid' => $options['defaultActivitySid'],
  97. 'EventCallbackUrl' => $options['eventCallbackUrl'],
  98. 'EventsFilter' => $options['eventsFilter'],
  99. 'FriendlyName' => $options['friendlyName'],
  100. 'MultiTaskEnabled' => Serialize::booleanToString($options['multiTaskEnabled']),
  101. 'TimeoutActivitySid' => $options['timeoutActivitySid'],
  102. 'PrioritizeQueueOrder' => $options['prioritizeQueueOrder'],
  103. ));
  104. $payload = $this->version->update(
  105. 'POST',
  106. $this->uri,
  107. array(),
  108. $data
  109. );
  110. return new WorkspaceInstance($this->version, $payload, $this->solution['sid']);
  111. }
  112. /**
  113. * Deletes the WorkspaceInstance
  114. *
  115. * @return boolean True if delete succeeds, false otherwise
  116. * @throws TwilioException When an HTTP error occurs.
  117. */
  118. public function delete() {
  119. return $this->version->delete('delete', $this->uri);
  120. }
  121. /**
  122. * Access the activities
  123. *
  124. * @return \Twilio\Rest\Taskrouter\V1\Workspace\ActivityList
  125. */
  126. protected function getActivities() {
  127. if (!$this->_activities) {
  128. $this->_activities = new ActivityList($this->version, $this->solution['sid']);
  129. }
  130. return $this->_activities;
  131. }
  132. /**
  133. * Access the events
  134. *
  135. * @return \Twilio\Rest\Taskrouter\V1\Workspace\EventList
  136. */
  137. protected function getEvents() {
  138. if (!$this->_events) {
  139. $this->_events = new EventList($this->version, $this->solution['sid']);
  140. }
  141. return $this->_events;
  142. }
  143. /**
  144. * Access the tasks
  145. *
  146. * @return \Twilio\Rest\Taskrouter\V1\Workspace\TaskList
  147. */
  148. protected function getTasks() {
  149. if (!$this->_tasks) {
  150. $this->_tasks = new TaskList($this->version, $this->solution['sid']);
  151. }
  152. return $this->_tasks;
  153. }
  154. /**
  155. * Access the taskQueues
  156. *
  157. * @return \Twilio\Rest\Taskrouter\V1\Workspace\TaskQueueList
  158. */
  159. protected function getTaskQueues() {
  160. if (!$this->_taskQueues) {
  161. $this->_taskQueues = new TaskQueueList($this->version, $this->solution['sid']);
  162. }
  163. return $this->_taskQueues;
  164. }
  165. /**
  166. * Access the workers
  167. *
  168. * @return \Twilio\Rest\Taskrouter\V1\Workspace\WorkerList
  169. */
  170. protected function getWorkers() {
  171. if (!$this->_workers) {
  172. $this->_workers = new WorkerList($this->version, $this->solution['sid']);
  173. }
  174. return $this->_workers;
  175. }
  176. /**
  177. * Access the workflows
  178. *
  179. * @return \Twilio\Rest\Taskrouter\V1\Workspace\WorkflowList
  180. */
  181. protected function getWorkflows() {
  182. if (!$this->_workflows) {
  183. $this->_workflows = new WorkflowList($this->version, $this->solution['sid']);
  184. }
  185. return $this->_workflows;
  186. }
  187. /**
  188. * Access the statistics
  189. *
  190. * @return \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceStatisticsList
  191. */
  192. protected function getStatistics() {
  193. if (!$this->_statistics) {
  194. $this->_statistics = new WorkspaceStatisticsList($this->version, $this->solution['sid']);
  195. }
  196. return $this->_statistics;
  197. }
  198. /**
  199. * Access the realTimeStatistics
  200. *
  201. * @return \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceRealTimeStatisticsList
  202. */
  203. protected function getRealTimeStatistics() {
  204. if (!$this->_realTimeStatistics) {
  205. $this->_realTimeStatistics = new WorkspaceRealTimeStatisticsList(
  206. $this->version,
  207. $this->solution['sid']
  208. );
  209. }
  210. return $this->_realTimeStatistics;
  211. }
  212. /**
  213. * Access the cumulativeStatistics
  214. *
  215. * @return \Twilio\Rest\Taskrouter\V1\Workspace\WorkspaceCumulativeStatisticsList
  216. */
  217. protected function getCumulativeStatistics() {
  218. if (!$this->_cumulativeStatistics) {
  219. $this->_cumulativeStatistics = new WorkspaceCumulativeStatisticsList(
  220. $this->version,
  221. $this->solution['sid']
  222. );
  223. }
  224. return $this->_cumulativeStatistics;
  225. }
  226. /**
  227. * Access the taskChannels
  228. *
  229. * @return \Twilio\Rest\Taskrouter\V1\Workspace\TaskChannelList
  230. */
  231. protected function getTaskChannels() {
  232. if (!$this->_taskChannels) {
  233. $this->_taskChannels = new TaskChannelList($this->version, $this->solution['sid']);
  234. }
  235. return $this->_taskChannels;
  236. }
  237. /**
  238. * Magic getter to lazy load subresources
  239. *
  240. * @param string $name Subresource to return
  241. * @return \Twilio\ListResource The requested subresource
  242. * @throws TwilioException For unknown subresources
  243. */
  244. public function __get($name) {
  245. if (\property_exists($this, '_' . $name)) {
  246. $method = 'get' . \ucfirst($name);
  247. return $this->$method();
  248. }
  249. throw new TwilioException('Unknown subresource ' . $name);
  250. }
  251. /**
  252. * Magic caller to get resource contexts
  253. *
  254. * @param string $name Resource to return
  255. * @param array $arguments Context parameters
  256. * @return \Twilio\InstanceContext The requested resource context
  257. * @throws TwilioException For unknown resource
  258. */
  259. public function __call($name, $arguments) {
  260. $property = $this->$name;
  261. if (\method_exists($property, 'getContext')) {
  262. return \call_user_func_array(array($property, 'getContext'), $arguments);
  263. }
  264. throw new TwilioException('Resource does not have a context');
  265. }
  266. /**
  267. * Provide a friendly representation
  268. *
  269. * @return string Machine friendly representation
  270. */
  271. public function __toString() {
  272. $context = array();
  273. foreach ($this->solution as $key => $value) {
  274. $context[] = "$key=$value";
  275. }
  276. return '[Twilio.Taskrouter.V1.WorkspaceContext ' . \implode(' ', $context) . ']';
  277. }
  278. }