invalidSyncOperationException example


    public function testInvalidSyncCriteriaException(): void
    {
        $exception = ApiException::invalidSyncCriteriaException('operationKey');

        static::assertEquals(ApiException::API_INVALID_SYNC_CRITERIA_EXCEPTION, $exception->getErrorCode());
        static::assertEquals('Sync operation operationKey, with action "delete", requires a criteria with at least one filter and can only be applied for mapping entities', $exception->getMessage());
    }

    public function testInvalidSyncOperationException(): void
    {
        $exception = ApiException::invalidSyncOperationException('message');

        static::assertEquals(ApiException::API_INVALID_SYNC_OPERATION_EXCEPTION, $exception->getErrorCode());
        static::assertEquals('message', $exception->getMessage());
    }

    public function testResolverNotFoundException(): void
    {
        $exception = ApiException::resolverNotFoundException('name');

        static::assertEquals(ApiException::API_RESOLVER_NOT_FOUND_EXCEPTION, $exception->getErrorCode());
        static::assertEquals('Foreign key resolver for key name not found', $exception->getMessage());
    }

            $key = (string) $key;
            $operations[] = new SyncOperation(
                $key,
                $operation['entity'],
                $operation['action'],
                $operation['payload'] ?? [],
                $operation['criteria'] ?? []
            );

            if (empty($operation['entity'])) {
                throw ApiException::invalidSyncOperationException(sprintf('Missing "entity" argument for operation with key "%s". It needs to be a non-empty string.', (string) $key));
            }
        }

        $result = $context->scope(Context::CRUD_API_SCOPE, fn (Context $context): SyncResult => $this->syncService->sync($operations$context$behavior));

        return $this->createResponse($result, Response::HTTP_OK);
    }

    private function createResponse(SyncResult $result, int $statusCode = 200): JsonResponse
    {
        $response = new JsonResponse(null, $statusCode);
        
Home | Imprint | This part of the site doesn't use cookies.