I'm trying to figure out if my users have a subscription (for instance, a Local Market subscription for Motors). How can I do this through the API?
Occasionally, the behavior of an application will change depending on what services a user is subscribed to. For instance, to list in certain categories under certain conditions, a Motors listing may require a Local Market subscription. This information is easy to obtain, provided you have a token from your user.
The relevant call in this case is GetUser. To obtain information about a specific user, you generally include the <UserID> parameter for the user you wish to obtain information about. By default, if you omit this parameter, the GetUser call will return information about the user making the call. As we will see in a moment, we won't actually need <UserID> in this case, since we will need the user's token to make the call.
Another thing to watch out for when using this call is that if you make the call as a user other than the one specified in the <RequesterCredentials>, you won't be able to find out what services they are subscribed to - this is 'private' info. To illustrate the point more clearly, consider the following example:
UserA is subscribed to 'Local Market'. DeveloperB makes a GetUser call using his own token, specifying UserA in the <UserID> block. The GetUser call will return information about UserA, but not 'private info', such as subscription information. Instead, DeveloperB should make the GetUser call using the token he obtained when UserA proceeded through Auth & Auth. When DeveloperB makes a GetUser call when UserA's token in the <RequesterCredentials> node, he will be able to obtain subscription information from User A.
With that in mind, we can make the following call to retrieve information about a user's subscriptions:
Note that since we are making the call with your user's token (UserA, using the above example), we don't even need to include the <UserID> parameter for the GetUser call in this case. Once you make this call, you'll get a result that looks like the following:
If you look at the response, you can see that this user has several subscriptions. The <EBaySubscription> and <UserSubscription> nodes indicate the subscriptions that this user has. You can use the existence and content of these nodes to take appropriate action in your application.