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;
}
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));
}
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();
}
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);
}
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);
}
Aggregations