use of com.hyperwallet.clientsdk.model.HyperwalletBusinessStakeholder in project mirakl-hyperwallet-connector by paypal.
the class BusinessStakeHolderModelToHyperWalletBusinessStakeHolderConverterTest method convert_shouldReturnHyperWalletBusinessStakeHolder_whenStringValueIsNull.
@Test
void convert_shouldReturnHyperWalletBusinessStakeHolder_whenStringValueIsNull() {
when(businessStakeHolderModelMock.getFirstName()).thenReturn(null);
when(businessStakeHolderModelMock.getBusinessContact()).thenReturn(Boolean.TRUE);
when(businessStakeHolderModelMock.getDirector()).thenReturn(Boolean.FALSE);
when(businessStakeHolderModelMock.getUbo()).thenReturn(Boolean.FALSE);
when(businessStakeHolderModelMock.getSmo()).thenReturn(Boolean.TRUE);
when(businessStakeHolderModelMock.getMiddleName()).thenReturn(MIDDLE_NAME);
when(businessStakeHolderModelMock.getLastName()).thenReturn(LAST_NAME);
when(businessStakeHolderModelMock.getDateOfBirth()).thenReturn(DateUtil.convertToDate(DATE_OF_BIRTH, HyperWalletConstants.HYPERWALLET_DATE_FORMAT, TimeZone.getTimeZone("UTC")));
when(businessStakeHolderModelMock.getCountryOfBirth()).thenReturn(COUNTRY_OF_BIRTH);
when(businessStakeHolderModelMock.getCountryOfNationality()).thenReturn(COUNTRY_OF_NATIONALITY);
when(businessStakeHolderModelMock.getGender()).thenReturn(SellerGender.MALE);
when(businessStakeHolderModelMock.getPhoneNumber()).thenReturn(PHONE_NUMBER);
when(businessStakeHolderModelMock.getMobileNumber()).thenReturn(MOBILE_NUMBER);
when(businessStakeHolderModelMock.getEmail()).thenReturn(EMAIL);
when(businessStakeHolderModelMock.getGovernmentId()).thenReturn(GOVERNMENT_ID);
when(businessStakeHolderModelMock.getGovernmentIdType()).thenReturn(SellerGovernmentIdType.NATIONAL_ID_CARD);
when(businessStakeHolderModelMock.getDriversLicenseId()).thenReturn(DRIVERS_LICENSE_ID);
when(businessStakeHolderModelMock.getAddressLine1()).thenReturn(ADDRESS_LINE_1);
when(businessStakeHolderModelMock.getAddressLine2()).thenReturn(ADDRESS_LINE_2);
when(businessStakeHolderModelMock.getCity()).thenReturn(CITY);
when(businessStakeHolderModelMock.getStateProvince()).thenReturn(STATE_PROVINCE);
when(businessStakeHolderModelMock.getCountry()).thenReturn(COUNTRY);
when(businessStakeHolderModelMock.getPostalCode()).thenReturn(POSTAL_CODE);
final HyperwalletBusinessStakeholder result = testObj.convert(businessStakeHolderModelMock);
assertThat(result.getFirstName()).isNull();
assertThat(result.getIsBusinessContact()).isTrue();
assertThat(result.getIsDirector()).isFalse();
assertThat(result.getIsUltimateBeneficialOwner()).isFalse();
assertThat(result.getIsSeniorManagingOfficial()).isTrue();
assertThat(result.getMiddleName()).isEqualTo(MIDDLE_NAME);
assertThat(result.getLastName()).isEqualTo(LAST_NAME);
assertThat(result.getDateOfBirth()).isEqualTo(DateUtil.convertToDate(DATE_OF_BIRTH, HyperWalletConstants.HYPERWALLET_DATE_FORMAT, TimeZone.getTimeZone("UTC")));
assertThat(result.getCountryOfBirth()).isEqualTo(COUNTRY_OF_BIRTH);
assertThat(result.getCountryOfNationality()).isEqualTo(COUNTRY_OF_NATIONALITY);
assertThat(result.getGender().name()).isEqualTo(Gender.MALE.name());
assertThat(result.getPhoneNumber()).isEqualTo(PHONE_NUMBER);
assertThat(result.getMobileNumber()).isEqualTo(MOBILE_NUMBER);
assertThat(result.getEmail()).isEqualTo(EMAIL);
assertThat(result.getGovernmentId()).isEqualTo(GOVERNMENT_ID);
assertThat(result.getGovernmentIdType().name()).isEqualTo(NATIONAL_ID_CARD.name());
assertThat(result.getDriversLicenseId()).isEqualTo(DRIVERS_LICENSE_ID);
assertThat(result.getAddressLine1()).isEqualTo(ADDRESS_LINE_1);
assertThat(result.getAddressLine2()).isEqualTo(ADDRESS_LINE_2);
assertThat(result.getCity()).isEqualTo(CITY);
assertThat(result.getStateProvince()).isEqualTo(STATE_PROVINCE);
assertThat(result.getCountry()).isEqualTo(COUNTRY);
assertThat(result.getPostalCode()).isEqualTo(POSTAL_CODE);
}
use of com.hyperwallet.clientsdk.model.HyperwalletBusinessStakeholder in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletCreateBusinessStakeHolderServiceStrategy method execute.
/**
* Executes the business logic based on the content of
* {@code businessStakeHolderModel} and returns a {@link BusinessStakeHolderModel}
* class based on a set of strategies
* @param businessStakeHolderModel the businessStakeHolderModel object of type
* {@link BusinessStakeHolderModel}
* @return the converted object of type {@link BusinessStakeHolderModel}
*/
@Override
public BusinessStakeHolderModel execute(final BusinessStakeHolderModel businessStakeHolderModel) {
final HyperwalletBusinessStakeholder hyperWalletBusinessStakeHolder = businessStakeHolderModelHyperwalletBusinessStakeholderConverter.convert(businessStakeHolderModel);
try {
final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(businessStakeHolderModel.getHyperwalletProgram());
final HyperwalletBusinessStakeholder hyperWalletBusinessStakeHolderResponse = hyperwallet.createBusinessStakeholder(businessStakeHolderModel.getUserToken(), hyperWalletBusinessStakeHolder);
return businessStakeHolderModel.toBuilder().token(hyperWalletBusinessStakeHolderResponse.getToken()).justCreated(true).build();
} catch (final HyperwalletException e) {
log.error("Stakeholder not created for clientId [{}]", businessStakeHolderModel.getClientUserId());
log.error(HyperwalletLoggingErrorsUtil.stringify(e));
mailNotificationUtil.sendPlainTextEmail("Issue detected when creating business stakeholder in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Business stakeholder not created for clientId [%s]%n%s", businessStakeHolderModel.getClientUserId(), HyperwalletLoggingErrorsUtil.stringify(e)));
}
return null;
}
use of com.hyperwallet.clientsdk.model.HyperwalletBusinessStakeholder in project java-sdk by hyperwallet.
the class HyperwalletBusinessStakeholderTest method createBaseModel.
protected HyperwalletBusinessStakeholder createBaseModel() {
HyperwalletBusinessStakeholder stakeholder = new HyperwalletBusinessStakeholder();
Map<String, String> params = new HashMap<String, String>();
params.put("rel", "self");
List<HyperwalletLink> links = new ArrayList<HyperwalletLink>();
HyperwalletLink link = new HyperwalletLink();
link.setHref("https://api.sandbox.hyperwallet.com/rest/v4/users/business-stakeholders");
links.add(link);
HyperwalletVerificationDocument hyperWalletVerificationDocument = new HyperwalletVerificationDocument();
hyperWalletVerificationDocument.category("IDENTIFICATION").type("DRIVERS_LICENSE").status("NEW").country("AL");
List<HyperwalletVerificationDocument> hyperwalletVerificationDocumentList = new ArrayList<>();
hyperwalletVerificationDocumentList.add(hyperWalletVerificationDocument);
stakeholder.token("test-token").isBusinessContact(true).isDirector(true).isUltimateBeneficialOwner(true).isSeniorManagingOfficial(true).status(Status.ACTIVATED).verificationStatus(VerificationStatus.REQUIRED).createdOn(new Date()).profileType(ProfileType.INDIVIDUAL).firstName("TestEE").middleName("EE").lastName("TestEE").dateOfBirth(new Date()).countryOfBirth("US").countryOfNationality("US").gender(Gender.FEMALE).phoneNumber("3103322333").mobileNumber("31052341241").email("swerw@sefrew.com").governmentId("345232").governmentIdType(GovernmentIdType.PASSPORT).driversLicenseId("12345").addressLine1("456 Main St").addressLine2("45 Maine").city("San Jose").stateProvince("CA").country("US").postalCode("22222").documents(hyperwalletVerificationDocumentList).postalCode("22222").links(links);
return stakeholder;
}
use of com.hyperwallet.clientsdk.model.HyperwalletBusinessStakeholder in project mirakl-hyperwallet-connector by paypal.
the class HyperwalletBusinessStakeholderExtractServiceImpl method getKYCRequiredVerificationBusinessStakeHolders.
/**
* {@inheritDoc}
*/
@Override
public List<String> getKYCRequiredVerificationBusinessStakeHolders(final String hyperwalletProgram, final String userToken) {
final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstance(hyperwalletProgram);
final List<HyperwalletBusinessStakeholder> businessStakeholders = getBusinessStakeholders(userToken, hyperwallet);
return businessStakeholders.stream().filter(hyperwalletBusinessStakeholder -> REQUIRED.equals(hyperwalletBusinessStakeholder.getVerificationStatus())).map(HyperwalletBusinessStakeholder::getToken).collect(Collectors.toList());
}
use of com.hyperwallet.clientsdk.model.HyperwalletBusinessStakeholder in project mirakl-hyperwallet-connector by paypal.
the class BusinessStakeHolderModelToHyperWalletBusinessStakeHolderConverter method convert.
/**
* Method that retrieves a {@link BusinessStakeHolderModel} and returns a
* {@link HyperwalletBusinessStakeholder}
* @param source the source object {@link BusinessStakeHolderModel}
* @return the returned object {@link HyperwalletBusinessStakeholder}
*/
@Override
public HyperwalletBusinessStakeholder convert(final BusinessStakeHolderModel source) {
final HyperwalletBusinessStakeholder hyperwalletBusinessStakeholder = new HyperwalletBusinessStakeholder();
hyperwalletBusinessStakeholder.token(source.getToken());
hyperwalletBusinessStakeholder.setIsBusinessContact(source.getBusinessContact());
hyperwalletBusinessStakeholder.isDirector(source.getDirector());
hyperwalletBusinessStakeholder.isUltimateBeneficialOwner(source.getUbo());
hyperwalletBusinessStakeholder.isSeniorManagingOfficial(source.getSmo());
hyperwalletBusinessStakeholder.profileType(HyperwalletBusinessStakeholder.ProfileType.INDIVIDUAL);
hyperwalletBusinessStakeholder.setFirstName(source.getFirstName());
hyperwalletBusinessStakeholder.setMiddleName(source.getMiddleName());
hyperwalletBusinessStakeholder.setLastName(source.getLastName());
Optional.ofNullable(source.getDateOfBirth()).ifPresent(hyperwalletBusinessStakeholder::setDateOfBirth);
hyperwalletBusinessStakeholder.countryOfBirth(source.getCountryOfBirth());
hyperwalletBusinessStakeholder.setCountryOfNationality(source.getCountryOfNationality());
Optional.ofNullable(source.getGender()).ifPresent(gender -> hyperwalletBusinessStakeholder.setGender(EnumUtils.getEnum(HyperwalletBusinessStakeholder.Gender.class, gender.name())));
hyperwalletBusinessStakeholder.setPhoneNumber(source.getPhoneNumber());
hyperwalletBusinessStakeholder.setMobileNumber(source.getMobileNumber());
hyperwalletBusinessStakeholder.setEmail(source.getEmail());
hyperwalletBusinessStakeholder.setGovernmentId(source.getGovernmentId());
Optional.ofNullable(source.getGovernmentIdType()).ifPresent(sellerGovernmentIdType -> hyperwalletBusinessStakeholder.setGovernmentIdType(EnumUtils.getEnum(HyperwalletBusinessStakeholder.GovernmentIdType.class, sellerGovernmentIdType.name())));
hyperwalletBusinessStakeholder.setDriversLicenseId(source.getDriversLicenseId());
hyperwalletBusinessStakeholder.setAddressLine1(source.getAddressLine1());
hyperwalletBusinessStakeholder.setAddressLine2(source.getAddressLine2());
hyperwalletBusinessStakeholder.setCity(source.getCity());
hyperwalletBusinessStakeholder.setStateProvince(source.getStateProvince());
hyperwalletBusinessStakeholder.setCountry(source.getCountry());
hyperwalletBusinessStakeholder.setPostalCode(source.getPostalCode());
return hyperwalletBusinessStakeholder;
}
Aggregations