Skip to content

Commit

Permalink
Add updateInvoice method to Client (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
petzsch authored Mar 28, 2023
1 parent a3456b5 commit 9a01503
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Client/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,35 @@ public function createInvoice(
}
}

public function updateInvoice(
string $storeId,
string $invoiceId,
?array $metaData = null
): ResultInvoice {
$url = $this->getApiUrl() . 'stores/' . urlencode(
$storeId
) . '/invoices/' . urlencode($invoiceId);
$headers = $this->getRequestHeaders();
$method = 'PUT';

$body = json_encode(
[
'metadata' => $metaData
],
JSON_THROW_ON_ERROR
);

$response = $this->getHttpClient()->request($method, $url, $headers, $body);

if ($response->getStatus() === 200) {
return new ResultInvoice(
json_decode($response->getBody(), true, 512, JSON_THROW_ON_ERROR)
);
} else {
throw $this->getExceptionByStatusCode($method, $url, $response);
}
}

public function getInvoice(
string $storeId,
string $invoiceId
Expand Down

0 comments on commit 9a01503

Please sign in to comment.