Obtener atributos (.NET)
Última actualización: 20 de julio de 2024
- Temas:
- APIs/SDKs
Creado para:
- Desarrollador
Descripción
GetAttributes()
se usa para recuperar experimentación y experiencias personalizadas de Target y extraer valores de atributos.
Método
getAttributes
TargetAttributes TargetClient.GetAttributes(TargetDeliveryRequest targetRequest, params string[] mboxes)
Parámetros
Nombre | Tipo | Requerido | Valor predeterminado | Descripción |
---|---|---|---|---|
targetRequest | TargetDeliveryRequest | No | null | Se usó la misma solicitud Target para Obtener ofertas |
mboxNames | params string[] | No | null | Matriz de parámetros de nombres de mbox |
Resultado
Se ha devuelto un objeto TargetAttributes
de TargetClient.GetAttributes()
que tiene las siguientes propiedades y métodos:
Propiedad/Método | Tipo de devolución | Descripción |
---|---|---|
Respuesta | TargetDeliveryResponse | Devuelve el objeto de respuesta normalmente devuelto por Obtener ofertas |
ToDictionary | IReadOnlyDictionary | Devuelve un diccionario de diccionarios con pares de valor clave agrupados por nombres de mbox |
ToMboxDictionary(mboxName) | IReadOnlyDictionary | Devuelve un diccionario con pares de valor clave para el mbox proporcionado |
GetBoolean(mboxName, key, defaultValue) | bool | Devuelve el valor de un nombre de mbox y una clave de atributo especificados |
GetString(mboxName, key, defaultValue) | string | Devuelve el valor de un nombre de mbox y una clave de atributo especificados |
GetInteger(mboxName, key, defaultValue) | int | Devuelve el valor de un nombre de mbox y una clave de atributo especificados |
GetDouble(mboxName, key, defaultValue) | doble | Devuelve el valor de un nombre de mbox y una clave de atributo especificados |
GetValue(mboxName, key, defaultValue) | T | Devuelve el valor de un nombre de mbox y una clave de atributo especificados |
Ejemplo
.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