/libraries/fabrik/vendor/twilio/sdk/src/Twilio/Rest/Preview/Understand/AssistantContext.php

https://github.com/jaanusnurmoja/fabrik · PHP · 288 lines · 138 code · 36 blank · 114 comment · 10 complexity · cd92341fd09a1854c950579b38c681b0 MD5 · raw file

  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Preview\Understand;
  9. use Twilio\Exceptions\TwilioException;
  10. use Twilio\InstanceContext;
  11. use Twilio\Options;
  12. use Twilio\Rest\Preview\Understand\Assistant\AssistantFallbackActionsList;
  13. use Twilio\Rest\Preview\Understand\Assistant\AssistantInitiationActionsList;
  14. use Twilio\Rest\Preview\Understand\Assistant\DialogueList;
  15. use Twilio\Rest\Preview\Understand\Assistant\FieldTypeList;
  16. use Twilio\Rest\Preview\Understand\Assistant\ModelBuildList;
  17. use Twilio\Rest\Preview\Understand\Assistant\QueryList;
  18. use Twilio\Rest\Preview\Understand\Assistant\StyleSheetList;
  19. use Twilio\Rest\Preview\Understand\Assistant\TaskList;
  20. use Twilio\Serialize;
  21. use Twilio\Values;
  22. use Twilio\Version;
  23. /**
  24. * PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
  25. *
  26. * @property \Twilio\Rest\Preview\Understand\Assistant\FieldTypeList $fieldTypes
  27. * @property \Twilio\Rest\Preview\Understand\Assistant\TaskList $tasks
  28. * @property \Twilio\Rest\Preview\Understand\Assistant\ModelBuildList $modelBuilds
  29. * @property \Twilio\Rest\Preview\Understand\Assistant\QueryList $queries
  30. * @property \Twilio\Rest\Preview\Understand\Assistant\AssistantFallbackActionsList $assistantFallbackActions
  31. * @property \Twilio\Rest\Preview\Understand\Assistant\AssistantInitiationActionsList $assistantInitiationActions
  32. * @property \Twilio\Rest\Preview\Understand\Assistant\DialogueList $dialogues
  33. * @property \Twilio\Rest\Preview\Understand\Assistant\StyleSheetList $styleSheet
  34. * @method \Twilio\Rest\Preview\Understand\Assistant\FieldTypeContext fieldTypes(string $sid)
  35. * @method \Twilio\Rest\Preview\Understand\Assistant\TaskContext tasks(string $sid)
  36. * @method \Twilio\Rest\Preview\Understand\Assistant\ModelBuildContext modelBuilds(string $sid)
  37. * @method \Twilio\Rest\Preview\Understand\Assistant\QueryContext queries(string $sid)
  38. * @method \Twilio\Rest\Preview\Understand\Assistant\AssistantFallbackActionsContext assistantFallbackActions()
  39. * @method \Twilio\Rest\Preview\Understand\Assistant\AssistantInitiationActionsContext assistantInitiationActions()
  40. * @method \Twilio\Rest\Preview\Understand\Assistant\DialogueContext dialogues(string $sid)
  41. * @method \Twilio\Rest\Preview\Understand\Assistant\StyleSheetContext styleSheet()
  42. */
  43. class AssistantContext extends InstanceContext {
  44. protected $_fieldTypes = null;
  45. protected $_tasks = null;
  46. protected $_modelBuilds = null;
  47. protected $_queries = null;
  48. protected $_assistantFallbackActions = null;
  49. protected $_assistantInitiationActions = null;
  50. protected $_dialogues = null;
  51. protected $_styleSheet = null;
  52. /**
  53. * Initialize the AssistantContext
  54. *
  55. * @param \Twilio\Version $version Version that contains the resource
  56. * @param string $sid A 34 character string that uniquely identifies this
  57. * resource.
  58. * @return \Twilio\Rest\Preview\Understand\AssistantContext
  59. */
  60. public function __construct(Version $version, $sid) {
  61. parent::__construct($version);
  62. // Path Solution
  63. $this->solution = array('sid' => $sid, );
  64. $this->uri = '/Assistants/' . \rawurlencode($sid) . '';
  65. }
  66. /**
  67. * Fetch a AssistantInstance
  68. *
  69. * @return AssistantInstance Fetched AssistantInstance
  70. * @throws TwilioException When an HTTP error occurs.
  71. */
  72. public function fetch() {
  73. $params = Values::of(array());
  74. $payload = $this->version->fetch(
  75. 'GET',
  76. $this->uri,
  77. $params
  78. );
  79. return new AssistantInstance($this->version, $payload, $this->solution['sid']);
  80. }
  81. /**
  82. * Update the AssistantInstance
  83. *
  84. * @param array|Options $options Optional Arguments
  85. * @return AssistantInstance Updated AssistantInstance
  86. * @throws TwilioException When an HTTP error occurs.
  87. */
  88. public function update($options = array()) {
  89. $options = new Values($options);
  90. $data = Values::of(array(
  91. 'FriendlyName' => $options['friendlyName'],
  92. 'LogQueries' => Serialize::booleanToString($options['logQueries']),
  93. 'UniqueName' => $options['uniqueName'],
  94. 'CallbackUrl' => $options['callbackUrl'],
  95. 'CallbackEvents' => $options['callbackEvents'],
  96. 'FallbackActions' => Serialize::jsonObject($options['fallbackActions']),
  97. 'InitiationActions' => Serialize::jsonObject($options['initiationActions']),
  98. 'StyleSheet' => Serialize::jsonObject($options['styleSheet']),
  99. ));
  100. $payload = $this->version->update(
  101. 'POST',
  102. $this->uri,
  103. array(),
  104. $data
  105. );
  106. return new AssistantInstance($this->version, $payload, $this->solution['sid']);
  107. }
  108. /**
  109. * Deletes the AssistantInstance
  110. *
  111. * @return boolean True if delete succeeds, false otherwise
  112. * @throws TwilioException When an HTTP error occurs.
  113. */
  114. public function delete() {
  115. return $this->version->delete('delete', $this->uri);
  116. }
  117. /**
  118. * Access the fieldTypes
  119. *
  120. * @return \Twilio\Rest\Preview\Understand\Assistant\FieldTypeList
  121. */
  122. protected function getFieldTypes() {
  123. if (!$this->_fieldTypes) {
  124. $this->_fieldTypes = new FieldTypeList($this->version, $this->solution['sid']);
  125. }
  126. return $this->_fieldTypes;
  127. }
  128. /**
  129. * Access the tasks
  130. *
  131. * @return \Twilio\Rest\Preview\Understand\Assistant\TaskList
  132. */
  133. protected function getTasks() {
  134. if (!$this->_tasks) {
  135. $this->_tasks = new TaskList($this->version, $this->solution['sid']);
  136. }
  137. return $this->_tasks;
  138. }
  139. /**
  140. * Access the modelBuilds
  141. *
  142. * @return \Twilio\Rest\Preview\Understand\Assistant\ModelBuildList
  143. */
  144. protected function getModelBuilds() {
  145. if (!$this->_modelBuilds) {
  146. $this->_modelBuilds = new ModelBuildList($this->version, $this->solution['sid']);
  147. }
  148. return $this->_modelBuilds;
  149. }
  150. /**
  151. * Access the queries
  152. *
  153. * @return \Twilio\Rest\Preview\Understand\Assistant\QueryList
  154. */
  155. protected function getQueries() {
  156. if (!$this->_queries) {
  157. $this->_queries = new QueryList($this->version, $this->solution['sid']);
  158. }
  159. return $this->_queries;
  160. }
  161. /**
  162. * Access the assistantFallbackActions
  163. *
  164. * @return \Twilio\Rest\Preview\Understand\Assistant\AssistantFallbackActionsList
  165. */
  166. protected function getAssistantFallbackActions() {
  167. if (!$this->_assistantFallbackActions) {
  168. $this->_assistantFallbackActions = new AssistantFallbackActionsList(
  169. $this->version,
  170. $this->solution['sid']
  171. );
  172. }
  173. return $this->_assistantFallbackActions;
  174. }
  175. /**
  176. * Access the assistantInitiationActions
  177. *
  178. * @return \Twilio\Rest\Preview\Understand\Assistant\AssistantInitiationActionsList
  179. */
  180. protected function getAssistantInitiationActions() {
  181. if (!$this->_assistantInitiationActions) {
  182. $this->_assistantInitiationActions = new AssistantInitiationActionsList(
  183. $this->version,
  184. $this->solution['sid']
  185. );
  186. }
  187. return $this->_assistantInitiationActions;
  188. }
  189. /**
  190. * Access the dialogues
  191. *
  192. * @return \Twilio\Rest\Preview\Understand\Assistant\DialogueList
  193. */
  194. protected function getDialogues() {
  195. if (!$this->_dialogues) {
  196. $this->_dialogues = new DialogueList($this->version, $this->solution['sid']);
  197. }
  198. return $this->_dialogues;
  199. }
  200. /**
  201. * Access the styleSheet
  202. *
  203. * @return \Twilio\Rest\Preview\Understand\Assistant\StyleSheetList
  204. */
  205. protected function getStyleSheet() {
  206. if (!$this->_styleSheet) {
  207. $this->_styleSheet = new StyleSheetList($this->version, $this->solution['sid']);
  208. }
  209. return $this->_styleSheet;
  210. }
  211. /**
  212. * Magic getter to lazy load subresources
  213. *
  214. * @param string $name Subresource to return
  215. * @return \Twilio\ListResource The requested subresource
  216. * @throws TwilioException For unknown subresources
  217. */
  218. public function __get($name) {
  219. if (\property_exists($this, '_' . $name)) {
  220. $method = 'get' . \ucfirst($name);
  221. return $this->$method();
  222. }
  223. throw new TwilioException('Unknown subresource ' . $name);
  224. }
  225. /**
  226. * Magic caller to get resource contexts
  227. *
  228. * @param string $name Resource to return
  229. * @param array $arguments Context parameters
  230. * @return \Twilio\InstanceContext The requested resource context
  231. * @throws TwilioException For unknown resource
  232. */
  233. public function __call($name, $arguments) {
  234. $property = $this->$name;
  235. if (\method_exists($property, 'getContext')) {
  236. return \call_user_func_array(array($property, 'getContext'), $arguments);
  237. }
  238. throw new TwilioException('Resource does not have a context');
  239. }
  240. /**
  241. * Provide a friendly representation
  242. *
  243. * @return string Machine friendly representation
  244. */
  245. public function __toString() {
  246. $context = array();
  247. foreach ($this->solution as $key => $value) {
  248. $context[] = "$key=$value";
  249. }
  250. return '[Twilio.Preview.Understand.AssistantContext ' . \implode(' ', $context) . ']';
  251. }
  252. }