Add Helper Functions
In this task, you will add two helper functions to query a subscriber and purchase an offer.
Procedure
- Edit the DemoServices.java file.
-
Add the subscriber query helper function.
private SubscriberResponse query(String route, RestQueryTerm term, SubscriberQuery req) throws Exception { SubscriberResponse rsp = new SubscriberResponse(); JsonObject json = new JsonObject(); service_subscriber_query(route, json, term, req, rsp); return rsp; }
This function performs a subscriber query using the extended subscriber query operation service_subscriber_query which is part of the
JsonStubs
class. This method performs a standard SubMan query and then extends the returned data using pricing cache information. -
Add the offer purchase helper function.
private MtxResponsePurchase purchase( String route, MtxSubscriberSearchData searchData, MtxPurchasedOfferData offer) { MtxRequestSubscriberPurchaseOffer purchaseRequest = new MtxRequestSubscriberPurchaseOffer(); MtxResponsePurchase response = null; purchaseRequest.setSubscriberSearchData(searchData); purchaseRequest.appendOfferRequestArray(offer); response = m_api.subscriberPurchaseOffer(route, purchaseRequest); return response; }
This helper function performs an offer purchase. Note that the
response
usesm_api
which is an instance of the code-generated SubMan API and is managed by theJsonStubs
class. - Save the file.
What to do next
Change the implementation method.