Search in sources :

Example 6 with MiraklGetShopDocumentsRequest

use of com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImplTest method getBusinessStakeholderDocumentsSelectedBySeller_shouldPopulateKYCInfoModelWithDocumentInformationAndReturnDocumentsReturnedByStrategies_whenLetterOfAuthorizationIsRequiredAndLetterOfAuthorizationDocumentIsFilled.

@Test
void getBusinessStakeholderDocumentsSelectedBySeller_shouldPopulateKYCInfoModelWithDocumentInformationAndReturnDocumentsReturnedByStrategies_whenLetterOfAuthorizationIsRequiredAndLetterOfAuthorizationDocumentIsFilled() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeHolderInfoModel = KYCDocumentBusinessStakeHolderInfoModel.builder().businessStakeholderMiraklNumber(1).requiresLetterOfAuthorization(Boolean.TRUE).clientUserId(MIRAKL_SHOP_ID).proofOfIdentity(KYCProofOfIdentityEnum.GOVERNMENT_ID).build();
    // @formatter:on
    final KYCDocumentModel kycDocumentModelProofOfIdentityFront = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_IDENTITY_FRONT).build();
    final KYCDocumentModel kycDocumentModelProofOfIdentityBack = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_IDENTITY_BACK).build();
    final KYCDocumentModel kycDocumentModelLetterOfAuthorization = KYCDocumentModel.builder().documentFieldName(KYCConstants.HwDocuments.PROOF_OF_AUTHORIZATION).build();
    final MiraklShopDocument miraklShopProofOfIdentityDocumentFront = new MiraklShopDocument();
    miraklShopProofOfIdentityDocumentFront.setTypeCode("hw-bsh1-proof-identity-front");
    final MiraklShopDocument miraklShopProofOfIdentityDocumentBack = new MiraklShopDocument();
    miraklShopProofOfIdentityDocumentBack.setTypeCode("hw-bsh1-proof-identity-back");
    final MiraklShopDocument miraklShopLetterOfAuthorizationDocument = new MiraklShopDocument();
    miraklShopProofOfIdentityDocumentBack.setTypeCode("hw-bsh-letter-authorization");
    final List<MiraklShopDocument> miraklShopDocumentsList = List.of(miraklShopProofOfIdentityDocumentFront, miraklShopProofOfIdentityDocumentBack, miraklShopLetterOfAuthorizationDocument);
    when(miraklMarketplacePlatformOperatorApiClientMock.getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)))).thenReturn(miraklShopDocumentsList);
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentBusinessStakeholderInfoModelWithMiraklDocumentsShopInformation = kycDocumentBusinessStakeHolderInfoModel.toBuilder().miraklShopDocuments(miraklShopDocumentsList).build();
    when(proofOfIdentityStrategyExecutorMock.execute(kycDocumentBusinessStakeholderInfoModelWithMiraklDocumentsShopInformation)).thenReturn(List.of(List.of(kycDocumentModelProofOfIdentityFront, kycDocumentModelProofOfIdentityBack, kycDocumentModelLetterOfAuthorization)));
    final KYCDocumentBusinessStakeHolderInfoModel result = testObj.getBusinessStakeholderDocumentsSelectedBySeller(kycDocumentBusinessStakeHolderInfoModel);
    verify(miraklMarketplacePlatformOperatorApiClientMock).getShopDocuments(new MiraklGetShopDocumentsRequest(List.of(MIRAKL_SHOP_ID)));
    verifyNoMoreInteractions(miraklMarketplacePlatformOperatorApiClientMock);
    assertThat(result.getDocuments()).containsExactlyInAnyOrder(kycDocumentModelProofOfIdentityFront, kycDocumentModelProofOfIdentityBack, kycDocumentModelLetterOfAuthorization);
}
Also used : KYCDocumentModel(com.paypal.kyc.model.KYCDocumentModel) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with MiraklGetShopDocumentsRequest

use of com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklBusinessStakeholderDocumentDownloadExtractServiceImpl method populateMiraklShopBusinessStakeholderDocuments.

