/** * @param ResponseInterface[] $responses * @return array */ public static function parseResponses(array $responses) : array { $data = []; foreach ($responses as $response) { $d = Util::parseResponse($response); $data[] = $d; } return $data; }
public function testGetAccounts() { $responses = $this->client->getAccounts(); $responses = Util::parseResponses($responses); $accounts = []; foreach ($responses as $res) { $accounts = array_merge($accounts, $res['Accounts']); } var_dump($accounts); }
/** * @param string $endpoint * @param array $options * @return ResponseInterface[] */ protected function getPaginatedEndpoint(string $endpoint, array $options = []) : array { $responses = []; $totalPages = 1; for ($i = 1; $i <= $totalPages; $i++) { $res = $this->sendRequest('GET', $endpoint, array_merge($options, ['query' => ['page' => $i, 'limit' => 500]])); $parsed = Util::parseResponse($res)['MetaInformation']; $totalPages = (int) $parsed['@TotalPages']; $responses[] = $res; } return $responses; }