use of com.google.api.ads.adwords.axis.v201809.cm.Asset in project googleads-java-lib by googleads.
the class AddMultiAssetResponsiveDisplayAd method createAssetLinkForImageAsset.
/**
* Creates an {@link AssetLink} containing a {@link ImageAsset} with the specified asset ID.
*
* @param assetId ID of the image asset.
* @return a new {@link AssetLink}
*/
private static AssetLink createAssetLinkForImageAsset(long assetId) {
AssetLink assetLink = new AssetLink();
ImageAsset imageAsset = new ImageAsset();
imageAsset.setAssetId(assetId);
assetLink.setAsset(imageAsset);
return assetLink;
}
use of com.google.api.ads.adwords.axis.v201809.cm.Asset in project googleads-java-lib by googleads.
the class AddResponsiveSearchAd method createAssetLinkForText.
/**
* Creates an {@link AssetLink} containing a {@link TextAsset} with the specified string.
*
* @param text the text for the text asset.
* @return a new {@link AssetLink}
*/
private static AssetLink createAssetLinkForText(String text) {
AssetLink assetLink = new AssetLink();
TextAsset textAsset = new TextAsset();
textAsset.setAssetText(text);
assetLink.setAsset(textAsset);
return assetLink;
}
use of com.google.api.ads.adwords.axis.v201809.cm.Asset in project googleads-java-lib by googleads.
the class GetAllImageAssets method runExample.
/**
* Runs the example.
*
* @param adWordsServices the services factory.
* @param session the session.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
*/
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session) throws RemoteException {
// Get the AdGroupAdService.
AssetServiceInterface assetService = adWordsServices.get(session, AssetServiceInterface.class);
int offset = 0;
boolean morePages = true;
// Create the selector.
SelectorBuilder builder = new SelectorBuilder();
Selector selector = builder.fields(AssetField.AssetName, AssetField.AssetStatus, AssetField.ImageFileSize, AssetField.ImageWidth, AssetField.ImageHeight, AssetField.ImageFullSizeUrl).offset(offset).limit(PAGE_SIZE).equals(AssetField.AssetSubtype, AssetType.IMAGE.getValue()).build();
int totalEntries = 0;
while (morePages) {
// Get the image assets.
AssetPage page = assetService.get(selector);
// Display the results.
if (page.getEntries() != null && page.getEntries().length > 0) {
totalEntries = page.getTotalNumEntries();
int i = selector.getPaging().getStartIndex();
for (Asset asset : page.getEntries()) {
System.out.printf("%d) Image asset with ID %d, name '%s', and status '%s' was found.%n", i, asset.getAssetId(), asset.getAssetName(), asset.getAssetStatus());
}
}
offset += PAGE_SIZE;
selector = builder.increaseOffsetBy(PAGE_SIZE).build();
morePages = offset < page.getTotalNumEntries();
}
System.out.printf("Found %d image assets.%n", totalEntries);
}
Aggregations