class Sol003PackageManagementSubscriptionController {

    @PostMapping(value = "/subscriptions")
    public ResponseEntity<?> postSubscriptionRequest(@RequestBody final PkgmSubscriptionRequest pkgmSubscriptionRequest)
            throws GeneralSecurityException {
        logger.info(LOG_REQUEST_RECEIVED, " postSubscriptionRequest Endpoint Called", pkgmSubscriptionRequest);

        // Check if subscription exists already.
        final Optional<String> exists = subscriptionManager.getSubscriptionId(pkgmSubscriptionRequest);

        if (exists.isPresent()) {
            final URI subscriptionUri = subscriptionManager.getSubscriptionUri(exists.get());
            final HttpHeaders headers = createLocationHeader(subscriptionUri);
            logger.info("PkgmSubscriptionRequest already exists with uri {} ", subscriptionUri);
            return new ResponseEntity<>(headers, HttpStatus.SEE_OTHER);
        }

        logger.debug("No duplicate Subscription exists, continuing with POST.");
        final Optional<InlineResponse201> optionalInlineResponse =
                subscriptionManager.createSubscription(pkgmSubscriptionRequest);

        if (optionalInlineResponse.isPresent()) {
            InlineResponse201 inlineResponse = optionalInlineResponse.get();
            final URI subscriptionUri = subscriptionManager.getSubscriptionUri(inlineResponse.getId());
            final HttpHeaders headers = createLocationHeader(subscriptionUri);
            logger.debug("Sending response with uri {} ", subscriptionUri);
            return new ResponseEntity<>(inlineResponse, headers, HttpStatus.CREATED);
        }
        final String errorMessage = "A null response was received during the postSubscriptionRequest call.";
        logger.error(errorMessage);
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new ProblemDetails().detail(errorMessage));
    }

    @Autowired public  Sol003PackageManagementSubscriptionController(final SubscriptionManager subscriptionManager);

}