MachineToMachineList.php 6.4 KB

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