1 | <?php |
||
14 | class Report extends LazyResource implements \Iterator, \Countable |
||
15 | { |
||
16 | use PaginatedListGenerator; |
||
17 | |||
18 | /** @var Client */ |
||
19 | protected $client; |
||
20 | |||
21 | /** @var string */ |
||
22 | public $path; |
||
23 | |||
24 | /** @var string */ |
||
25 | public $filter; |
||
26 | |||
27 | /** @var array */ |
||
28 | protected $headers = []; |
||
29 | |||
30 | /** @var string */ |
||
31 | protected $resumptionToken = null; |
||
32 | |||
33 | /** @var bool */ |
||
34 | protected $isFinished = false; |
||
35 | |||
36 | /** @var int */ |
||
37 | public $chunkSize = 1000; |
||
38 | |||
39 | /** @var Row[] */ |
||
40 | protected $resources = []; |
||
41 | |||
42 | public static $maxAttempts = 5; |
||
43 | |||
44 | public static $retryDelayTime = 3; |
||
45 | |||
46 | public function __construct(Client $client = null, $path = null, $headers = [], $filter = null) |
||
54 | |||
55 | /** |
||
56 | * @deprecated |
||
57 | * |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function getRows() |
||
64 | |||
65 | public function getHeaders() |
||
73 | |||
74 | /** |
||
75 | * Generate the base URL for this resource. |
||
76 | * |
||
77 | * @return string |
||
78 | */ |
||
79 | protected function urlBase() |
||
83 | |||
84 | /** |
||
85 | * Convert a retrieved resource to an object. |
||
86 | * |
||
87 | * @param $data |
||
88 | * |
||
89 | * @return mixed |
||
90 | */ |
||
91 | protected function convertToResource($data) |
||
95 | |||
96 | /** |
||
97 | * Note: chunkSize must be between 25 and 1000. |
||
98 | * |
||
99 | * @param int $attempt |
||
100 | * @param int $chunkSize |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | protected function fetchBatch($attempt = 1, $chunkSize = null) |
||
150 | |||
151 | protected function fetchData() |
||
157 | |||
158 | /** |
||
159 | * Read column headers from response, and check that we got the right number of columns back. |
||
160 | * |
||
161 | * @param QuiteSimpleXMLElement $results |
||
162 | */ |
||
163 | protected function readColumnHeaders(QuiteSimpleXMLElement $results) |
||
189 | |||
190 | /** |
||
191 | * Check if we have the full representation of our data object. We cannot |
||
192 | * really know from the data object alone, but when this method is called |
||
193 | * we should have all the data. |
||
194 | * |
||
195 | * @param \stdClass $data |
||
196 | * |
||
197 | * @return bool |
||
198 | */ |
||
199 | protected function isInitialized($data) |
||
203 | |||
204 | /** |
||
205 | * Total number of resources. Note that we don't get this number from API upfront, |
||
206 | * so we have to fetch all the rows to find out. |
||
207 | * |
||
208 | * @link http://php.net/manual/en/countable.count.php |
||
209 | * |
||
210 | * @return int |
||
211 | */ |
||
212 | public function count() |
||
216 | |||
217 | /** |
||
218 | * Magic! |
||
219 | * |
||
220 | * @param string $key |
||
221 | * |
||
222 | * @return mixed |
||
223 | */ |
||
224 | public function __get($key) |
||
233 | } |
||
234 |