use of com.google.api.ads.admanager.axis.v202202.HasDestinationUrlCreative in project googleads-java-lib by googleads.
the class UpdateCreatives method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param creativeId the ID of the creative to update.
* @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(AdManagerServices adManagerServices, AdManagerSession session, long creativeId) throws RemoteException {
// Get the CreativeService.
CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
// Create a statement to only select a single creative by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeId);
// Get the creative.
CreativePage page = creativeService.getCreativesByStatement(statementBuilder.toStatement());
Creative creative = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Only update the destination URL if it has one.
if (creative instanceof HasDestinationUrlCreative) {
HasDestinationUrlCreative hasDestinationUrlCreative = (HasDestinationUrlCreative) creative;
// Update the destination URL of the creative.
hasDestinationUrlCreative.setDestinationUrl("http://news.google.com");
// Update the creative on the server.
Creative[] creatives = creativeService.updateCreatives(new Creative[] { creative });
for (Creative updatedCreative : creatives) {
System.out.printf("Creative with ID %d and name '%s' was updated.%n", updatedCreative.getId(), updatedCreative.getName());
}
} else {
System.out.println("No creatives were updated.");
}
}
use of com.google.api.ads.admanager.axis.v202202.HasDestinationUrlCreative in project googleads-java-lib by googleads.
the class UpdateCreatives method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param creativeId the ID of the creative to update.
* @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(AdManagerServices adManagerServices, AdManagerSession session, long creativeId) throws RemoteException {
// Get the CreativeService.
CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
// Create a statement to only select a single creative by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeId);
// Get the creative.
CreativePage page = creativeService.getCreativesByStatement(statementBuilder.toStatement());
Creative creative = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Only update the destination URL if it has one.
if (creative instanceof HasDestinationUrlCreative) {
HasDestinationUrlCreative hasDestinationUrlCreative = (HasDestinationUrlCreative) creative;
// Update the destination URL of the creative.
hasDestinationUrlCreative.setDestinationUrl("http://news.google.com");
// Update the creative on the server.
Creative[] creatives = creativeService.updateCreatives(new Creative[] { creative });
for (Creative updatedCreative : creatives) {
System.out.printf("Creative with ID %d and name '%s' was updated.%n", updatedCreative.getId(), updatedCreative.getName());
}
} else {
System.out.println("No creatives were updated.");
}
}
use of com.google.api.ads.admanager.axis.v202202.HasDestinationUrlCreative in project googleads-java-lib by googleads.
the class UpdateCreatives method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param creativeId the ID of the creative to update.
* @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(AdManagerServices adManagerServices, AdManagerSession session, long creativeId) throws RemoteException {
// Get the CreativeService.
CreativeServiceInterface creativeService = adManagerServices.get(session, CreativeServiceInterface.class);
// Create a statement to only select a single creative by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeId);
// Get the creative.
CreativePage page = creativeService.getCreativesByStatement(statementBuilder.toStatement());
Creative creative = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Only update the destination URL if it has one.
if (creative instanceof HasDestinationUrlCreative) {
HasDestinationUrlCreative hasDestinationUrlCreative = (HasDestinationUrlCreative) creative;
// Update the destination URL of the creative.
hasDestinationUrlCreative.setDestinationUrl("http://news.google.com");
// Update the creative on the server.
Creative[] creatives = creativeService.updateCreatives(new Creative[] { creative });
for (Creative updatedCreative : creatives) {
System.out.printf("Creative with ID %d and name '%s' was updated.%n", updatedCreative.getId(), updatedCreative.getName());
}
} else {
System.out.println("No creatives were updated.");
}
}
Aggregations