QueryContext.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Preview\Understand\Assistant;
  9. use Twilio\InstanceContext;
  10. use Twilio\Options;
  11. use Twilio\Values;
  12. use Twilio\Version;
  13. /**
  14. * 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.
  15. */
  16. class QueryContext extends InstanceContext {
  17. /**
  18. * Initialize the QueryContext
  19. *
  20. * @param \Twilio\Version $version Version that contains the resource
  21. * @param string $assistantSid The assistant_sid
  22. * @param string $sid The sid
  23. * @return \Twilio\Rest\Preview\Understand\Assistant\QueryContext
  24. */
  25. public function __construct(Version $version, $assistantSid, $sid) {
  26. parent::__construct($version);
  27. // Path Solution
  28. $this->solution = array('assistantSid' => $assistantSid, 'sid' => $sid, );
  29. $this->uri = '/Assistants/' . rawurlencode($assistantSid) . '/Queries/' . rawurlencode($sid) . '';
  30. }
  31. /**
  32. * Fetch a QueryInstance
  33. *
  34. * @return QueryInstance Fetched QueryInstance
  35. * @throws TwilioException When an HTTP error occurs.
  36. */
  37. public function fetch() {
  38. $params = Values::of(array());
  39. $payload = $this->version->fetch(
  40. 'GET',
  41. $this->uri,
  42. $params
  43. );
  44. return new QueryInstance(
  45. $this->version,
  46. $payload,
  47. $this->solution['assistantSid'],
  48. $this->solution['sid']
  49. );
  50. }
  51. /**
  52. * Update the QueryInstance
  53. *
  54. * @param array|Options $options Optional Arguments
  55. * @return QueryInstance Updated QueryInstance
  56. * @throws TwilioException When an HTTP error occurs.
  57. */
  58. public function update($options = array()) {
  59. $options = new Values($options);
  60. $data = Values::of(array('SampleSid' => $options['sampleSid'], 'Status' => $options['status'], ));
  61. $payload = $this->version->update(
  62. 'POST',
  63. $this->uri,
  64. array(),
  65. $data
  66. );
  67. return new QueryInstance(
  68. $this->version,
  69. $payload,
  70. $this->solution['assistantSid'],
  71. $this->solution['sid']
  72. );
  73. }
  74. /**
  75. * Deletes the QueryInstance
  76. *
  77. * @return boolean True if delete succeeds, false otherwise
  78. * @throws TwilioException When an HTTP error occurs.
  79. */
  80. public function delete() {
  81. return $this->version->delete('delete', $this->uri);
  82. }
  83. /**
  84. * Provide a friendly representation
  85. *
  86. * @return string Machine friendly representation
  87. */
  88. public function __toString() {
  89. $context = array();
  90. foreach ($this->solution as $key => $value) {
  91. $context[] = "$key=$value";
  92. }
  93. return '[Twilio.Preview.Understand.QueryContext ' . implode(' ', $context) . ']';
  94. }
  95. }