@Override
    public AppResponse process(Flow flow, AppRequest request) {

        if (!appSession.getWithBsn()) {
            digidClient.remoteLog("1487", Map.of(lowerUnderscore(ACCOUNT_ID), appSession.getAccountId(), "hidden", true));
            return new NokResponse("no_bsn_on_account");
        }

        boolean reRequestLetter = flow.getName().equals(ReApplyActivateActivationCode.NAME);

        if(reRequestLetter){
            digidClient.remoteLog("914", Map.of(lowerUnderscore(ACCOUNT_ID), appAuthenticator.getAccountId(), lowerUnderscore(APP_CODE), appAuthenticator.getAppCode(), lowerUnderscore(DEVICE_NAME), appAuthenticator.getDeviceName()));
        }

        Map<String, Object> result = digidClient.createLetter(appSession.getAccountId(), appSession.getActivationMethod(), reRequestLetter);
        if (result.get(ERROR) != null){
            if(result.get(ERROR).equals("too_often")){
                digidClient.remoteLog("906", Map.of(lowerUnderscore(ACCOUNT_ID), appAuthenticator.getAccountId(), lowerUnderscore(APP_CODE), appAuthenticator.getAppCode(), lowerUnderscore(DEVICE_NAME), appAuthenticator.getDeviceName()));
                return new NokTooOftenResponse((Map<String, Object>) result.get(PAYLOAD), (String) result.get(ERROR));
            } else if(result.get(ERROR).equals("too_soon")){
                digidClient.remoteLog("758", Map.of(lowerUnderscore(ACCOUNT_ID), appAuthenticator.getAccountId()));
            } else if(result.get(ERROR).equals("too_many_letter_requests")){
                digidClient.remoteLog("1554", Map.of(lowerUnderscore(ACCOUNT_ID), appAuthenticator.getAccountId(), lowerUnderscore(APP_CODE), appAuthenticator.getAppCode(), lowerUnderscore(DEVICE_NAME), appAuthenticator.getDeviceName()));
            }
            return new NokResponse((String) result.get(ERROR));
        }

        appSession.setRegistrationId(((Integer) result.get(lowerUnderscore(REGISTRATION_ID))).longValue());

        digidClient.remoteLog("904", Map.of(lowerUnderscore(ACCOUNT_ID), appAuthenticator.getAccountId(), lowerUnderscore(APP_CODE), appAuthenticator.getAppCode(), lowerUnderscore(DEVICE_NAME), appAuthenticator.getDeviceName()));

        return new OkResponse();
    }
@Test
    void processTooSoon() {
        when(digidClientMock.createLetter(mockedAppSession.getAccountId(), mockedAppSession.getActivationMethod(), true)).thenReturn(tooSoonCreateLetterResponse);
        when(mockedFlow.getName()).thenReturn(ReApplyActivateActivationCode.NAME);

        NokResponse appResponse = (NokResponse) letterSent.process(mockedFlow, mockedAbstractAppRequest);

        verify(digidClientMock, times(1)).remoteLog("758", ImmutableMap.of(lowerUnderscore(ACCOUNT_ID), mockedAppSession.getAccountId()));
        assertEquals(TOO_SOON, appResponse.getError());
    }