Add Helper Functions

In this task, you will add two helper functions to query a subscriber and purchase an offer.

Procedure

  1. Edit the DemoServices.java file.
  2. 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.

  3. 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 uses m_api which is an instance of the code-generated SubMan API and is managed by the JsonStubs class.

  4. Save the file.

What to do next

Change the implementation method.