/
Subscription Service (java)
NOTE: Trivore ID Documentation has moved to https://trivoreid.com
The content on this site IS OUT OF DATE!
This space has been archived!
Please go ahead to the new site!
Subscription Service (java)
Wrapper for '/subscription' endpoint
List of all options:
Subscriptions management
Subscription's Periods management
Initialize service
TrivoreID sdk = TrivoreID.mgmtApiClient();
SubscriptionServiceImpl subscriptionService = new SubscriptionServiceImpl(sdk.subscriptionService());
Subscriptions and Periods management
// Get list of all subscriptions.
Page<Subscription> page = subscriptionService.getAll();
// Apply filter
Filter filter = Filter.equal("customFields.key1", "value1");
page = subscriptionService.getAll(new Criteria(filter));
// Create new Subscription
Subscription subscription = new Subscription();
subscription.setSubscriberId("exampleUserId");
// This method returns new subscription object with the generated ID
subscription = subscriptionService.create(subscription);
String subscriptionId = subscription.getId();
// Modify subscription
subscription.getCustomFields().put("key1", "value1");
subscription.getCustomFields().put("key2", 2);
subscriptionService.update(subscription);
// Get subscription
subscription = api.subscription_service.get(subscriptionId)
// Terminate subscription
subscription = subscriptionService.terminate(subscriptionId);
Subscription period management
// Create, Update and Get the subscription's period
Period period = new Period();
period.setExternalId("test");
period = subscriptionService.createPeriod(subscriptionId, period);
String periodId = period.getId();
period.getCustomFields().put("key1", "periodValue");
period.getCustomFields().put("key2", 22);
subscriptionService.updatePeriod(subscriptionId, period);
period = subscriptionService.getPeriod(subscriptionId, periodId);