示例#1
0
文件: Util.php 项目: VinniaAB/fortnox
 /**
  * @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;
 }
示例#2
0
 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);
 }
示例#3
0
 /**
  * @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;
 }