/vendor/twilio/sdk/src/Twilio/Rest/Serverless/V1/Service/AssetInstance.php

https://gitlab.com/D-apos-software/Alcesac · PHP · 149 lines · 64 code · 17 blank · 68 comment · 3 complexity · 5f4a5f7b6288ed6af6d99f3f1450d596 MD5 · raw file

  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Serverless\V1\Service;
  9. use Twilio\Deserialize;
  10. use Twilio\Exceptions\TwilioException;
  11. use Twilio\InstanceResource;
  12. use Twilio\Rest\Serverless\V1\Service\Asset\AssetVersionList;
  13. use Twilio\Values;
  14. use Twilio\Version;
  15. /**
  16. * PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
  17. *
  18. * @property string $sid
  19. * @property string $accountSid
  20. * @property string $serviceSid
  21. * @property string $friendlyName
  22. * @property \DateTime $dateCreated
  23. * @property \DateTime $dateUpdated
  24. * @property string $url
  25. * @property array $links
  26. */
  27. class AssetInstance extends InstanceResource {
  28. protected $_assetVersions;
  29. /**
  30. * Initialize the AssetInstance
  31. *
  32. * @param Version $version Version that contains the resource
  33. * @param mixed[] $payload The response payload
  34. * @param string $serviceSid The SID of the Service that the Asset resource is
  35. * associated with
  36. * @param string $sid The SID that identifies the Asset resource to fetch
  37. */
  38. public function __construct(Version $version, array $payload, string $serviceSid, string $sid = null) {
  39. parent::__construct($version);
  40. // Marshaled Properties
  41. $this->properties = [
  42. 'sid' => Values::array_get($payload, 'sid'),
  43. 'accountSid' => Values::array_get($payload, 'account_sid'),
  44. 'serviceSid' => Values::array_get($payload, 'service_sid'),
  45. 'friendlyName' => Values::array_get($payload, 'friendly_name'),
  46. 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
  47. 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
  48. 'url' => Values::array_get($payload, 'url'),
  49. 'links' => Values::array_get($payload, 'links'),
  50. ];
  51. $this->solution = ['serviceSid' => $serviceSid, 'sid' => $sid ?: $this->properties['sid'], ];
  52. }
  53. /**
  54. * Generate an instance context for the instance, the context is capable of
  55. * performing various actions. All instance actions are proxied to the context
  56. *
  57. * @return AssetContext Context for this AssetInstance
  58. */
  59. protected function proxy(): AssetContext {
  60. if (!$this->context) {
  61. $this->context = new AssetContext(
  62. $this->version,
  63. $this->solution['serviceSid'],
  64. $this->solution['sid']
  65. );
  66. }
  67. return $this->context;
  68. }
  69. /**
  70. * Fetch the AssetInstance
  71. *
  72. * @return AssetInstance Fetched AssetInstance
  73. * @throws TwilioException When an HTTP error occurs.
  74. */
  75. public function fetch(): AssetInstance {
  76. return $this->proxy()->fetch();
  77. }
  78. /**
  79. * Delete the AssetInstance
  80. *
  81. * @return bool True if delete succeeds, false otherwise
  82. * @throws TwilioException When an HTTP error occurs.
  83. */
  84. public function delete(): bool {
  85. return $this->proxy()->delete();
  86. }
  87. /**
  88. * Update the AssetInstance
  89. *
  90. * @param string $friendlyName A string to describe the Asset resource
  91. * @return AssetInstance Updated AssetInstance
  92. * @throws TwilioException When an HTTP error occurs.
  93. */
  94. public function update(string $friendlyName): AssetInstance {
  95. return $this->proxy()->update($friendlyName);
  96. }
  97. /**
  98. * Access the assetVersions
  99. */
  100. protected function getAssetVersions(): AssetVersionList {
  101. return $this->proxy()->assetVersions;
  102. }
  103. /**
  104. * Magic getter to access properties
  105. *
  106. * @param string $name Property to access
  107. * @return mixed The requested property
  108. * @throws TwilioException For unknown properties
  109. */
  110. public function __get(string $name) {
  111. if (\array_key_exists($name, $this->properties)) {
  112. return $this->properties[$name];
  113. }
  114. if (\property_exists($this, '_' . $name)) {
  115. $method = 'get' . \ucfirst($name);
  116. return $this->$method();
  117. }
  118. throw new TwilioException('Unknown property: ' . $name);
  119. }
  120. /**
  121. * Provide a friendly representation
  122. *
  123. * @return string Machine friendly representation
  124. */
  125. public function __toString(): string {
  126. $context = [];
  127. foreach ($this->solution as $key => $value) {
  128. $context[] = "$key=$value";
  129. }
  130. return '[Twilio.Serverless.V1.AssetInstance ' . \implode(' ', $context) . ']';
  131. }
  132. }