use of com.google.api.ads.admanager.axis.v202205.Location in project googleads-java-lib by googleads.
the class GetLineItemsNamedLike method runExample.
/**
* Runs the example.
*
* @param adManagerServices 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.
* @throws IOException if unable to write the response to a file.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) throws IOException {
// Get the PublisherQueryLanguageService.
PublisherQueryLanguageServiceInterface pqlService = adManagerServices.get(session, PublisherQueryLanguageServiceInterface.class);
// Create statement to select all line items.
StatementBuilder statementBuilder = new StatementBuilder().select("Id, Name, Status").from("Line_Item").where("Name LIKE 'line item%'").orderBy("Id ASC").offset(0).limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
// Default for result sets.
ResultSet combinedResultSet = null;
ResultSet resultSet;
int i = 0;
do {
// Get line items like 'line item%'.
resultSet = pqlService.select(statementBuilder.toStatement());
// Combine result sets with previous ones.
combinedResultSet = combinedResultSet == null ? resultSet : Pql.combineResultSets(combinedResultSet, resultSet);
System.out.printf("%d) %d line items beginning at offset %d were found.%n", i++, resultSet.getRows() == null ? 0 : resultSet.getRows().length, statementBuilder.getOffset());
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (resultSet.getRows() != null && resultSet.getRows().length > 0);
// Change to your file location.
String filePath = File.createTempFile("Line-Items-Named-Like-", ".csv").toString();
// Write the result set to a CSV.
CsvFiles.writeCsv(Pql.resultSetToStringArrayList(combinedResultSet), filePath);
System.out.printf("Line items saved to: %s%n", filePath);
}
use of com.google.api.ads.admanager.axis.v202205.Location in project googleads-java-lib by googleads.
the class GetMcmEarnings method runExample.
/**
* Runs the example.
*
* @param adManagerServices 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(AdManagerServices adManagerServices, AdManagerSession session) throws IOException {
// Get the PublisherQueryLanguageService.
PublisherQueryLanguageServiceInterface pqlService = adManagerServices.get(session, PublisherQueryLanguageServiceInterface.class);
DateTime lastMonth = DateTime.now().minusMonths(1).withDayOfMonth(1);
// Create statement to select earnings data from the prior month.
StatementBuilder statementBuilder = new StatementBuilder().select("Month, ChildName, ChildNetworkCode, TotalEarningsCurrencyCode," + " TotalEarningsMicros, ParentPaymentCurrencyCode, ParentPaymentMicros," + " ChildPaymentCurrencyCode, ChildPaymentMicros, DeductionsMicros").from("mcm_earnings").where("Month = :month").orderBy("ChildNetworkCode").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("month", DateTimes.toDateTime(lastMonth).getDate());
// Default for result sets.
ResultSet combinedResultSet = null;
ResultSet resultSet;
int i = 0;
do {
// Get all earnings information.
resultSet = pqlService.select(statementBuilder.toStatement());
// Combine result sets with previous ones.
combinedResultSet = combinedResultSet == null ? resultSet : Pql.combineResultSets(combinedResultSet, resultSet);
System.out.printf("%d) %d rows beginning at offset %d were found.%n", i++, resultSet.getRows() == null ? 0 : resultSet.getRows().length, statementBuilder.getOffset());
statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
} while (resultSet.getRows() != null && resultSet.getRows().length > 0);
// Change to your file location.
String filePath = File.createTempFile("EarningsReport-", ".csv").toString();
// Write the result set to a CSV.
CsvFiles.writeCsv(Pql.resultSetToStringArrayList(combinedResultSet), filePath);
System.out.printf("Earnings information saved to: %s%n", filePath);
}
use of com.google.api.ads.admanager.axis.v202205.Location 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.v202205.Location in project java-container by googleapis.
the class ClusterManagerClientTest method listLocationsTest.
@Test
public void listLocationsTest() throws Exception {
ListLocationsResponse expectedResponse = ListLocationsResponse.newBuilder().addAllLocations(new ArrayList<Location>()).setNextPageToken("nextPageToken-1386094857").build();
mockClusterManager.addResponse(expectedResponse);
String parent = "parent-995424086";
ListLocationsResponse actualResponse = client.listLocations(parent);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockClusterManager.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListLocationsRequest actualRequest = ((ListLocationsRequest) actualRequests.get(0));
Assert.assertEquals(parent, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.api.ads.admanager.axis.v202205.Location in project selenium-webdriver-java by bonigarcia.
the class LocationContextSelJupTest method testLocationContext.
@Test
void testLocationContext(ChromeDriver driver) {
LocationContext location = (LocationContext) driver;
location.setLocation(new Location(27.5916, 86.5640, 8850));
driver.get("https://bonigarcia.dev/selenium-webdriver-java/geolocation.html");
driver.findElement(By.id("get-coordinates")).click();
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
WebElement coordinates = driver.findElement(By.id("coordinates"));
wait.until(ExpectedConditions.visibilityOf(coordinates));
}
Aggregations