Search in sources :

Example 1 with MiraklShopKycStatus

use of com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus in project mirakl-hyperwallet-connector by paypal.

the class AbstractKYCUserStatusNotificationStrategy method updateShop.

protected void updateShop(final KYCUserStatusNotificationBodyModel kycUserStatusNotificationBodyModel) {
    final MiraklShopKycStatus status = expectedKycMiraklStatus(kycUserStatusNotificationBodyModel);
    if (Objects.nonNull(status)) {
        final String shopId = kycUserStatusNotificationBodyModel.getClientUserId();
        final MiraklUpdateShopsRequest request = createUpdateShopRequest(kycUserStatusNotificationBodyModel, status);
        log.info("Updating KYC status for shop [{}]", shopId);
        try {
            final MiraklUpdatedShops response = miraklOperatorClient.updateShops(request);
            if (response == null) {
                log.error("No response was received for update request for shop [{}]", shopId);
            } else {
                final List<MiraklUpdatedShopReturn> shopReturns = response.getShopReturns();
                shopReturns.forEach(this::logShopUpdates);
            }
            deleteInvalidDocuments(kycUserStatusNotificationBodyModel);
        } catch (final MiraklException ex) {
            final String errorMessage = String.format(MSG_ERROR_DETECTED, shopId, MiraklLoggingErrorsUtil.stringify(ex));
            log.error(errorMessage);
            mailNotificationUtil.sendPlainTextEmail(MAIL_SUBJECT, ERROR_MESSAGE_PREFIX + errorMessage);
            // Rethrow exception to handle it in AbstractNotificationListener
            throw ex;
        }
    }
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklUpdatedShopReturn(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn) MiraklUpdatedShops(com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops) MiraklUpdateShopsRequest(com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest) MiraklShopKycStatus(com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus)

Example 2 with MiraklShopKycStatus

use of com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus in project mirakl-hyperwallet-connector by paypal.

the class BusinessKycUserNotificationStrategyTest method expectedKycMiraklStatus_shouldSetCorrectMiraklStatus_whenBusinessStakeHolderVerificationStatusIsNull.

@Test
void expectedKycMiraklStatus_shouldSetCorrectMiraklStatus_whenBusinessStakeHolderVerificationStatusIsNull() {
    // @formatter:off
    final KYCUserStatusNotificationBodyModel KYCUserStatusNotificationBodyModelStub = KYCUserStatusNotificationBodyModel.builder().clientUserId(String.valueOf(CLIENT_USER_ID)).verificationStatus(HyperwalletUser.VerificationStatus.VERIFIED).businessStakeholderVerificationStatus(null).letterOfAuthorizationStatus(HyperwalletUser.LetterOfAuthorizationStatus.VERIFIED).profileType(HyperwalletUser.ProfileType.BUSINESS).build();
    // @formatter:on
    final MiraklShopKycStatus result = testObj.expectedKycMiraklStatus(KYCUserStatusNotificationBodyModelStub);
    assertThat(result).isEqualTo(MiraklShopKycStatus.APPROVED);
}
Also used : MiraklShopKycStatus(com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus) KYCUserStatusNotificationBodyModel(com.paypal.kyc.model.KYCUserStatusNotificationBodyModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with MiraklShopKycStatus

use of com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus in project mirakl-hyperwallet-connector by paypal.

the class BusinessKycUserNotificationStrategyTest method expectedKycMiraklStatus_shouldSetCorrectMiraklStatus_whenVerificationStatusIsNull.

@Test
void expectedKycMiraklStatus_shouldSetCorrectMiraklStatus_whenVerificationStatusIsNull() {
    // @formatter:off
    final KYCUserStatusNotificationBodyModel KYCUserStatusNotificationBodyModelStub = KYCUserStatusNotificationBodyModel.builder().clientUserId(String.valueOf(CLIENT_USER_ID)).verificationStatus(null).businessStakeholderVerificationStatus(HyperwalletUser.BusinessStakeholderVerificationStatus.VERIFIED).letterOfAuthorizationStatus(HyperwalletUser.LetterOfAuthorizationStatus.VERIFIED).profileType(HyperwalletUser.ProfileType.BUSINESS).build();
    // @formatter:on
    final MiraklShopKycStatus result = testObj.expectedKycMiraklStatus(KYCUserStatusNotificationBodyModelStub);
    assertThat(result).isEqualTo(MiraklShopKycStatus.APPROVED);
}
Also used : MiraklShopKycStatus(com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus) KYCUserStatusNotificationBodyModel(com.paypal.kyc.model.KYCUserStatusNotificationBodyModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with MiraklShopKycStatus

use of com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus in project mirakl-hyperwallet-connector by paypal.

the class BusinessKycUserNotificationStrategyTest method expectedKycMiraklStatus_shouldSetCorrectMiraklStatus_whenLetterOfAuthorizationStatusIsNull.

@Test
void expectedKycMiraklStatus_shouldSetCorrectMiraklStatus_whenLetterOfAuthorizationStatusIsNull() {
    // @formatter:off
    final KYCUserStatusNotificationBodyModel KYCUserStatusNotificationBodyModelStub = KYCUserStatusNotificationBodyModel.builder().clientUserId(String.valueOf(CLIENT_USER_ID)).verificationStatus(HyperwalletUser.VerificationStatus.VERIFIED).businessStakeholderVerificationStatus(HyperwalletUser.BusinessStakeholderVerificationStatus.VERIFIED).letterOfAuthorizationStatus(null).profileType(HyperwalletUser.ProfileType.BUSINESS).build();
    // @formatter:on
    final MiraklShopKycStatus result = testObj.expectedKycMiraklStatus(KYCUserStatusNotificationBodyModelStub);
    assertThat(result).isEqualTo(MiraklShopKycStatus.APPROVED);
}
Also used : MiraklShopKycStatus(com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus) KYCUserStatusNotificationBodyModel(com.paypal.kyc.model.KYCUserStatusNotificationBodyModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with MiraklShopKycStatus

use of com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus in project mirakl-hyperwallet-connector by paypal.

the class BusinessKycUserNotificationStrategyTest method expectedKycMiraklStatus_shouldSetCorrectMiraklStatusBasedOnHyperwalletUserStatusesForBusiness.

@MethodSource("validVerificationStatuses")
@ParameterizedTest
void expectedKycMiraklStatus_shouldSetCorrectMiraklStatusBasedOnHyperwalletUserStatusesForBusiness(final HyperwalletUser.VerificationStatus verificationStatus, final HyperwalletUser.BusinessStakeholderVerificationStatus businessStakeholderVerificationStatus, final HyperwalletUser.LetterOfAuthorizationStatus letterOfAuthorizationStatus, final MiraklShopKycStatus miraklShopKycStatus) {
    // @formatter:off
    final KYCUserStatusNotificationBodyModel KYCUserStatusNotificationBodyModelStub = KYCUserStatusNotificationBodyModel.builder().clientUserId(String.valueOf(CLIENT_USER_ID)).verificationStatus(verificationStatus).businessStakeholderVerificationStatus(businessStakeholderVerificationStatus).letterOfAuthorizationStatus(letterOfAuthorizationStatus).profileType(HyperwalletUser.ProfileType.BUSINESS).build();
    // @formatter:on
    final MiraklShopKycStatus result = testObj.expectedKycMiraklStatus(KYCUserStatusNotificationBodyModelStub);
    assertThat(result).isEqualTo(miraklShopKycStatus);
}
Also used : MiraklShopKycStatus(com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus) KYCUserStatusNotificationBodyModel(com.paypal.kyc.model.KYCUserStatusNotificationBodyModel) MethodSource(org.junit.jupiter.params.provider.MethodSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

MiraklShopKycStatus (com.mirakl.client.mmp.domain.shop.MiraklShopKycStatus)6 KYCUserStatusNotificationBodyModel (com.paypal.kyc.model.KYCUserStatusNotificationBodyModel)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 Test (org.junit.jupiter.api.Test)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 MiraklException (com.mirakl.client.core.exception.MiraklException)1 MiraklUpdatedShopReturn (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShopReturn)1 MiraklUpdatedShops (com.mirakl.client.mmp.operator.domain.shop.update.MiraklUpdatedShops)1 MiraklUpdateShopsRequest (com.mirakl.client.mmp.operator.request.shop.MiraklUpdateShopsRequest)1