Edit in GitHubLog an issue

Get Attributes

Description#

getAttributes() is used to fetch experimentation and personalized experiences from Target and extract attribute values.

Method#

Copied to your clipboard
Attributes TargetClient.getAttributes(TargetDeliveryRequest targetRequest, String ...mboxes)

Parameters#

NameTypeRequiredDefaultDescription
targetRequestTargetDeliveryRequestYesNoneThe same target request as used for Get Offers​
mboxNamesvar-args arrayNoNoneA var-args array of mbox names

Result#

An Attributes object is returned from TargetClient.getAttributes() which has the following methods:

NameTypeDescription
getBoolean(mboxName, key)BooleanReturns the value for a specified mbox name and attribute key
getString(mboxName, key)StringReturns the value for a specified mbox name and attribute key
getInteger(mboxName, key)IntegerReturns the value for a specified mbox name and attribute key
getDouble(mboxName, key)DoubleReturns the value for a specified mbox name and attribute key
toMboxMap(mboxName)MapReturns a simple Map with key value pairs
getResponse()TargetDeliveryResponseReturns the response object normally returned by getOffers

Example#

Copied to your clipboard
1ClientConfig clientConfig = ClientConfig.builder()
2 .client("acmeclient")
3 .organizationId("1234567890@AdobeOrg")
4 .build();
5
6TargetClient targetJavaClient = TargetClient.create(clientConfig);
7
8TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder()
9 .context(new Context().channel(ChannelType.WEB))
10 .build();
11
12Attributes offerAttributes = targetJavaClient.getAttributes(targetDeliveryRequest, "demo-engineering-flags");
13
14//returns just the value of searchProviderId from the mbox offer
15String searchProviderId = offerAttributes.getString("demo-engineering-flags", "searchProviderId");
16
17//returns a simple Map representing the mbox offer
18Map<String, Object> engineeringFlags = offerAttributes.toMboxMap("demo-engineering-flags");
19
20// the value of engineeringFlags looks like this
21// {
22// "cdnHostname": "cdn.cloud.corp.net",
23// "searchProviderId": 143,
24// "hasLegacyAccess": false
25// }
26
27String assetUrl = "http://" + engineeringFlags.cdnHostname + "/path/to/asset";
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.