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

https://github.com/trob/fabrik · PHP · 215 lines · 111 code · 26 blank · 78 comment · 5 complexity · 47de64e4d72ce67c3376ba19204a43f8 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\Exceptions\TwilioException;
  10. use Twilio\InstanceContext;
  11. use Twilio\Options;
  12. use Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowCumulativeStatisticsList;
  13. use Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowRealTimeStatisticsList;
  14. use Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowStatisticsList;
  15. use Twilio\Values;
  16. use Twilio\Version;
  17. /**
  18. * @property \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowStatisticsList $statistics
  19. * @property \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowRealTimeStatisticsList $realTimeStatistics
  20. * @property \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowCumulativeStatisticsList $cumulativeStatistics
  21. * @method \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowStatisticsContext statistics()
  22. * @method \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowRealTimeStatisticsContext realTimeStatistics()
  23. * @method \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowCumulativeStatisticsContext cumulativeStatistics()
  24. */
  25. class WorkflowContext extends InstanceContext {
  26. protected $_statistics = null;
  27. protected $_realTimeStatistics = null;
  28. protected $_cumulativeStatistics = null;
  29. /**
  30. * Initialize the WorkflowContext
  31. *
  32. * @param \Twilio\Version $version Version that contains the resource
  33. * @param string $workspaceSid The SID of the Workspace with the Workflow to
  34. * fetch
  35. * @param string $sid The SID of the resource
  36. * @return \Twilio\Rest\Taskrouter\V1\Workspace\WorkflowContext
  37. */
  38. public function __construct(Version $version, $workspaceSid, $sid) {
  39. parent::__construct($version);
  40. // Path Solution
  41. $this->solution = array('workspaceSid' => $workspaceSid, 'sid' => $sid, );
  42. $this->uri = '/Workspaces/' . \rawurlencode($workspaceSid) . '/Workflows/' . \rawurlencode($sid) . '';
  43. }
  44. /**
  45. * Fetch a WorkflowInstance
  46. *
  47. * @return WorkflowInstance Fetched WorkflowInstance
  48. * @throws TwilioException When an HTTP error occurs.
  49. */
  50. public function fetch() {
  51. $params = Values::of(array());
  52. $payload = $this->version->fetch(
  53. 'GET',
  54. $this->uri,
  55. $params
  56. );
  57. return new WorkflowInstance(
  58. $this->version,
  59. $payload,
  60. $this->solution['workspaceSid'],
  61. $this->solution['sid']
  62. );
  63. }
  64. /**
  65. * Update the WorkflowInstance
  66. *
  67. * @param array|Options $options Optional Arguments
  68. * @return WorkflowInstance Updated WorkflowInstance
  69. * @throws TwilioException When an HTTP error occurs.
  70. */
  71. public function update($options = array()) {
  72. $options = new Values($options);
  73. $data = Values::of(array(
  74. 'FriendlyName' => $options['friendlyName'],
  75. 'AssignmentCallbackUrl' => $options['assignmentCallbackUrl'],
  76. 'FallbackAssignmentCallbackUrl' => $options['fallbackAssignmentCallbackUrl'],
  77. 'Configuration' => $options['configuration'],
  78. 'TaskReservationTimeout' => $options['taskReservationTimeout'],
  79. 'ReEvaluateTasks' => $options['reEvaluateTasks'],
  80. ));
  81. $payload = $this->version->update(
  82. 'POST',
  83. $this->uri,
  84. array(),
  85. $data
  86. );
  87. return new WorkflowInstance(
  88. $this->version,
  89. $payload,
  90. $this->solution['workspaceSid'],
  91. $this->solution['sid']
  92. );
  93. }
  94. /**
  95. * Deletes the WorkflowInstance
  96. *
  97. * @return boolean True if delete succeeds, false otherwise
  98. * @throws TwilioException When an HTTP error occurs.
  99. */
  100. public function delete() {
  101. return $this->version->delete('delete', $this->uri);
  102. }
  103. /**
  104. * Access the statistics
  105. *
  106. * @return \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowStatisticsList
  107. */
  108. protected function getStatistics() {
  109. if (!$this->_statistics) {
  110. $this->_statistics = new WorkflowStatisticsList(
  111. $this->version,
  112. $this->solution['workspaceSid'],
  113. $this->solution['sid']
  114. );
  115. }
  116. return $this->_statistics;
  117. }
  118. /**
  119. * Access the realTimeStatistics
  120. *
  121. * @return \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowRealTimeStatisticsList
  122. */
  123. protected function getRealTimeStatistics() {
  124. if (!$this->_realTimeStatistics) {
  125. $this->_realTimeStatistics = new WorkflowRealTimeStatisticsList(
  126. $this->version,
  127. $this->solution['workspaceSid'],
  128. $this->solution['sid']
  129. );
  130. }
  131. return $this->_realTimeStatistics;
  132. }
  133. /**
  134. * Access the cumulativeStatistics
  135. *
  136. * @return \Twilio\Rest\Taskrouter\V1\Workspace\Workflow\WorkflowCumulativeStatisticsList
  137. */
  138. protected function getCumulativeStatistics() {
  139. if (!$this->_cumulativeStatistics) {
  140. $this->_cumulativeStatistics = new WorkflowCumulativeStatisticsList(
  141. $this->version,
  142. $this->solution['workspaceSid'],
  143. $this->solution['sid']
  144. );
  145. }
  146. return $this->_cumulativeStatistics;
  147. }
  148. /**
  149. * Magic getter to lazy load subresources
  150. *
  151. * @param string $name Subresource to return
  152. * @return \Twilio\ListResource The requested subresource
  153. * @throws TwilioException For unknown subresources
  154. */
  155. public function __get($name) {
  156. if (\property_exists($this, '_' . $name)) {
  157. $method = 'get' . \ucfirst($name);
  158. return $this->$method();
  159. }
  160. throw new TwilioException('Unknown subresource ' . $name);
  161. }
  162. /**
  163. * Magic caller to get resource contexts
  164. *
  165. * @param string $name Resource to return
  166. * @param array $arguments Context parameters
  167. * @return \Twilio\InstanceContext The requested resource context
  168. * @throws TwilioException For unknown resource
  169. */
  170. public function __call($name, $arguments) {
  171. $property = $this->$name;
  172. if (\method_exists($property, 'getContext')) {
  173. return \call_user_func_array(array($property, 'getContext'), $arguments);
  174. }
  175. throw new TwilioException('Resource does not have a context');
  176. }
  177. /**
  178. * Provide a friendly representation
  179. *
  180. * @return string Machine friendly representation
  181. */
  182. public function __toString() {
  183. $context = array();
  184. foreach ($this->solution as $key => $value) {
  185. $context[] = "$key=$value";
  186. }
  187. return '[Twilio.Taskrouter.V1.WorkflowContext ' . \implode(' ', $context) . ']';
  188. }
  189. }