diff --git a/rest/index.php b/rest/index.php index b9ad8fdbb809ab1666669b0c83475b3642f28621..eee8e31a2981477e49423d9b691f1f16f737e5e2 100755 --- a/rest/index.php +++ b/rest/index.php @@ -371,7 +371,7 @@ $app->get('/categories', \Resource\controllers\ResController::class . ':getCateg $app->get('/resources/{resId}/users/{userId}/isDestinationChanging', \Action\controllers\PreProcessActionController::class . ':isDestinationChanging'); $app->get('/resources/{resId}/users/{userId}/groups/{groupId}/baskets/{basketId}/processingData', \Resource\controllers\ResController::class . ':getProcessingData'); $app->post('/resources/exportData', \Resource\controllers\ResourceDataExportController::class . ':generateFile'); -$app->put('/resources/{resId}/setInIntegrations', \Resource\controllers\ResController::class . ':setInIntegrations'); +$app->put('/resources/{resId}/integrations', \Resource\controllers\ResController::class . ':setInIntegrations'); //ResourcesList $app->get('/resourcesList/users/{userId}/groups/{groupId}/baskets/{basketId}', \Resource\controllers\ResourceListController::class . ':get'); diff --git a/src/app/resource/controllers/ResController.php b/src/app/resource/controllers/ResController.php index 3045b5e7452e12793246bffd843168478418c657..f892dd778fc4d94f232ce8d71104122ffba836aa 100755 --- a/src/app/resource/controllers/ResController.php +++ b/src/app/resource/controllers/ResController.php @@ -722,7 +722,7 @@ class ResController $body = $request->getParsedBody(); if (empty($body['integrations'])) { - return $response->withStatus(403)->withJson(['errors' => 'Query param integrations is missing']); + return $response->withStatus(400)->withJson(['errors' => 'Body param integrations is missing']); } $resource = ResModel::getById(['resId' => $args['resId'], 'select' => ['integrations']]); @@ -731,8 +731,17 @@ class ResController } $integrations = json_decode($resource['integrations'], true); - $integrations['inSignatureBook'] = $body['integrations']['inSignatureBook'] ?? $integrations['inSignatureBook']; - $integrations['inShipping'] = $body['integrations']['inShipping'] ?? $integrations['inShipping']; + if (!empty($body['integrations']['inSignatureBook']) && Validator::boolType()->validate($body['integrations']['inSignatureBook'])) { + $integrations['inSignatureBook'] = $body['integrations']['inSignatureBook']; + } else { + $integrations['inSignatureBook'] = $integrations['inSignatureBook'] ?? false; + } + + if (!empty($body['integrations']['inShipping']) && Validator::boolType()->validate($body['integrations']['inShipping'])) { + $integrations['inShipping'] = $body['integrations']['inShipping']; + } else { + $integrations['inShipping'] = $integrations['inShipping'] ?? false; + } ResModel::update([ 'set' => [