/libraries/fabrik/vendor/twilio/sdk/src/Twilio/Rest/Preview/Marketplace/InstalledAddOnContext.php

https://github.com/trob/fabrik · PHP · 156 lines · 70 code · 22 blank · 64 comment · 3 complexity · d914a2c9c69df8d90f459eebfd57c131 MD5 · raw file

  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Preview\Marketplace;
  9. use Twilio\Exceptions\TwilioException;
  10. use Twilio\InstanceContext;
  11. use Twilio\Options;
  12. use Twilio\Rest\Preview\Marketplace\InstalledAddOn\InstalledAddOnExtensionList;
  13. use Twilio\Serialize;
  14. use Twilio\Values;
  15. use Twilio\Version;
  16. /**
  17. * 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.
  18. *
  19. * @property \Twilio\Rest\Preview\Marketplace\InstalledAddOn\InstalledAddOnExtensionList $extensions
  20. * @method \Twilio\Rest\Preview\Marketplace\InstalledAddOn\InstalledAddOnExtensionContext extensions(string $sid)
  21. */
  22. class InstalledAddOnContext extends InstanceContext {
  23. protected $_extensions = null;
  24. /**
  25. * Initialize the InstalledAddOnContext
  26. *
  27. * @param \Twilio\Version $version Version that contains the resource
  28. * @param string $sid The SID of the InstalledAddOn resource to fetch
  29. * @return \Twilio\Rest\Preview\Marketplace\InstalledAddOnContext
  30. */
  31. public function __construct(Version $version, $sid) {
  32. parent::__construct($version);
  33. // Path Solution
  34. $this->solution = array('sid' => $sid, );
  35. $this->uri = '/InstalledAddOns/' . \rawurlencode($sid) . '';
  36. }
  37. /**
  38. * Deletes the InstalledAddOnInstance
  39. *
  40. * @return boolean True if delete succeeds, false otherwise
  41. * @throws TwilioException When an HTTP error occurs.
  42. */
  43. public function delete() {
  44. return $this->version->delete('delete', $this->uri);
  45. }
  46. /**
  47. * Fetch a InstalledAddOnInstance
  48. *
  49. * @return InstalledAddOnInstance Fetched InstalledAddOnInstance
  50. * @throws TwilioException When an HTTP error occurs.
  51. */
  52. public function fetch() {
  53. $params = Values::of(array());
  54. $payload = $this->version->fetch(
  55. 'GET',
  56. $this->uri,
  57. $params
  58. );
  59. return new InstalledAddOnInstance($this->version, $payload, $this->solution['sid']);
  60. }
  61. /**
  62. * Update the InstalledAddOnInstance
  63. *
  64. * @param array|Options $options Optional Arguments
  65. * @return InstalledAddOnInstance Updated InstalledAddOnInstance
  66. * @throws TwilioException When an HTTP error occurs.
  67. */
  68. public function update($options = array()) {
  69. $options = new Values($options);
  70. $data = Values::of(array(
  71. 'Configuration' => Serialize::jsonObject($options['configuration']),
  72. 'UniqueName' => $options['uniqueName'],
  73. ));
  74. $payload = $this->version->update(
  75. 'POST',
  76. $this->uri,
  77. array(),
  78. $data
  79. );
  80. return new InstalledAddOnInstance($this->version, $payload, $this->solution['sid']);
  81. }
  82. /**
  83. * Access the extensions
  84. *
  85. * @return \Twilio\Rest\Preview\Marketplace\InstalledAddOn\InstalledAddOnExtensionList
  86. */
  87. protected function getExtensions() {
  88. if (!$this->_extensions) {
  89. $this->_extensions = new InstalledAddOnExtensionList($this->version, $this->solution['sid']);
  90. }
  91. return $this->_extensions;
  92. }
  93. /**
  94. * Magic getter to lazy load subresources
  95. *
  96. * @param string $name Subresource to return
  97. * @return \Twilio\ListResource The requested subresource
  98. * @throws TwilioException For unknown subresources
  99. */
  100. public function __get($name) {
  101. if (\property_exists($this, '_' . $name)) {
  102. $method = 'get' . \ucfirst($name);
  103. return $this->$method();
  104. }
  105. throw new TwilioException('Unknown subresource ' . $name);
  106. }
  107. /**
  108. * Magic caller to get resource contexts
  109. *
  110. * @param string $name Resource to return
  111. * @param array $arguments Context parameters
  112. * @return \Twilio\InstanceContext The requested resource context
  113. * @throws TwilioException For unknown resource
  114. */
  115. public function __call($name, $arguments) {
  116. $property = $this->$name;
  117. if (\method_exists($property, 'getContext')) {
  118. return \call_user_func_array(array($property, 'getContext'), $arguments);
  119. }
  120. throw new TwilioException('Resource does not have a context');
  121. }
  122. /**
  123. * Provide a friendly representation
  124. *
  125. * @return string Machine friendly representation
  126. */
  127. public function __toString() {
  128. $context = array();
  129. foreach ($this->solution as $key => $value) {
  130. $context[] = "$key=$value";
  131. }
  132. return '[Twilio.Preview.Marketplace.InstalledAddOnContext ' . \implode(' ', $context) . ']';
  133. }
  134. }