Browse Source

fix dolibarr society creation call

Olivier Massot 1 year ago
parent
commit
973d76d12f

+ 3 - 1
src/Service/Dolibarr/DolibarrApiService.php

@@ -182,6 +182,8 @@ class DolibarrApiService extends ApiRequestService
     }
 
     /**
+     * Créé une société dans la DB dolibarr, et retourne l'id de celle-ci.
+     *
      * @param Organization $organization
      * @return mixed
      */
@@ -196,7 +198,7 @@ class DolibarrApiService extends ApiRequestService
         ];
 
         /** @var Response $response */
-        $response = $this->post("api/index.php/thirdparties", $body);
+        $response = $this->post("/thirdparties", $body);
 
         return json_decode($response->getContent(), true);
     }

+ 4 - 5
src/State/Processor/Organization/OrganizationCreationRequestProcessor.php

@@ -4,8 +4,8 @@ declare(strict_types=1);
 
 namespace App\State\Processor\Organization;
 
-use ApiPlatform\Metadata\Delete;
 use ApiPlatform\Metadata\Operation;
+use ApiPlatform\Metadata\Post;
 use ApiPlatform\State\ProcessorInterface;
 use App\ApiResources\Organization\OrganizationCreationRequest;
 use App\Message\Command\OrganizationCreationCommand;
@@ -15,9 +15,8 @@ use Symfony\Component\Messenger\MessageBusInterface;
 class OrganizationCreationRequestProcessor implements ProcessorInterface
 {
     public function __construct(
-        private MessageBusInterface $messageBus,
-    ) {
-    }
+        private readonly MessageBusInterface $messageBus
+    ) {}
 
     /**
      * @param OrganizationCreationRequest $organizationCreationRequest
@@ -28,7 +27,7 @@ class OrganizationCreationRequestProcessor implements ProcessorInterface
      */
     public function process(mixed $organizationCreationRequest, Operation $operation, array $uriVariables = [], array $context = []): OrganizationCreationRequest
     {
-        if ($operation instanceof Delete) {
+        if (!$operation instanceof Post) {
             throw new \RuntimeException('not supported', Response::HTTP_METHOD_NOT_ALLOWED);
         }