class ConsentController extends AbstractController implements ConsentApi, AccountApi {

    @Override
    public ResponseEntity<ConsentsResponse201> createConsent(Map<String, String> parameters,
                                                               Map<String, String> headers,
                                                               Consents body) {
        RequestHeaders requestHeaders = RequestHeaders.fromMap(headers);
        RequestParams requestParams = RequestParams.fromMap(parameters);

        Response<ConsentsResponse201> response;
        try {
            response = accountInformationService.createConsent(requestHeaders,
                requestParams,
                body);
        } catch (ErrorResponseException e) {
            if (e.getStatusCode() == 403 && e.getMessage() != null && e.getMessage().contains("TOKEN_INVALID")) {
                ConsentsResponse201 consentsResponse = new ConsentsResponse201();
                HrefType preOauthHref = new HrefType();
                preOauthHref.setHref(Oauth2Api.AUTHORIZATION_REQUEST_URI);
                Map<String, HrefType> preOauth = singletonMap("preOauth", preOauthHref);
                consentsResponse.setLinks(preOauth);
                return ResponseEntity.ok(consentsResponse);
            }
            throw e;
        }

        ConsentsResponse201 consentsResponse = response.getBody();
        if (consentsResponse.getConsentId() == null && consentsResponse.getLinks() == null) {
            HrefType oauthConsentHref = new HrefType();
            oauthConsentHref.setHref(Oauth2Api.AUTHORIZATION_REQUEST_URI);
            consentsResponse.setLinks(
                singletonMap("oauthConsent", oauthConsentHref)
            );
        }

        return ResponseEntity.status(HttpStatus.CREATED)
            .headers(headersMapper.toHttpHeaders(response.getHeaders()))
            .body(consentsResponse);
    }

    public  ConsentController(AccountInformationService accountInformationService, ObjectMapper objectMapper, HeadersMapper headersMapper);

}