AgentQuickCaseOperationBuilder

since v11.18

An AgentQuickCaseOperationBuilder can be used to build a start or cancel operation for a quick case.

An example of a method which starts a quick case for the provided agent and the provided category and subject would look like this:

import com.novomind.ecom.api.iagent.action.AgentActionHandler;
import com.novomind.ecom.api.iagent.model.AgentQuickCase;
import com.novomind.ecom.api.iagent.model.Category;
import com.novomind.ecom.api.iagent.model.User;
import com.novomind.ecom.api.iagent.operation.quickcase.AgentQuickCaseCancelOperationResult;
import com.novomind.ecom.api.iagent.operation.quickcase.AgentQuickCaseOperationBuilder;
import com.novomind.ecom.api.iagent.operation.quickcase.AgentQuickCaseOperationBuilder.StartQuickCase;
import com.novomind.ecom.api.iagent.operation.quickcase.AgentQuickCaseStartOperation;
import com.novomind.ecom.api.iagent.operation.quickcase.AgentQuickCaseStartOperationResult;

@Inject
protected AgentActionHandler agentActionHandler;

public AgentQuickCase startAgentQuickCase(User user, Category category, String subject) {
  try {
    AgentQuickCaseOperationBuilder builder = agentActionHandler.getAgentQuickCaseOperationBuilder(user);
    StartQuickCase startQuickCase = builder.start();
    AgentQuickCaseStartOperation startOperation = startQuickCase.category(category).subject(subject).build();
    AgentQuickCaseStartOperationResult operationResult = startOperation.execute();
    return operationResult.getAgentQuickCase();
  } catch (WrongArgumentException e) {
    // WrongArgumentException if the user is not valid (e.g. is not an agent)
  } catch (ValidationException e) {
    // ValidationException if one of the provided attributes are not valid (e.g. null values)
  } catch (OperationFailedException e) {
    // OperationFailedException if the operation failed (e.g. user is not logged in as an agent)
  }
  return null;
}

Note that the returned AgentQuickCase can also be used to cancel the quick case for the agent by calling cancel(AgentQuickCase).