DocumentazioneGuida per gli sviluppatori di Target

Ottieni attributi (Java)

20 luglio 2024
  • Argomenti:
  • APIs/SDKs

Creato per:

  • Sviluppatore

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

NomeTipoObbligatorioPredefinitoDescrizione
targetRequestTargetDeliveryRequestSìNone (Nessuno)La stessa richiesta di destinazione utilizzata per Get Offers​
mboxNamesarray var-argsNoNone (Nessuno)Matrice var-args di nomi mbox

Risultato

Un oggetto Attributes è restituito da TargetClient.getAttributes() che dispone dei seguenti metodi:

NomeTipoDescrizione
getBoolean(mboxName, key)BooleanoRestituisce il valore per il nome mbox e la chiave attributo specificati
getString(mboxName, key)StringaRestituisce il valore per il nome mbox e la chiave attributo specificati
getInteger(mboxName, key)InteroRestituisce il valore per il nome mbox e la chiave attributo specificati
getDouble(mboxName, key)DoppioRestituisce il valore per il nome mbox e la chiave attributo specificati
toMboxMap(mboxName)MappaRestituisce una mappa semplice con coppie chiave-valore
getResponse()TargetDeliveryResponseRestituisce 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