subscription-service/src/main/java/com/mantolin/adidascodingchallenge/subscriptionservice/resource/SubscriptionResource.java
/**
     * Subscription entrypoint
     * 
     * @param request
     * @return
     * @throws SubscriptionServiceException
     */
Subscription entrypoint

@param request
@return
@throws SubscriptionServiceException
Subscription entrypoint @param request @return @throws SubscriptionServiceException
@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "Creates a subscription")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Subscription successfully created.", response = SubscriptionResponse.class),
            @ApiResponse(code = 400, message = "Bad request.", response = ErrorDetails.class),
            @ApiResponse(code = 401, message = "Unauthorized. Valid access token must be provided."),
            @ApiResponse(code = 403, message = "Forbidden. The user does not have required role."),
            @ApiResponse(code = 409, message = "Conflict. There was an issue while creating the subscription.", response = ErrorDetails.class),
            @ApiResponse(code = 500, message = "Internal Server Error.", response = ErrorDetails.class)
    })
    public SubscriptionResponse subscribe(@Valid @RequestBody final SubscriptionRequest request)
            throws SubscriptionServiceException {
        log.info("Subscribe: " + request);
        AddSubscriptionRequest addRequest = new AddSubscriptionRequest(request);
        AddSubscriptionResponse addResponse = subscriptionService.addSubscription(addRequest);
        SubscriptionResponse response = new SubscriptionResponse(addResponse.getSubscription().getId());
        return response;
    }
@ PostMapping ( consumes = MediaType . APPLICATION_JSON_VALUE , produces = MediaType . APPLICATION_JSON_VALUE ) @ ApiOperation ( value = "Creates a subscription" ) @ ApiResponses ( value = { @ ApiResponse ( code = 200 , message = "Subscription successfully created." , response = SubscriptionResponse . class ) , @ ApiResponse ( code = 400 , message = "Bad request." , response = ErrorDetails . class ) , @ ApiResponse ( code = 401 , message = "Unauthorized. Valid access token must be provided." ) , @ ApiResponse ( code = 403 , message = "Forbidden. The user does not have required role." ) , @ ApiResponse ( code = 409 , message = "Conflict. There was an issue while creating the subscription." , response = ErrorDetails . class ) , @ ApiResponse ( code = 500 , message = "Internal Server Error." , response = ErrorDetails . class ) } ) public SubscriptionResponse subscribe ( @ Valid @ RequestBody final SubscriptionRequest request ) throws SubscriptionServiceException { log . info ( "Subscribe: " + request ) ; AddSubscriptionRequest addRequest = new AddSubscriptionRequest ( request ) ; AddSubscriptionResponse addResponse = subscriptionService . addSubscription ( addRequest ) ; SubscriptionResponse response = new SubscriptionResponse ( addResponse . getSubscription ( ) . getId ( ) ) ; return response ; }
Subscription entrypoint
Subscription entrypoint