// using Management API client
TrivoreID id = TrivoreID.mgmtApiClient();
UserServiceImpl userService = new UserServiceImpl(id.userService());
WalletServiceImpl walletService = new WalletServiceImpl(id.walletService());
AccessControlServiceImpl accessControlService = new AccessControlServiceImpl(id.accessControlService());
AccessControl accessControl = new AccessControl();
accessControl.setTitle("Example");
// adding ID of the targer Management API client
accessControl.getApiClientIdWrite().add(id.getClientId());
accessControl.getApiClientIdRead().add(id.getClientId());
// getting the owner
User owner = userService.get("userId");
Wallet wallet = new Wallet();
wallet.setName("Example Name");
wallet.setCurrency("EUR"); // required field
wallet.setOwnerId(owner.getId()); // required field
wallet.getAccessControlIds().add(accessControl.getId());
wallet = walletService.create(wallet);
// now this Management API has access to modify/delete the wallet
wallet = walletService.update(wallet);
walletService.delete(wallet.getId());
|