use of com.google.api.ads.admanager.axis.v202202.Order in project googleads-java-lib by googleads.
the class RunDeliveryReportForOrder method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param orderId the ID of the order to run the report for.
* @throws ApiException if the API request failed with one or more service errors.
* @throws RemoteException if the API request failed due to other errors.
* @throws IOException if unable to write the response to a file.
* @throws InterruptedException if the thread is interrupted while waiting for the report to
* complete.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long orderId) throws IOException, InterruptedException {
// Get the ReportService.
ReportServiceInterface reportService = adManagerServices.get(session, ReportServiceInterface.class);
// Create report query.
ReportQuery reportQuery = new ReportQuery();
reportQuery.setDimensions(new Dimension[] { Dimension.DATE, Dimension.ORDER_ID });
reportQuery.setColumns(new Column[] { Column.AD_SERVER_IMPRESSIONS, Column.AD_SERVER_CLICKS, Column.AD_SERVER_CTR, Column.AD_SERVER_CPM_AND_CPC_REVENUE });
reportQuery.setDimensionAttributes(new DimensionAttribute[] { DimensionAttribute.ORDER_TRAFFICKER, DimensionAttribute.ORDER_START_DATE_TIME, DimensionAttribute.ORDER_END_DATE_TIME });
// Create statement to filter for an order.
StatementBuilder statementBuilder = new StatementBuilder().where("ORDER_ID = :orderId").withBindVariableValue("orderId", orderId);
// Set the filter statement.
reportQuery.setStatement(statementBuilder.toStatement());
// Set the start and end dates or choose a dynamic date range type.
reportQuery.setDateRangeType(DateRangeType.CUSTOM_DATE);
reportQuery.setStartDate(DateTimes.toDateTime("2013-05-01T00:00:00", "America/New_York").getDate());
reportQuery.setEndDate(DateTimes.toDateTime("2013-05-31T00:00:00", "America/New_York").getDate());
// Create report job.
ReportJob reportJob = new ReportJob();
reportJob.setReportQuery(reportQuery);
// Run report job.
reportJob = reportService.runReportJob(reportJob);
// Create report downloader.
ReportDownloader reportDownloader = new ReportDownloader(reportService, reportJob.getId());
// Wait for the report to be ready.
reportDownloader.waitForReportReady();
// Change to your file location.
File file = File.createTempFile("delivery-report-", ".csv.gz");
System.out.printf("Downloading report to %s ...", file.toString());
// Download the report.
ReportDownloadOptions options = new ReportDownloadOptions();
options.setExportFormat(ExportFormat.CSV_DUMP);
options.setUseGzipCompression(true);
URL url = reportDownloader.getDownloadUrl(options);
Resources.asByteSource(url).copyTo(Files.asByteSink(file));
System.out.println("done.");
}
use of com.google.api.ads.admanager.axis.v202202.Order in project googleads-java-lib by googleads.
the class UpdateCreativeWrappers method runExample.
/**
* Runs the example.
*
* @param adManagerServices the services factory.
* @param session the session.
* @param creativeWrapperId the ID of the creative wrapper 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 creativeWrapperId) throws RemoteException {
// Get the CreativeWrapperService.
CreativeWrapperServiceInterface creativeWrapperService = adManagerServices.get(session, CreativeWrapperServiceInterface.class);
// Create a statement to only select a single creative wrapper by ID.
StatementBuilder statementBuilder = new StatementBuilder().where("id = :id").orderBy("id ASC").limit(1).withBindVariableValue("id", creativeWrapperId);
// Get the creative wrapper.
CreativeWrapperPage page = creativeWrapperService.getCreativeWrappersByStatement(statementBuilder.toStatement());
CreativeWrapper creativeWrapper = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
// Update the creative wrapper ordering.
creativeWrapper.setOrdering(CreativeWrapperOrdering.OUTER);
// Update the creative wrapper on the server.
CreativeWrapper[] creativeWrappers = creativeWrapperService.updateCreativeWrappers(new CreativeWrapper[] { creativeWrapper });
for (CreativeWrapper updatedCreativeWrapper : creativeWrappers) {
System.out.printf("Creative wrapper with ID %d and wrapping order '%s' was updated.%n", updatedCreativeWrapper.getId(), updatedCreativeWrapper.getOrdering());
}
}
use of com.google.api.ads.admanager.axis.v202202.Order in project googleads-java-lib by googleads.
the class StatementBuilderTest method testOrderBy.
@Test
public void testOrderBy() {
StatementBuilder statementBuilder = new StatementBuilder();
Statement statement = statementBuilder.orderBy("id ASC").toStatement();
assertEquals("ORDER BY id ASC", statement.getQuery());
}
use of com.google.api.ads.admanager.axis.v202202.Order in project googleads-java-lib by googleads.
the class StatementBuilderTest method testOrderBy_stripsOrderBy.
@Test
public void testOrderBy_stripsOrderBy() {
StatementBuilder statementBuilder = new StatementBuilder();
Statement statement = statementBuilder.orderBy("ORDER BY id ASC").toStatement();
assertEquals("ORDER BY id ASC", statement.getQuery());
}
use of com.google.api.ads.admanager.axis.v202202.Order in project pwinty-java-sdk by OddPrints.
the class OrderUpdater method updateAddress.
public void updateAddress(int orderIdToUpdate) {
Pwinty pwinty = getPwinty(environment);
System.out.println(pwinty.getOrder(orderIdToUpdate));
Order order = pwinty.getOrder(orderIdToUpdate);
order.setRecipientName("");
order.setAddress1("");
order.setAddress2("");
order.setAddressTownOrCity("");
order.setStateOrCounty("");
order.setPostalOrZipCode("");
}
Aggregations