Search in sources :

Example 31 with Location

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);
}
Also used : PublisherQueryLanguageServiceInterface(com.google.api.ads.admanager.axis.v202205.PublisherQueryLanguageServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) ResultSet(com.google.api.ads.admanager.axis.v202205.ResultSet)

Example 32 with Location

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);
}
Also used : PublisherQueryLanguageServiceInterface(com.google.api.ads.admanager.axis.v202205.PublisherQueryLanguageServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) ResultSet(com.google.api.ads.admanager.axis.v202205.ResultSet) DateTime(org.joda.time.DateTime)

Example 33 with Location

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.");
}
Also used : ReportDownloader(com.google.api.ads.admanager.axis.utils.v202205.ReportDownloader) ReportDownloadOptions(com.google.api.ads.admanager.axis.v202205.ReportDownloadOptions) ReportQuery(com.google.api.ads.admanager.axis.v202205.ReportQuery) ReportServiceInterface(com.google.api.ads.admanager.axis.v202205.ReportServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) ReportJob(com.google.api.ads.admanager.axis.v202205.ReportJob) File(java.io.File) URL(java.net.URL)

Example 34 with Location

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()));
}
Also used : ListLocationsResponse(com.google.container.v1beta1.ListLocationsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListLocationsRequest(com.google.container.v1beta1.ListLocationsRequest) Location(com.google.container.v1beta1.Location) Test(org.junit.Test)

Example 35 with Location

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));
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) LocationContext(org.openqa.selenium.html5.LocationContext) WebElement(org.openqa.selenium.WebElement) Location(org.openqa.selenium.html5.Location) Test(org.junit.jupiter.api.Test)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)8 Random (java.util.Random)8 ReportDownloader (com.google.api.ads.admanager.axis.utils.v202205.ReportDownloader)7 ReportDownloadOptions (com.google.api.ads.admanager.axis.v202205.ReportDownloadOptions)7 ReportJob (com.google.api.ads.admanager.axis.v202205.ReportJob)7 ReportQuery (com.google.api.ads.admanager.axis.v202205.ReportQuery)7 ReportServiceInterface (com.google.api.ads.admanager.axis.v202205.ReportServiceInterface)7 File (java.io.File)7 URL (java.net.URL)7 Location (org.openqa.selenium.html5.Location)7 PublisherQueryLanguageServiceInterface (com.google.api.ads.admanager.axis.v202205.PublisherQueryLanguageServiceInterface)6 ResultSet (com.google.api.ads.admanager.axis.v202205.ResultSet)6 Test (org.junit.Test)5 LocationContext (org.openqa.selenium.html5.LocationContext)5 WebElement (org.openqa.selenium.WebElement)3 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)3 AdUnitTargeting (com.google.api.ads.admanager.axis.v202108.AdUnitTargeting)2 GeoTargeting (com.google.api.ads.admanager.axis.v202108.GeoTargeting)2 InventoryTargeting (com.google.api.ads.admanager.axis.v202108.InventoryTargeting)2 Location (com.google.api.ads.admanager.axis.v202108.Location)2