Skip to content

Commit

Permalink
Merge pull request #2 from gponty/creditnote
Browse files Browse the repository at this point in the history
Add all credit notes
  • Loading branch information
gponty authored Jun 15, 2023
2 parents 85b2db6 + c7a82d9 commit b4b9239
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/IdLoomApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,29 @@ public function getAllInvoices(array $options = []): array

return ['success' => true, 'data' => $data];
}

public function getAllCreditNotes(array $options = []): array
{
$options['page'] = 1;
$creditNotesAvailable = true;

$data = [];

while ($creditNotesAvailable) {
$retour = $this->request('GET', '/credit-notes', $options);

if ($retour['success']) {
$creditNotes = $retour['data'];
$data = \array_merge($data, $creditNotes);
if (0 === \count($creditNotes)) {
$creditNotesAvailable = false;
}
} else {
return $retour;
}
++$options['page'];
}

return ['success' => true, 'data' => $data];
}
}

0 comments on commit b4b9239

Please sign in to comment.