fetchByAccount method returns one or more Entitlement objects associated with the specified Account object. These Entitlements may be associated through an AutoBill, or directly with the Account.
Use this method to look up entitlements for a specific customer. Use the frequency of customer access, to determine how often to make this call. For example, if a customer on a monthly Billing Plan logs into your service several times each day, it’s unnecessary and inefficient to make a call to Subscribe to look up their entitlements for every login.
Instead, cache the entitlements obtained from this call locally. The Entitlement objects with the active flag set to true thus obtained and locally stored can be considered valid until the endTimestamp date.
You may cache Entitlement objects locally on your site with the database table shown below. Here, the columns customer_id and entitlement_id form a joint primary key.
For example, to check the entitlements for customer
Jdoe1970, check if entries exist in the table for Jdoe1970 and then follow these steps in your application logic:
-
If entries exist, check if an entry exists in the table for the entitlement ID you need. If yes and if the
active_tilldate is today or in the future, allowJdoe1970access. If theactive_tilldate is in the past, callfetchByAccount()orfetchByEntitlementIdAndAccount()and specify the related entitlement ID (entitlement_id). Afterwards, update theJdoe1970table entries with the data in theEntitlement.objects returned, and check theactive_tilldate again. If it is notnulland is in the future, allowJdoe1970access. -
If no entries exist, call
fetchByAccount()and add entries to the entitlement cache table with the data in theEntitlement.objects returned. Next, check the entry for the entitlement ID you need forJdoe1970and theactive_tilldate. If that date is in the future, grantJdoe1970access. If no entry exists or if theactive_tilldate isnullor in the past,Jdoe1970does not have that specific entitlement.
Input
srd: sparse response description, a SOAP string (which must be a JSON object), in which you specify the elements you want returned.This parameter enables the calling system to constrain amethod call to return only components you specify. This gives you greater control over returned content, and improves response time within the Vindicia platform by reducing the processing needed for the call.
Some fields are required, either practically or in the WSDL, and will be returned regardless of the srd. A null srd returns the complete response.
account: the Account object for which to retrieve entitlements. Use the merchantAccountId or VID to identify the object.
showAll: a Boolean flag that, if set to true, causes fetchByAccount to return all the Entitlement. objects, including those that have expired. Otherwise, fetchByAccount returns only the active Entitlement. objects.
includeChildren: a Boolean flag that, if set to true, includes any children associated with this Account. If this flag is omitted, Subscribe will interpret it as false, and constructs the query without looking at any child’s account.
Output
return: an object of typeReturn that indicates the success or failure of the call.
entitlements: an array of one or more Entitlement objects whose Account object matches the input.

