/libraries/fabrik/vendor/twilio/sdk/src/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountry/SharedCostList.php

https://github.com/trob/fabrik · PHP · 152 lines · 64 code · 16 blank · 72 comment · 0 complexity · bdd51d6f3f7a90b2a71f68af97140ba5 MD5 · raw file

  1. <?php
  2. /**
  3. * This code was generated by
  4. * \ / _ _ _| _ _
  5. * | (_)\/(_)(_|\/| |(/_ v1.0.0
  6. * / /
  7. */
  8. namespace Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry;
  9. use Twilio\ListResource;
  10. use Twilio\Options;
  11. use Twilio\Serialize;
  12. use Twilio\Values;
  13. use Twilio\Version;
  14. class SharedCostList extends ListResource {
  15. /**
  16. * Construct the SharedCostList
  17. *
  18. * @param Version $version Version that contains the resource
  19. * @param string $accountSid The account_sid
  20. * @param string $countryCode The ISO-3166-1 country code of the country.
  21. * @return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\SharedCostList
  22. */
  23. public function __construct(Version $version, $accountSid, $countryCode) {
  24. parent::__construct($version);
  25. // Path Solution
  26. $this->solution = array('accountSid' => $accountSid, 'countryCode' => $countryCode, );
  27. $this->uri = '/Accounts/' . \rawurlencode($accountSid) . '/AvailablePhoneNumbers/' . \rawurlencode($countryCode) . '/SharedCost.json';
  28. }
  29. /**
  30. * Streams SharedCostInstance records from the API as a generator stream.
  31. * This operation lazily loads records as efficiently as possible until the
  32. * limit
  33. * is reached.
  34. * The results are returned as a generator, so this operation is memory
  35. * efficient.
  36. *
  37. * @param array|Options $options Optional Arguments
  38. * @param int $limit Upper limit for the number of records to return. stream()
  39. * guarantees to never return more than limit. Default is no
  40. * limit
  41. * @param mixed $pageSize Number of records to fetch per request, when not set
  42. * will use the default value of 50 records. If no
  43. * page_size is defined but a limit is defined, stream()
  44. * will attempt to read the limit with the most
  45. * efficient page size, i.e. min(limit, 1000)
  46. * @return \Twilio\Stream stream of results
  47. */
  48. public function stream($options = array(), $limit = null, $pageSize = null) {
  49. $limits = $this->version->readLimits($limit, $pageSize);
  50. $page = $this->page($options, $limits['pageSize']);
  51. return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
  52. }
  53. /**
  54. * Reads SharedCostInstance records from the API as a list.
  55. * Unlike stream(), this operation is eager and will load `limit` records into
  56. * memory before returning.
  57. *
  58. * @param array|Options $options Optional Arguments
  59. * @param int $limit Upper limit for the number of records to return. read()
  60. * guarantees to never return more than limit. Default is no
  61. * limit
  62. * @param mixed $pageSize Number of records to fetch per request, when not set
  63. * will use the default value of 50 records. If no
  64. * page_size is defined but a limit is defined, read()
  65. * will attempt to read the limit with the most
  66. * efficient page size, i.e. min(limit, 1000)
  67. * @return SharedCostInstance[] Array of results
  68. */
  69. public function read($options = array(), $limit = null, $pageSize = null) {
  70. return \iterator_to_array($this->stream($options, $limit, $pageSize), false);
  71. }
  72. /**
  73. * Retrieve a single page of SharedCostInstance records from the API.
  74. * Request is executed immediately
  75. *
  76. * @param array|Options $options Optional Arguments
  77. * @param mixed $pageSize Number of records to return, defaults to 50
  78. * @param string $pageToken PageToken provided by the API
  79. * @param mixed $pageNumber Page Number, this value is simply for client state
  80. * @return \Twilio\Page Page of SharedCostInstance
  81. */
  82. public function page($options = array(), $pageSize = Values::NONE, $pageToken = Values::NONE, $pageNumber = Values::NONE) {
  83. $options = new Values($options);
  84. $params = Values::of(array(
  85. 'AreaCode' => $options['areaCode'],
  86. 'Contains' => $options['contains'],
  87. 'SmsEnabled' => Serialize::booleanToString($options['smsEnabled']),
  88. 'MmsEnabled' => Serialize::booleanToString($options['mmsEnabled']),
  89. 'VoiceEnabled' => Serialize::booleanToString($options['voiceEnabled']),
  90. 'ExcludeAllAddressRequired' => Serialize::booleanToString($options['excludeAllAddressRequired']),
  91. 'ExcludeLocalAddressRequired' => Serialize::booleanToString($options['excludeLocalAddressRequired']),
  92. 'ExcludeForeignAddressRequired' => Serialize::booleanToString($options['excludeForeignAddressRequired']),
  93. 'Beta' => Serialize::booleanToString($options['beta']),
  94. 'NearNumber' => $options['nearNumber'],
  95. 'NearLatLong' => $options['nearLatLong'],
  96. 'Distance' => $options['distance'],
  97. 'InPostalCode' => $options['inPostalCode'],
  98. 'InRegion' => $options['inRegion'],
  99. 'InRateCenter' => $options['inRateCenter'],
  100. 'InLata' => $options['inLata'],
  101. 'InLocality' => $options['inLocality'],
  102. 'FaxEnabled' => Serialize::booleanToString($options['faxEnabled']),
  103. 'PageToken' => $pageToken,
  104. 'Page' => $pageNumber,
  105. 'PageSize' => $pageSize,
  106. ));
  107. $response = $this->version->page(
  108. 'GET',
  109. $this->uri,
  110. $params
  111. );
  112. return new SharedCostPage($this->version, $response, $this->solution);
  113. }
  114. /**
  115. * Retrieve a specific page of SharedCostInstance records from the API.
  116. * Request is executed immediately
  117. *
  118. * @param string $targetUrl API-generated URL for the requested results page
  119. * @return \Twilio\Page Page of SharedCostInstance
  120. */
  121. public function getPage($targetUrl) {
  122. $response = $this->version->getDomain()->getClient()->request(
  123. 'GET',
  124. $targetUrl
  125. );
  126. return new SharedCostPage($this->version, $response, $this->solution);
  127. }
  128. /**
  129. * Provide a friendly representation
  130. *
  131. * @return string Machine friendly representation
  132. */
  133. public function __toString() {
  134. return '[Twilio.Api.V2010.SharedCostList]';
  135. }
  136. }