A workflow defines the action an application should offer the user for a particular tag, such as purchasing a product or claiming a coupon.

Each workflow includes all information required to display the actions (such as the product information) to the user.

After obtaining the tag, use the WorkflowManager to retrieve the workflow information for the tag.

Note: For those using RxJava, all the methods described below are available in RxWorkflowManager


Workflow Types


The WorkflowManager will return one of the following workflow types:

Product
A workflow for a single product that can be purchased immediately or saved in a basket for later.

Basket
A workflow for a 'TemporaryBasket' containing a set of items that can be purchased.

Act
A worfklow for an 'Act' containing custom information required by a merchant as part of a "Call to action".

Catalog
A workflow for a catalog which contains products for review, selection and purchase.


Retrieving a Workflow


  1. Retrieve an instance of WorkflowManager:
WorkflowManager workflowManager = ManagerFactory.getInstance().getWorkflowManager();

  1. Get the workflow using a tag:
workflowManager.getWorkflow(tag, new PowaTagCallback<Workflow>() {
	public void onSuccess(Workflow workflow) {
		// Determine the workflow type
	}
	public void onError(PowaTagException exception) {
	}
});

Determining the Workflow Type


  1. Use the WorkflowType convertion methods to convert the generic workflow object to the correct workflow subclass:
switch (workflow.getWorkflowType()) {
	case PRODUCT:
		ProductWorkflow productWorkflow = WorkflowType.asProductWorkflow(workflow);
		Product product = productWorkflow.getProduct();
		break;
	case BASKET:
		TemporaryBasketWorkflow basketWorkflow = WorkflowType.asBasketWorkflow(workflow);
		TemporaryBasket basket = basketWorkflow.getBasket();
		break;
	case ACT:
		ActWorkflow actWorkflow = WorkflowType.asActWorkflow(workflow);
		Act act = actWorkflow.getAct();
		break;
	case CATALOG:
		CatalogWorkflow catalogWorkflow = WorkflowType.asCatalogWorkflow(workflow);
		Catalog catalog = catalogWorkflow.getCatalog();
		break;	   
}

Next Steps

Depending on the type of workflow returned, you can navigate to the following sections for implementation details:

ProductWorkflow - review the Products page
TemporaryBasketWorkflow - review the Baskets page
ActWorkflow - review the Acts page
CatalogWorkflow - review the Catalogs page