Get VOUsageLicense object to assign subscription
DashThink opened this issue · 1 comments
Hi,
I am trying to assign subscription to all the user from 'XYZ' org. Am using addRevokeUser method. I am able to remove the subscription by sending VOUser list. But i am not able to get VOUsageLicense object to pass this method. How can i get this? Please suggest. any code snippet?
Hi @DashThink
not sure if I fully got your intention here. Note that subscriptions can only be assigned to existing users of the respective customer. Thus, condition in your case is that "'XYZ' org" is a customer of the supplier organization providing the service. Otherwise you should look for AccountService API to register a customer, as administrator of given supplier organization. See AccountService#registerCustomer respectively AccountService#registerKnownCustomer.
For adding all users your code should look something like following.
`
IdentityService id = connectAsSusbcriptionAdmin();
// Collect usage licenses
List<VOUsageLicense> licences = new ArrayList<VOUsageLicense>();
List<VOUserDetails> users = id.getUsersForOrganization();
for (VOUserDetails user : users) {
VOUsageLicense usageLicence = new VOUsageLicense();
usageLicence.setUser(user);
licences.add(usageLicence);
}
// Add users
SubscriptionService subService= ...;
subService.addRevokeUser(subscriptionId, licences, null);
`
Hope this is helpful for you.