protected KYCDocumentBusinessStakeHolderInfoModel populateMiraklShopBusinessStakeholderDocuments(final KYCDocumentBusinessStakeHolderInfoModel kycBusinessStakeHolderInfoModel) {
    final MiraklGetShopDocumentsRequest getShopBusinessStakeholderDocumentsRequest = new MiraklGetShopDocumentsRequest(List.of(kycBusinessStakeHolderInfoModel.getClientUserId()));
    try {
        log.info("Retrieving business stakeholder documents for seller with id [{}]", kycBusinessStakeHolderInfoModel.getClientUserId());
        final List<MiraklShopDocument> shopDocuments = miraklMarketplacePlatformOperatorApiClient.getShopDocuments(getShopBusinessStakeholderDocumentsRequest);
        // @formatter:off
        log.info("Business stakeholder documents available for seller with id [{}]: [{}]", kycBusinessStakeHolderInfoModel.getClientUserId(), shopDocuments.stream().map(miraklDocument -> "Id:" + miraklDocument.getId() + " ,fileName:" + miraklDocument.getFileName() + " ,typeCode:" + miraklDocument.getTypeCode()).collect(Collectors.joining(" | ")));
        // @formatter:on
        return kycBusinessStakeHolderInfoModel.toBuilder().miraklShopDocuments(shopDocuments).build();
    } catch (final MiraklException e) {
        log.error("Something went wrong trying to receive business stakeholder documents from Mirakl for seller with id [{}]", kycBusinessStakeHolderInfoModel.getClientUserId());
        kycMailNotificationUtil.sendPlainTextEmail("Issue detected getting business stakeholder documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycBusinessStakeHolderInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(e)));
    }
    return kycBusinessStakeHolderInfoModel.toBuilder().build();
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)

Example 8 with MiraklGetShopDocumentsRequest

use of com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest in project mirakl-hyperwallet-connector by paypal.

the class MiraklSellerDocumentDownloadExtractServiceImpl method populateMiraklShopDocuments.

/**
 * {@inheritDoc}
 */
@Override
public KYCDocumentSellerInfoModel populateMiraklShopDocuments(final KYCDocumentSellerInfoModel kycDocumentSellerInfoModel) {
    final MiraklGetShopDocumentsRequest getShopDocumentsRequest = new MiraklGetShopDocumentsRequest(List.of(kycDocumentSellerInfoModel.getClientUserId()));
    try {
        log.info("Retrieving documents for seller with id [{}]", kycDocumentSellerInfoModel.getClientUserId());
        final List<MiraklShopDocument> shopDocuments = miraklMarketplacePlatformOperatorApiClient.getShopDocuments(getShopDocumentsRequest);
        log.info("Documents retrieved for seller with id [{}]: [{}]", kycDocumentSellerInfoModel.getClientUserId(), shopDocuments.stream().map(MiraklShopDocument::getId).collect(Collectors.joining(",")));
        return kycDocumentSellerInfoModel.toBuilder().miraklShopDocuments(shopDocuments).build();
    } catch (final MiraklException e) {
        log.error("Something went wrong trying to receive documents from Mirakl for seller with id [{}]", kycDocumentSellerInfoModel.getClientUserId());
        kycMailNotificationUtil.sendPlainTextEmail("Issue detected getting documents from Mirakl", String.format("Something went wrong getting documents from Mirakl for shop Id [%s]%n%s", String.join(",", kycDocumentSellerInfoModel.getClientUserId()), MiraklLoggingErrorsUtil.stringify(e)));
    }
    return kycDocumentSellerInfoModel.toBuilder().build();
}
Also used : MiraklException(com.mirakl.client.core.exception.MiraklException) MiraklGetShopDocumentsRequest(com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest) MiraklShopDocument(com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)

Aggregations

MiraklGetShopDocumentsRequest (com.mirakl.client.mmp.request.shop.document.MiraklGetShopDocumentsRequest)8 MiraklShopDocument (com.mirakl.client.mmp.domain.shop.document.MiraklShopDocument)7 Test (org.junit.jupiter.api.Test)6 MiraklException (com.mirakl.client.core.exception.MiraklException)4 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 KYCDocumentModel (com.paypal.kyc.model.KYCDocumentModel)2