ModelBuildInstance.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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\Deserialize;
  10. use Twilio\Exceptions\TwilioException;
  11. use Twilio\InstanceResource;
  12. use Twilio\Options;
  13. use Twilio\Values;
  14. use Twilio\Version;
  15. /**
  16. * 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.
  17. *
  18. * @property string accountSid
  19. * @property \DateTime dateCreated
  20. * @property \DateTime dateUpdated
  21. * @property string assistantSid
  22. * @property string sid
  23. * @property string status
  24. * @property string uniqueName
  25. * @property string url
  26. * @property integer buildDuration
  27. * @property integer errorCode
  28. */
  29. class ModelBuildInstance extends InstanceResource {
  30. /**
  31. * Initialize the ModelBuildInstance
  32. *
  33. * @param \Twilio\Version $version Version that contains the resource
  34. * @param mixed[] $payload The response payload
  35. * @param string $assistantSid The unique ID of the parent Assistant.
  36. * @param string $sid The sid
  37. * @return \Twilio\Rest\Preview\Understand\Assistant\ModelBuildInstance
  38. */
  39. public function __construct(Version $version, array $payload, $assistantSid, $sid = null) {
  40. parent::__construct($version);
  41. // Marshaled Properties
  42. $this->properties = array(
  43. 'accountSid' => Values::array_get($payload, 'account_sid'),
  44. 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
  45. 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
  46. 'assistantSid' => Values::array_get($payload, 'assistant_sid'),
  47. 'sid' => Values::array_get($payload, 'sid'),
  48. 'status' => Values::array_get($payload, 'status'),
  49. 'uniqueName' => Values::array_get($payload, 'unique_name'),
  50. 'url' => Values::array_get($payload, 'url'),
  51. 'buildDuration' => Values::array_get($payload, 'build_duration'),
  52. 'errorCode' => Values::array_get($payload, 'error_code'),
  53. );
  54. $this->solution = array('assistantSid' => $assistantSid, 'sid' => $sid ?: $this->properties['sid'], );
  55. }
  56. /**
  57. * Generate an instance context for the instance, the context is capable of
  58. * performing various actions. All instance actions are proxied to the context
  59. *
  60. * @return \Twilio\Rest\Preview\Understand\Assistant\ModelBuildContext Context
  61. * for this
  62. * ModelBuildInstance
  63. */
  64. protected function proxy() {
  65. if (!$this->context) {
  66. $this->context = new ModelBuildContext(
  67. $this->version,
  68. $this->solution['assistantSid'],
  69. $this->solution['sid']
  70. );
  71. }
  72. return $this->context;
  73. }
  74. /**
  75. * Fetch a ModelBuildInstance
  76. *
  77. * @return ModelBuildInstance Fetched ModelBuildInstance
  78. * @throws TwilioException When an HTTP error occurs.
  79. */
  80. public function fetch() {
  81. return $this->proxy()->fetch();
  82. }
  83. /**
  84. * Update the ModelBuildInstance
  85. *
  86. * @param array|Options $options Optional Arguments
  87. * @return ModelBuildInstance Updated ModelBuildInstance
  88. * @throws TwilioException When an HTTP error occurs.
  89. */
  90. public function update($options = array()) {
  91. return $this->proxy()->update($options);
  92. }
  93. /**
  94. * Deletes the ModelBuildInstance
  95. *
  96. * @return boolean True if delete succeeds, false otherwise
  97. * @throws TwilioException When an HTTP error occurs.
  98. */
  99. public function delete() {
  100. return $this->proxy()->delete();
  101. }
  102. /**
  103. * Magic getter to access properties
  104. *
  105. * @param string $name Property to access
  106. * @return mixed The requested property
  107. * @throws TwilioException For unknown properties
  108. */
  109. public function __get($name) {
  110. if (array_key_exists($name, $this->properties)) {
  111. return $this->properties[$name];
  112. }
  113. if (property_exists($this, '_' . $name)) {
  114. $method = 'get' . ucfirst($name);
  115. return $this->$method();
  116. }
  117. throw new TwilioException('Unknown property: ' . $name);
  118. }
  119. /**
  120. * Provide a friendly representation
  121. *
  122. * @return string Machine friendly representation
  123. */
  124. public function __toString() {
  125. $context = array();
  126. foreach ($this->solution as $key => $value) {
  127. $context[] = "$key=$value";
  128. }
  129. return '[Twilio.Preview.Understand.ModelBuildInstance ' . implode(' ', $context) . ']';
  130. }
  131. }