Search in sources :

Example 6 with Asset

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;
}
Also used : AssetLink(com.google.api.ads.adwords.axis.v201809.cm.AssetLink) ImageAsset(com.google.api.ads.adwords.axis.v201809.cm.ImageAsset)

Example 7 with Asset

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;
}
Also used : TextAsset(com.google.api.ads.adwords.axis.v201809.cm.TextAsset) AssetLink(com.google.api.ads.adwords.axis.v201809.cm.AssetLink)

Example 8 with Asset

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);
}
Also used : SelectorBuilder(com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder) Asset(com.google.api.ads.adwords.axis.v201809.cm.Asset) AssetServiceInterface(com.google.api.ads.adwords.axis.v201809.cm.AssetServiceInterface) AssetPage(com.google.api.ads.adwords.axis.v201809.cm.AssetPage) Selector(com.google.api.ads.adwords.axis.v201809.cm.Selector)

Aggregations

AssetLink (com.google.api.ads.adwords.axis.v201809.cm.AssetLink)5 AssetServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AssetServiceInterface)4 ImageAsset (com.google.api.ads.adwords.axis.v201809.cm.ImageAsset)4 AssetOperation (com.google.api.ads.adwords.axis.v201809.cm.AssetOperation)3 TextAsset (com.google.api.ads.adwords.axis.v201809.cm.TextAsset)3 AdGroupAd (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAd)2 AdGroupAdOperation (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdOperation)2 AdGroupAdReturnValue (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdReturnValue)2 AdGroupAdServiceInterface (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdServiceInterface)2 Asset (com.google.api.ads.adwords.axis.v201809.cm.Asset)2 ArrayList (java.util.ArrayList)2 Parameter (com.beust.jcommander.Parameter)1 AdWordsServices (com.google.api.ads.adwords.axis.factory.AdWordsServices)1 SelectorBuilder (com.google.api.ads.adwords.axis.utils.v201809.SelectorBuilder)1 AdGroupAdStatus (com.google.api.ads.adwords.axis.v201809.cm.AdGroupAdStatus)1 ApiError (com.google.api.ads.adwords.axis.v201809.cm.ApiError)1 ApiException (com.google.api.ads.adwords.axis.v201809.cm.ApiException)1 AssetPage (com.google.api.ads.adwords.axis.v201809.cm.AssetPage)1 AssetReturnValue (com.google.api.ads.adwords.axis.v201809.cm.AssetReturnValue)1 DisplayAdFormatSetting (com.google.api.ads.adwords.axis.v201809.cm.DisplayAdFormatSetting)1