Search in sources :

Example 6 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.

the class SellerModelToHyperWalletUserConverter method convert.

/**
 * Method that retrieves a {@link SellerModel} and returns a {@link HyperwalletUser}
 * @param sellerModel the source object {@link SellerModel}
 * @return the returned object {@link HyperwalletUser}
 */
@Override
public HyperwalletUser convert(final SellerModel sellerModel) {
    final HyperwalletUser hyperwalletUser = new HyperwalletUser();
    final HyperwalletUser.ProfileType profileType = EnumUtils.getEnum(HyperwalletUser.ProfileType.class, sellerModel.getProfileType().name(), HyperwalletUser.ProfileType.UNKNOWN);
    hyperwalletUser.setClientUserId(sellerModel.getClientUserId());
    hyperwalletUser.setBusinessName(sellerModel.getBusinessName());
    hyperwalletUser.setProfileType(profileType);
    Optional.ofNullable(sellerModel.getBusinessType()).map(Enum::name).map(HyperwalletUser.BusinessType::valueOf).ifPresent(hyperwalletUser::setBusinessType);
    hyperwalletUser.setAddressLine1(sellerModel.getAddressLine1());
    hyperwalletUser.setCity(sellerModel.getCity());
    hyperwalletUser.setStateProvince(sellerModel.getStateProvince());
    hyperwalletUser.setPostalCode(sellerModel.getPostalCode());
    hyperwalletUser.setCountry(sellerModel.getCountry());
    hyperwalletUser.setProgramToken(sellersHyperwalletApiConfig.getUserStoreTokens().get(sellerModel.getHyperwalletProgram()));
    hyperwalletUser.setToken(sellerModel.getToken());
    hyperwalletUser.setEmail(sellerModel.getEmail());
    hyperwalletUser.setBusinessRegistrationCountry(sellerModel.getCompanyRegistrationCountry());
    hyperwalletUser.setBusinessRegistrationStateProvince(sellerModel.getBusinessRegistrationStateProvince());
    hyperwalletUser.setBusinessRegistrationId(sellerModel.getCompanyRegistrationNumber());
    if (HyperwalletUser.ProfileType.INDIVIDUAL.equals(profileType)) {
        hyperwalletUser.setFirstName(sellerModel.getFirstName());
        hyperwalletUser.setLastName(sellerModel.getLastName());
        hyperwalletUser.setDateOfBirth(sellerModel.getDateOfBirth());
        hyperwalletUser.setCountryOfBirth(sellerModel.getCountryOfBirth());
        hyperwalletUser.setCountryOfNationality(sellerModel.getCountryOfNationality());
        hyperwalletUser.setPhoneNumber(sellerModel.getPhoneNumber());
        hyperwalletUser.setMobileNumber(sellerModel.getMobilePhone());
        hyperwalletUser.setAddressLine2(sellerModel.getAddressLine2());
        hyperwalletUser.setGovernmentId(sellerModel.getGovernmentId());
        hyperwalletUser.setPassportId(sellerModel.getPassportId());
        hyperwalletUser.setDriversLicenseId(sellerModel.getDriversLicenseId());
        hyperwalletUser.setBusinessOperatingName(sellerModel.getCompanyName());
        Optional.ofNullable(sellerModel.getGovernmentIdType()).map(Enum::name).map(HyperwalletUser.GovernmentIdType::valueOf).ifPresent(hyperwalletUser::setGovernmentIdType);
    }
    return hyperwalletUser;
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser)

Example 7 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.

the class HyperwalletSellerExtractServiceImplTest method pushDocuments_shouldReturnOnlySuccessfulKYCDocumentInfoModelAPICalls.

