miner
This commit is contained in:
@@ -327,6 +327,11 @@ final class Router
|
||||
Http::json(['data' => $this->updatePurchasedMiner($projectKey, (int) $matches[1], Http::input())]);
|
||||
}
|
||||
|
||||
if (preg_match('~^purchased-miners/(\d+)$~', $resource, $matches) && $method === 'DELETE') {
|
||||
$this->deletePurchasedMiner($projectKey, (int) $matches[1]);
|
||||
Http::json(['data' => ['deleted' => true]]);
|
||||
}
|
||||
|
||||
if (preg_match('~^miner-offers/([^/]+)/purchase$~', $resource, $matches) && $method === 'POST') {
|
||||
$this->repository()->ensureProject($projectKey);
|
||||
Http::json(['data' => $this->purchaseMiner($projectKey, rawurldecode((string) $matches[1]), Http::input())], 201);
|
||||
@@ -2179,6 +2184,19 @@ final class Router
|
||||
);
|
||||
}
|
||||
|
||||
private function deletePurchasedMiner(string $projectKey, int $minerId): void
|
||||
{
|
||||
if ($minerId <= 0) {
|
||||
throw new ApiException('miner_id ist ungueltig.', 422);
|
||||
}
|
||||
|
||||
if (!is_array($this->repository()->getPurchasedMiner($projectKey, $minerId))) {
|
||||
throw new ApiException('Gemieteter Miner nicht gefunden.', 404);
|
||||
}
|
||||
|
||||
$this->repository()->deletePurchasedMiner($projectKey, $minerId);
|
||||
}
|
||||
|
||||
private function findComputedMinerOffer(string $projectKey, string $offerId): ?array
|
||||
{
|
||||
foreach ($this->minerOffers($projectKey) as $offer) {
|
||||
|
||||
Reference in New Issue
Block a user