From 9a84df992ff274beb9921ef5f15465800aae6ebc Mon Sep 17 00:00:00 2001 From: Ishita Gambhir Date: Tue, 15 Oct 2024 12:46:16 +0530 Subject: [PATCH] update documentation for updatePropositionsWithCompletionHandler (#104) --- Documentation/api-reference.md | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/Documentation/api-reference.md b/Documentation/api-reference.md index 468e11a1..37772282 100644 --- a/Documentation/api-reference.md +++ b/Documentation/api-reference.md @@ -12,6 +12,7 @@ Refer to the [Getting Started Guide](getting-started.md). - [onPropositionsUpdate](#onPropositionsUpdate) - [resetIdentities](#resetIdentities) - [updatePropositions](#updatePropositions) +- [updatePropositionsWithCompletionHandler](#updatePropositionsWithCompletionHandler) ## Public classes @@ -184,6 +185,63 @@ Optimize.updatePropositions(decisionScopes, }); ``` +## updatePropositionsWithCompletionHandler + +This API dispatches an event for the Edge network extension to fetch decision propositions, for the provided decision scopes array, from the decisioning services enabled in the Experience Edge. The returned decision propositions are cached in-memory in the Optimize SDK extension and can be retrieved using `getPropositions` API. + +> [!TIP] +> Completion callback passed to `updatePropositions` supports network timeout and fatal errors returned by edge network along with fetched propositions data. The SDK's internal retry mechanism handles the recoverable HTTP errors. As a result, recoverable HTTP errors are not returned through this callback. + +### Java + +#### Syntax + +```java +public static void updatePropositions(final List decisionScopes, + final Map xdm, + final Map data, + final AdobeCallback> callback) +``` + +* _decisionScopes_ is a list of decision scopes for which propositions need updating. +* _xdm_ is a map containing additional xdm formatted data to be attached to the Experience Event. +* _data_ is a map containing additional freeform data to be attached to the Experience Event. +* _callback_ is an optional completion handler that is invoked at the completion of the edge request. `call` method is invoked with propositions map of type `Map`. If the callback is an instance of `AdobeCallbackWithOptimizeError`, and if the operation times out or an error occurs in retrieving propositions, the `fail` method is invoked with the appropriate [AEPOptimizeError](https://developer.adobe.com/client-sdks/edge/adobe-journey-optimizer-decisioning/api-reference/#aepoptimizeerror). _Note:_ In certain cases, both the success and failure callbacks may be triggered. To handle these cases, ensure that your implementation checks for both successful propositions and errors within the callback, as both may be present simultaneously. + +#### Example + +```java +final DecisionScope decisionScope1 = DecisionScope("xcore:offer-activity:1111111111111111", "xcore:offer-placement:1111111111111111", 2); +final DecisionScope decisionScope2 = new DecisionScope("myScope"); + +final List decisionScopes = new ArrayList<>(); +decisionScopes.add(decisionScope1); +decisionScopes.add(decisionScope2); + +Optimize.updatePropositions(decisionScopes, + new HashMap() { + { + put("xdmKey", "xdmValue"); + } + }, + new HashMap() { + { + put("dataKey", "dataValue"); + } + }, + new AdobeCallbackWithOptimizeError>() { + @Override + public void fail(AEPOptimizeError optimizeError) { + responseError = optimizeError; + } + + @Override + public void call(Map propositionsMap) { + responseMap = propositionsMap; + } + }); +``` + ## Public classes ### DecisionScope