Ottieni attributi (Java)
Descrizione
getAttributes() viene utilizzato per recuperare esperienze di sperimentazione e personalizzate da Target ed estrarre i valori degli attributi.
Metodo
getAttributes
Attributes TargetClient.getAttributes(TargetDeliveryRequest targetRequest, String ...mboxes)
Parametri
Nome
Tipo
Obbligatorio
Predefinito
Descrizione
targetRequest
TargetDeliveryRequest
Sì
None (Nessuno)
La stessa richiesta di destinazione utilizzata per Get Offers
mboxNames
array var-args
No
None (Nessuno)
Matrice var-args di nomi mbox
Risultato
Un oggetto Attributes è restituito da TargetClient.getAttributes() che dispone dei seguenti metodi:
Nome
Tipo
Descrizione
getBoolean(mboxName, key)
Booleano
Restituisce il valore per il nome mbox e la chiave attributo specificati
getString(mboxName, key)
Stringa
Restituisce il valore per il nome mbox e la chiave attributo specificati
getInteger(mboxName, key)
Intero
Restituisce il valore per il nome mbox e la chiave attributo specificati
getDouble(mboxName, key)
Doppio
Restituisce il valore per il nome mbox e la chiave attributo specificati
toMboxMap(mboxName)
Mappa
Restituisce una mappa semplice con coppie chiave-valore
getResponse()
TargetDeliveryResponse
Restituisce l’oggetto di risposta normalmente restituito da getOffers
Esempio
Java
ClientConfig clientConfig = ClientConfig.builder()
.client("acmeclient")
.organizationId("1234567890@AdobeOrg")
.build();
TargetClient targetJavaClient = TargetClient.create(clientConfig);
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder()
.context(new Context().channel(ChannelType.WEB))
.build();
Attributes offerAttributes = targetJavaClient.getAttributes(targetDeliveryRequest, "demo-engineering-flags");
//returns just the value of searchProviderId from the mbox offer
String searchProviderId = offerAttributes.getString("demo-engineering-flags", "searchProviderId");
//returns a simple Map representing the mbox offer
Map<String, Object> engineeringFlags = offerAttributes.toMboxMap("demo-engineering-flags");
// the value of engineeringFlags looks like this
// {
// "cdnHostname": "cdn.cloud.corp.net",
// "searchProviderId": 143,
// "hasLegacyAccess": false
// }
String assetUrl = "http://" + engineeringFlags.cdnHostname + "/path/to/asset";
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3