sdsad
This commit is contained in:
@@ -265,6 +265,10 @@ final class Router
|
||||
Http::json(['data' => $this->saveCostPlan($projectKey, Http::input())], 201);
|
||||
}
|
||||
|
||||
if (preg_match('~^cost-plans/(\d+)$~', $resource, $matches) && $method === 'PATCH') {
|
||||
Http::json(['data' => $this->updateCostPlan($projectKey, (int) $matches[1], Http::input())]);
|
||||
}
|
||||
|
||||
if ($resource === 'payouts' && $method === 'GET') {
|
||||
Http::json(['data' => $this->payouts($projectKey)]);
|
||||
}
|
||||
@@ -1912,6 +1916,24 @@ final class Router
|
||||
]);
|
||||
}
|
||||
|
||||
private function updateCostPlan(string $projectKey, int $planId, array $input): array
|
||||
{
|
||||
$plan = $this->repository()->getCostPlan($projectKey, $planId);
|
||||
if (!is_array($plan)) {
|
||||
throw new ApiException('Manuell eingetragener Miner nicht gefunden.', 404);
|
||||
}
|
||||
|
||||
if (!array_key_exists('auto_renew', $input)) {
|
||||
throw new ApiException('Es kann aktuell nur auto_renew geaendert werden.', 422, ['field' => 'auto_renew']);
|
||||
}
|
||||
|
||||
return $this->repository()->updateCostPlanAutoRenew(
|
||||
$projectKey,
|
||||
$planId,
|
||||
!empty($input['auto_renew'])
|
||||
);
|
||||
}
|
||||
|
||||
private function savePayout(string $projectKey, array $input): array
|
||||
{
|
||||
$transferMode = $this->enumValue($input['transfer_mode'] ?? 'manual', ['manual', 'full_latest'], 'transfer_mode');
|
||||
|
||||
Reference in New Issue
Block a user