@Test
void pushDocuments_shouldReturnOnlySuccessfulKYCDocumentInfoModelAPICalls() {
    final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelOKStub = Mockito.spy(KYCDocumentSellerInfoModel.builder().clientUserId(CLIENT_USER_ID_ONE).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USR_TOKEN_ONE))).hyperwalletProgram(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HW_PROGRAM, EUROPE_HYPERWALLET_PROGRAM))).build());
    final KYCDocumentSellerInfoModel kycDocumentSellerInfoModelKOStub = Mockito.spy(KYCDocumentSellerInfoModel.builder().clientUserId(CLIENT_USER_ID_TWO).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USR_TOKEN_TWO))).hyperwalletProgram(List.of(new MiraklAdditionalFieldValue.MiraklValueListAdditionalFieldValue(KYCConstants.HW_PROGRAM, EUROPE_HYPERWALLET_PROGRAM))).build());
    when(kycDocumentSellerInfoModelOKStub.areDocumentsFilled()).thenReturn(true);
    when(kycDocumentSellerInfoModelKOStub.areDocumentsFilled()).thenReturn(true);
    when(kycDocumentInfoToHWVerificationDocumentExecutorMock.execute(kycDocumentSellerInfoModelOKStub)).thenReturn(List.of(uploadDataOneMock));
    when(kycDocumentInfoToHWVerificationDocumentExecutorMock.execute(kycDocumentSellerInfoModelKOStub)).thenReturn(List.of(uploadDataTwoMock));
    when(hyperwalletSDKServiceMock.getHyperwalletInstance(Mockito.anyString())).thenReturn(hyperwalletClientMock);
    doReturn(new HyperwalletUser()).when(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_ONE, List.of(uploadDataOneMock));
    doThrow(new HyperwalletException("Something went wrong")).when(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_TWO, List.of(uploadDataTwoMock));
    final List<KYCDocumentSellerInfoModel> result = testObj.pushProofOfIdentityAndBusinessSellerDocuments(List.of(kycDocumentSellerInfoModelOKStub, kycDocumentSellerInfoModelKOStub));
    verify(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_ONE, List.of(uploadDataOneMock));
    verify(hyperwalletClientMock).uploadUserDocuments(USR_TOKEN_TWO, List.of(uploadDataTwoMock));
    assertThat(result).containsExactly(markInfoAsSentToHyperwallet(kycDocumentSellerInfoModelOKStub));
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) KYCDocumentSellerInfoModel(com.paypal.kyc.model.KYCDocumentSellerInfoModel) Test(org.junit.jupiter.api.Test)

Example 8 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.

the class IndividualKYCBusinessStakeholderStatusExecutorNotificationStrategyTest method callHyperwalletSDKCatchingException_whenExceptionIsThrown_shouldReturnNull.

@Test
void callHyperwalletSDKCatchingException_whenExceptionIsThrown_shouldReturnNull() {
    when(hyperwalletMock.getUser(USER_TOKEN)).thenThrow(HyperwalletException.class);
    final HyperwalletUser hyperwalletUser = testObj.callHyperwalletSDKCatchingException(hyperwalletMock, USER_TOKEN);
    assertThat(hyperwalletUser).isNull();
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Test(org.junit.jupiter.api.Test)

Example 9 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.

the class IndividualKYCBusinessStakeholderStatusExecutorNotificationStrategyTest method getHyperWalletUser_shouldCallHyperwalletOnEachUserToken.

@Test
void getHyperWalletUser_shouldCallHyperwalletOnEachUserToken() {
    when(kycHyperwalletApiConfigMock.getUserStoreTokens()).thenReturn(USER_STORE_TOKENS);
    when(hyperwalletSDKService.getHyperwalletInstance(anyString())).thenReturn(hyperwalletMock);
    when(kycBusinessStakeholderStatusNotificationBodyModelMock.getUserToken()).thenReturn(USER_TOKEN);
    when(hyperwalletMock.getUser(USER_TOKEN)).thenReturn(hyperwalletUserMock);
    final HyperwalletUser result = testObj.getHyperWalletUser(kycBusinessStakeholderStatusNotificationBodyModelMock);
    verify(hyperwalletMock, times(2)).getUser(USER_TOKEN);
    assertThat(result).isEqualTo(hyperwalletUserMock);
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Test(org.junit.jupiter.api.Test)

Example 10 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.

the class IndividualKYCBusinessStakeholderStatusExecutorNotificationStrategyTest method callHyperwalletSDKCatchingException_shouldReturnHyperwalletUser.

@Test
void callHyperwalletSDKCatchingException_shouldReturnHyperwalletUser() {
    when(hyperwalletMock.getUser(USER_TOKEN)).thenReturn(hyperwalletUserMock);
    final HyperwalletUser result = testObj.callHyperwalletSDKCatchingException(hyperwalletMock, USER_TOKEN);
    assertThat(result).isEqualTo(hyperwalletUserMock);
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Test(org.junit.jupiter.api.Test)

Aggregations

HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)32 Test (org.testng.annotations.Test)15 HyperwalletApiClient (com.hyperwallet.clientsdk.util.HyperwalletApiClient)11 Test (org.junit.jupiter.api.Test)9 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)5 TypeReference (com.fasterxml.jackson.core.type.TypeReference)3 Hyperwallet (com.hyperwallet.clientsdk.Hyperwallet)3 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)2 IOException (java.io.IOException)2 Gson (com.google.gson.Gson)1 JOSEException (com.nimbusds.jose.JOSEException)1 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)1 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)1 File (java.io.File)1 ParseException (java.text.ParseException)1 JSONObject (net.minidev.json.JSONObject)1 JSONException (org.json.JSONException)1