DocumentazioneGuida per gli sviluppatori di Target

Ottieni attributi (.NET)

Ultimo aggiornamento: 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

TargetAttributes TargetClient.GetAttributes(TargetDeliveryRequest targetRequest, params string[] mboxes)

Parametri

NomeTipoObbligatorioPredefinitoDescrizione
targetRequestTargetDeliveryRequestNonulleLa stessa richiesta Target utilizzata per Ottieni offerte​
mboxNamesstringa parametri[]NonulleMatrice di parametri di nomi mbox

Risultato

Un oggetto TargetAttributes è stato restituito da TargetClient.GetAttributes() con le proprietà e i metodi seguenti:

Proprietà/MetodoTipo restituitoDescrizione
RispostaTargetDeliveryResponseRestituisce l'oggetto di risposta normalmente restituito da Get Offers
ToDictionaryIReadOnlyDictionaryRestituisce un dizionario di dizionari con coppie chiave-valore raggruppate per nomi mbox
ToMboxDictionary(mboxName)IReadOnlyDictionaryRestituisce un dizionario con coppie di valori chiave per la mbox fornita
GetBoolean(mboxName, key, defaultValue)booleanoRestituisce il valore per il nome mbox e la chiave attributo specificati
GetString(mboxName, key, defaultValue)stringaRestituisce il valore per il nome mbox e la chiave attributo specificati
GetInteger(mboxName, key, defaultValue)intRestituisce il valore per il nome mbox e la chiave attributo specificati
GetDouble(mboxName, key, defaultValue)doppioRestituisce il valore per il nome mbox e la chiave attributo specificati
GetValue(mboxName, key, defaultValue)TRestituisce il valore per il nome mbox e la chiave attributo specificati

Esempio

.NET

var targetClientConfig = new TargetClientConfig.Builder("acmeClient", "ABCDEF012345677890ABCDEF0@AdobeOrg")
    .Build();

var targetClient = TargetClient.Create(targetClientConfig);

var mboxRequests = new List<MboxRequest> { new (index: 1, name: "a1-serverside-ab") };

var targetDeliveryRequest = new TargetDeliveryRequest.Builder()
    .Build();

var offerAttributes = targetClient.GetAttributes(targetDeliveryRequest, "demo-engineering-flags");

//returns just the value of searchProviderId from the mbox offer
var searchProviderId = offerAttributes.GetString("demo-engineering-flags", "searchProviderId");

//returns a simple Dictionary representing the mbox offer
var engineeringFlags = offerAttributes.ToMboxDictionary("demo-engineering-flags");

//  the value of engineeringFlags looks like this
//  {
//      "cdnHostname": "cdn.cloud.corp.net",
//      "searchProviderId": 143,
//      "hasLegacyAccess": false
//  }

var assetUrl = $"http://{engineeringFlags["cdnHostname"]}/path/to/asset";
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3