use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletUpdateBusinessStakeHolderServiceStrategy 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 {
log.info("Updating stakeholder [{}] for user [{}]", hyperWalletBusinessStakeHolder.getToken(), businessStakeHolderModel.getUserToken());
final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstanceByHyperwalletProgram(businessStakeHolderModel.getHyperwalletProgram());
hyperwallet.updateBusinessStakeholder(businessStakeHolderModel.getUserToken(), hyperWalletBusinessStakeHolder);
return businessStakeHolderModel;
} catch (final HyperwalletException e) {
log.error("Stakeholder not updated for clientId [{}]", businessStakeHolderModel.getClientUserId());
log.error(HyperwalletLoggingErrorsUtil.stringify(e));
mailNotificationUtil.sendPlainTextEmail("Issue detected when updating business stakeholder in Hyperwallet", String.format(ERROR_MESSAGE_PREFIX + "Business stakeholder not updated for clientId [%s]%n%s", businessStakeHolderModel.getClientUserId(), HyperwalletLoggingErrorsUtil.stringify(e)));
}
return null;
}
use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class HyperWalletUpdateSellerServiceStrategy method createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl.
@Override
protected HyperwalletUser createOrUpdateUserOnHyperWalletAndUpdateItsTokenOnMirakl(final HyperwalletUser hyperwalletUser) {
final Hyperwallet hyperwallet = hyperwalletSDKService.getHyperwalletInstanceByProgramToken(hyperwalletUser.getProgramToken());
final HyperwalletUser updatedUser = hyperwallet.updateUser(hyperwalletUser);
log.info("Seller updated for seller with clientUserId [{}]", hyperwalletUser.getClientUserId());
return updatedUser;
}
use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class SellerHyperwalletSDKEncryptedServiceImplTest method getHyperwalletInstance_shouldReturnAnHyperwalletInstanceWithEncryptedOption.
@Test
void getHyperwalletInstance_shouldReturnAnHyperwalletInstanceWithEncryptedOption() {
when(sellersHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
when(sellersHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
when(sellersHyperwalletApiConfigMock.getServer()).thenReturn(SERVER);
final Hyperwallet result = testObj.getHyperwalletInstance(PROGRAM_TOKEN);
assertThat(result).hasFieldOrPropertyWithValue("apiClient.hyperwalletEncryption", hyperwalletEncryptionMock);
}
use of com.hyperwallet.clientsdk.Hyperwallet in project mirakl-hyperwallet-connector by paypal.
the class SellerHyperwalletSDKServiceImplTest method getHyperwalletInstanceByHyperwalletProgram_shouldReturnAnHyperwalletInstance.
@Test
void getHyperwalletInstanceByHyperwalletProgram_shouldReturnAnHyperwalletInstance() {
when(sellersHyperwalletApiConfigMock.getUserStoreTokens()).thenReturn(Map.of(HYPERWALLET_PROGRAM, PROGRAM_TOKEN));
when(sellersHyperwalletApiConfigMock.getUsername()).thenReturn(USER_NAME);
when(sellersHyperwalletApiConfigMock.getPassword()).thenReturn(PASSWORD);
when(sellersHyperwalletApiConfigMock.getServer()).thenReturn(SERVER);
final Hyperwallet result = testObj.getHyperwalletInstanceByHyperwalletProgram(HYPERWALLET_PROGRAM);
assertThat(result).hasFieldOrPropertyWithValue("programToken", PROGRAM_TOKEN).hasFieldOrPropertyWithValue("apiClient.username", USER_NAME).hasFieldOrPropertyWithValue("url", SERVER + "/rest/v4");
}
Aggregations