com.ibm.commerce.subscription.facade.client

Class SubscriptionFacadeClient



  • public class SubscriptionFacadeClient
    extends AbstractSubscriptionFacadeClient

    This class provides common methods that this and other utility class to the Subscription facade can use. This class also provides a set of convenient Java API to represent particular Subscription operations. This set of Java API also include APIs for Web based requests to transform the name value pair request into the appropriate request documents. It also provides a set of methods which are used by the order component to create subscriptions and recurring orders. These methods are not similar to the traditional web methods in terms of the map they receive as input and should not be called directly from the web.

    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM Copyright notice field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • SubscriptionFacadeClient

        public SubscriptionFacadeClient()
        Creates an instance of the client to communicate with the Subscription facade.
      • SubscriptionFacadeClient

        public SubscriptionFacadeClient(BusinessContextType businessContext,
                                        javax.security.auth.callback.CallbackHandler callbackHandler)
        Creates an instance of the client to communicate with the Subscription facade.
        Parameters:
        businessContext - The default business context to associate with the messages when making requests.
        callbackHandler - Used for authentication purposes so the controller can give the authentication information to the transport when required.
    • Method Detail

      • createRecurringOrder

        public java.util.Map createRecurringOrder(java.util.Map inputParameters)
                                           throws SubscriptionException
        Creates a recurring order. This method transforms the given map of input parameters to a ProcessSubscription request with action code as Create.The SubscriptionType object are built using the buildSubscriptionDataObject method. The following parameters are mandatory in the input map.
        • orderId - The parent Order ID of the recurring order.
        • fulfillmentSchedule - A map containing fulfillment schedule for the recurring order. Refer to buildFulfillmentSchedule(Map, Boolean, String) for the parameters expected in the map.
        • totalCost - The total cost of the recurring order
        • currency - The currency of the recurring order
        • state - The state of the recurring order.

        The following parameters are optional depending on the recurring order being placed.

        • paymentSchedule - A map containing the payment schedule for the recurring order being placed. If not provided, this is assumed to be same as fulfillment schedule. Refer to buildPaymentSchedule(Map, Boolean, String) for the parameters expected in the map.
        • description - A textual description of the recurring order as provided by the customer.

        The following code demonstrates sample data that is accepted
                Map parameters = new HashMap();
                
              parameters.put("currency", new String[] {"USD"});
              parameters.put("totalCost", new String[] {"300.00"});
              parameters.put("orderId", new String[] {"10003"});
              parameters.put("state", "Active");
          
                Map ffmScheduleMap = new HashMap();
                ffmScheduleMap.put("startDate", new String[] {"2010-10-16T07:32:48.437Z"});     
                ffmScheduleMap.put("timePeriod", new String[] {"100"}); 
                ffmScheduleMap.put("timePeriodUOM", new String[] {"DAY"});       
              ffmScheduleMap.put("ffmFrequency", new String[] {"12"});  
                ffmScheduleMap.put("fulfillmentFrequencyUOM", new String[] {"DAY"});
              ffmScheduleMap.put("numOfFulfillments", new String[] {"100"});
              parameters.put("fulfillmentSchedule",ffmScheduleMap);
          
              Map paymentScheduleMap = new HashMap();
                paymentScheduleMap.put("paymentFrequency", new String[] {"15"});        
                paymentScheduleMap.put("paymentFrequencyUOM", new String[] {"DAY"});
                parameters.put("paymentSchedule",paymentScheduleMap);
        
         
        Parameters:
        inputParameters - The map of input parameters
        Returns:
        The response map populated by populateSubscriptionResponse method.
        Throws:
        SubscriptionException - When the operation was not successful.
        See Also:
        SubscriptionFacadeClient#buildSubscriptionDataObject(Map, Boolean, String)}
      • createSubscriptions

        public java.util.Map createSubscriptions(java.util.Map inputParameters)
                                          throws SubscriptionException
        Creates the subscription entry for all the subscription items that are present in the order . This method transforms the given map of input parameters to a ProcessSubscription request with action code as Create. For all the subscription items in the map, this method creates separate SubscriptionType objects and associates separate action expressions for each of them. The SubscriptionType objects are built using the buildSubscriptionDataObject method. The following parameters are mandatory in the input map.
        • orderId - The parent Order ID of the subscription order.
        • subscriptionItems - A list of maps which contains information about the subscription item present in the order.

        Each map in the subscription items list provides all the details of the item. The details provided are:

        • fulfillmentSchedule - The fulfillment schedule of the item. Refer to buildFulfillmentSchedule(Map, Boolean, String) for the parameters expected in the map.
        • paymentSchedule - The payment schedule of the item. If the payment is up front, the payment schedule must indicate that. If the payment schedule is not provided, it is assumed to be same as fulfillment schedule. Refer to buildPaymentSchedule(Map, Boolean, String) for the parameters expected in the map.
        • state - The state of the subscription.
        • subscriptionType - The subscription type code for the subscription.
        • orderItemId - The order item ID of the subscription item.
        • catalogEntryId - The catalog entry ID of the subscription item.
        • quantity - The quantity of the subscription item. If not provided, the default quantity is assumed to be one.

        The following code demonstrates sample data that is accepted
                          
           Map parameters = new HashMap();               
           List subscriptionItems = new ArrayList();
        
           Map subscriptionItem = new HashMap();
           subscriptionItem.put("currency", new String[] {"USD"});
           subscriptionItem.put("totalCost", new String[] {"200.00"});
           subscriptionItem.put("quantity", new String[] {"2"});
           subscriptionItem.put("catalogEntryId", new String[] {"10005"});
           subscriptionItem.put("orderItemId", new String[] {"10004"});
           subscriptionItem.put("state", "Active");
                   
           Map ffmScheduleMap = new HashMap();
           ffmScheduleMap.put("startDate", new String[] {"2010-10-16T07:32:48.437Z"});  
           ffmScheduleMap.put("timePeriod", new String[] {"100"});      
           ffmScheduleMap.put("timePeriodUOM", new String[] {"DAY"});    
           ffmScheduleMap.put("ffmFrequency", new String[] {"12"});     
           ffmScheduleMap.put("fulfillmentFrequencyUOM", new String[] {"DAY"});
           ffmScheduleMap.put("numOfFulfillments", new String[] {"100"});
           subscriptionItem.put("fulfillmentSchedule",ffmScheduleMap);
                   
           Map paymentScheduleMap = new HashMap();
           paymentScheduleMap.put("paymentFrequency", new String[] {"15"});     
           paymentScheduleMap.put("paymentFrequencyUOM", new String[] {"DAY"});
           subscriptionItem.put("paymentSchedule",paymentScheduleMap);
        
           subscriptionItems.add(subscriptionItem);
           
           parameters.put("subscriptionItems",subscriptionItems);
           parameters.put("orderId",new String[] {"20001"});
         
        Parameters:
        inputParameters - The map of input parameters
        Returns:
        The response map populated by populateSubscriptionResponse method.
        Throws:
        SubscriptionException - When the operation was not successful.
        See Also:
        SubscriptionFacadeClient#buildSubscriptionDataObject(Map, Boolean, String)} {@link SubscriptionFacadeClient#buildSubscriptionPurchaseDetails(Map, Boolean, String)}
      • activateSubscription

        public java.util.Map activateSubscription(java.util.Map inputParameters)
                                           throws SubscriptionException
        Activates a subscription or recurring order. This method transforms the given map of input parameters to a ProcessSubscription request with action code as Activate. The following parameters are mandatory in the input map.
        • subscriptionId - The subscriptionId of the recurring order or subscription. If the subscriptionId is not available, the orderId is mandatory for recurring order. For a subscription, orderId and orderItemId are mandatory.

        The following code demonstrates the use this API
              SubscriptionFacadeClient client = new SubscriptionFacadeClient();
                Map map = new HashMap();
                map.put("subscriptionId", new String[] {"10101"});      
                client.activateSubscription(map);
                

        The following code demonstrates the use of this API in case of a subscription order, without providing the subscriptionId
          SubscriptionFacadeClient client = new SubscriptionFacadeClient();
                Map map = new HashMap();
                map.put("orderId", new String[] {"1003"});
                map.put("orderItemId", new String[] {"1002"});  
                client.activateSubscription(map);
                
        Parameters:
        inputParameters - inputParameters The map of input parameters
        Returns:
        The response map populated by populateSubscriptionResponse method.
        Throws:
        SubscriptionException - When the operation was not successful.
      • cancelSubscription

        public java.util.Map cancelSubscription(java.util.Map inputParameters)
                                         throws SubscriptionException
        Cancels a subscription. This method transforms the given map of input parameters to a ProcessSubscription request with action code as Cancel. The below parameter is mandatory in the input map.
        • subscriptionId - The subscription ID of the recurring order.

        The following code demonstrates how to use this API
          SubscriptionFacadeClient client = new SubscriptionFacadeClient();
                Map map = new HashMap();
                map.put("subscriptionId", new String[] {"10101"});      
                client.cancelSubscription(map);
                
        Parameters:
        inputParameters - The map of input parameters
        Returns:
        The response map populated by populateSubscriptionResponse method.
        Throws:
        SubscriptionException - When the operation was not successful.