PageRenderTime 36ms CodeModel.GetById 7ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/twilio/sdk/src/Twilio/Rest/Verify/V2/Service/RateLimitInstance.php

https://gitlab.com/D-apos-software/Alcesac
PHP | 150 lines | 66 code | 17 blank | 67 comment | 3 complexity | 6c2a64350979ff0b9882d0b174edad78 MD5 | raw file
  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Verify\V2\Service;
  9. use Twilio\Deserialize;
  10. use Twilio\Exceptions\TwilioException;
  11. use Twilio\InstanceResource;
  12. use Twilio\Options;
  13. use Twilio\Rest\Verify\V2\Service\RateLimit\BucketList;
  14. use Twilio\Values;
  15. use Twilio\Version;
  16. /**
  17. * @property string $sid
  18. * @property string $serviceSid
  19. * @property string $accountSid
  20. * @property string $uniqueName
  21. * @property string $description
  22. * @property \DateTime $dateCreated
  23. * @property \DateTime $dateUpdated
  24. * @property string $url
  25. * @property array $links
  26. */
  27. class RateLimitInstance extends InstanceResource {
  28. protected $_buckets;
  29. /**
  30. * Initialize the RateLimitInstance
  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 resource is
  35. * associated with
  36. * @param string $sid The unique string that identifies the resource
  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. 'serviceSid' => Values::array_get($payload, 'service_sid'),
  44. 'accountSid' => Values::array_get($payload, 'account_sid'),
  45. 'uniqueName' => Values::array_get($payload, 'unique_name'),
  46. 'description' => Values::array_get($payload, 'description'),
  47. 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
  48. 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
  49. 'url' => Values::array_get($payload, 'url'),
  50. 'links' => Values::array_get($payload, 'links'),
  51. ];
  52. $this->solution = ['serviceSid' => $serviceSid, 'sid' => $sid ?: $this->properties['sid'], ];
  53. }
  54. /**
  55. * Generate an instance context for the instance, the context is capable of
  56. * performing various actions. All instance actions are proxied to the context
  57. *
  58. * @return RateLimitContext Context for this RateLimitInstance
  59. */
  60. protected function proxy(): RateLimitContext {
  61. if (!$this->context) {
  62. $this->context = new RateLimitContext(
  63. $this->version,
  64. $this->solution['serviceSid'],
  65. $this->solution['sid']
  66. );
  67. }
  68. return $this->context;
  69. }
  70. /**
  71. * Update the RateLimitInstance
  72. *
  73. * @param array|Options $options Optional Arguments
  74. * @return RateLimitInstance Updated RateLimitInstance
  75. * @throws TwilioException When an HTTP error occurs.
  76. */
  77. public function update(array $options = []): RateLimitInstance {
  78. return $this->proxy()->update($options);
  79. }
  80. /**
  81. * Fetch the RateLimitInstance
  82. *
  83. * @return RateLimitInstance Fetched RateLimitInstance
  84. * @throws TwilioException When an HTTP error occurs.
  85. */
  86. public function fetch(): RateLimitInstance {
  87. return $this->proxy()->fetch();
  88. }
  89. /**
  90. * Delete the RateLimitInstance
  91. *
  92. * @return bool True if delete succeeds, false otherwise
  93. * @throws TwilioException When an HTTP error occurs.
  94. */
  95. public function delete(): bool {
  96. return $this->proxy()->delete();
  97. }
  98. /**
  99. * Access the buckets
  100. */
  101. protected function getBuckets(): BucketList {
  102. return $this->proxy()->buckets;
  103. }
  104. /**
  105. * Magic getter to access properties
  106. *
  107. * @param string $name Property to access
  108. * @return mixed The requested property
  109. * @throws TwilioException For unknown properties
  110. */
  111. public function __get(string $name) {
  112. if (\array_key_exists($name, $this->properties)) {
  113. return $this->properties[$name];
  114. }
  115. if (\property_exists($this, '_' . $name)) {
  116. $method = 'get' . \ucfirst($name);
  117. return $this->$method();
  118. }
  119. throw new TwilioException('Unknown property: ' . $name);
  120. }
  121. /**
  122. * Provide a friendly representation
  123. *
  124. * @return string Machine friendly representation
  125. */
  126. public function __toString(): string {
  127. $context = [];
  128. foreach ($this->solution as $key => $value) {
  129. $context[] = "$key=$value";
  130. }
  131. return '[Twilio.Verify.V2.RateLimitInstance ' . \implode(' ', $context) . ']';
  132. }
  133. }