PageRenderTime 53ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Twilio/Rest/Proxy/V1/Service/PhoneNumberInstance.php

http://github.com/twilio/twilio-php
PHP | 148 lines | 64 code | 15 blank | 69 comment | 3 complexity | fd122d49aa7fbd364f44792b1e97c5fc MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Proxy\V1\Service;
  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 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 \DateTime $dateCreated
  22. * @property \DateTime $dateUpdated
  23. * @property string $phoneNumber
  24. * @property string $friendlyName
  25. * @property string $isoCountry
  26. * @property string $capabilities
  27. * @property string $url
  28. * @property bool $isReserved
  29. * @property int $inUse
  30. */
  31. class PhoneNumberInstance extends InstanceResource {
  32. /**
  33. * Initialize the PhoneNumberInstance
  34. *
  35. * @param Version $version Version that contains the resource
  36. * @param mixed[] $payload The response payload
  37. * @param string $serviceSid The SID of the PhoneNumber resource's parent
  38. * Service resource
  39. * @param string $sid The unique string that identifies the resource
  40. */
  41. public function __construct(Version $version, array $payload, string $serviceSid, string $sid = null) {
  42. parent::__construct($version);
  43. // Marshaled Properties
  44. $this->properties = [
  45. 'sid' => Values::array_get($payload, 'sid'),
  46. 'accountSid' => Values::array_get($payload, 'account_sid'),
  47. 'serviceSid' => Values::array_get($payload, 'service_sid'),
  48. 'dateCreated' => Deserialize::dateTime(Values::array_get($payload, 'date_created')),
  49. 'dateUpdated' => Deserialize::dateTime(Values::array_get($payload, 'date_updated')),
  50. 'phoneNumber' => Values::array_get($payload, 'phone_number'),
  51. 'friendlyName' => Values::array_get($payload, 'friendly_name'),
  52. 'isoCountry' => Values::array_get($payload, 'iso_country'),
  53. 'capabilities' => Values::array_get($payload, 'capabilities'),
  54. 'url' => Values::array_get($payload, 'url'),
  55. 'isReserved' => Values::array_get($payload, 'is_reserved'),
  56. 'inUse' => Values::array_get($payload, 'in_use'),
  57. ];
  58. $this->solution = ['serviceSid' => $serviceSid, 'sid' => $sid ?: $this->properties['sid'], ];
  59. }
  60. /**
  61. * Generate an instance context for the instance, the context is capable of
  62. * performing various actions. All instance actions are proxied to the context
  63. *
  64. * @return PhoneNumberContext Context for this PhoneNumberInstance
  65. */
  66. protected function proxy(): PhoneNumberContext {
  67. if (!$this->context) {
  68. $this->context = new PhoneNumberContext(
  69. $this->version,
  70. $this->solution['serviceSid'],
  71. $this->solution['sid']
  72. );
  73. }
  74. return $this->context;
  75. }
  76. /**
  77. * Delete the PhoneNumberInstance
  78. *
  79. * @return bool True if delete succeeds, false otherwise
  80. * @throws TwilioException When an HTTP error occurs.
  81. */
  82. public function delete(): bool {
  83. return $this->proxy()->delete();
  84. }
  85. /**
  86. * Fetch the PhoneNumberInstance
  87. *
  88. * @return PhoneNumberInstance Fetched PhoneNumberInstance
  89. * @throws TwilioException When an HTTP error occurs.
  90. */
  91. public function fetch(): PhoneNumberInstance {
  92. return $this->proxy()->fetch();
  93. }
  94. /**
  95. * Update the PhoneNumberInstance
  96. *
  97. * @param array|Options $options Optional Arguments
  98. * @return PhoneNumberInstance Updated PhoneNumberInstance
  99. * @throws TwilioException When an HTTP error occurs.
  100. */
  101. public function update(array $options = []): PhoneNumberInstance {
  102. return $this->proxy()->update($options);
  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.Proxy.V1.PhoneNumberInstance ' . \implode(' ', $context) . ']';
  132. }
  133. }