use of com.google.api.ads.admanager.axis.v202111.Date in project algorithms-sedgewick-wayne by reneargento.
the class Exercise13 method main.
public static void main(String[] args) {
Date date = new Date(8, 3, 2016);
Exercise13 transaction = new Exercise13("Rene", date, 500);
StdOut.println(transaction);
StdOut.println("Expected: Rene spent 500.0 on 8/3/2016");
}
use of com.google.api.ads.admanager.axis.v202111.Date in project algorithms-sedgewick-wayne by reneargento.
the class Exercise14 method main.
public static void main(String[] args) {
Date date = new Date(8, 3, 2016);
Exercise14 transaction1 = new Exercise14("Rene", date, 500);
Exercise14 transaction2 = new Exercise14("Rene", date, 500);
Exercise14 transaction3 = new Exercise14("Argento", date, 600);
Exercise14 transaction4 = transaction3;
StdOut.println("Equals 1: " + transaction1.equals(transaction2) + " Expected: true");
StdOut.println("Equals 2: " + transaction2.equals(transaction1) + " Expected: true");
StdOut.println("Equals 3: " + transaction1.equals(transaction3) + " Expected: false");
StdOut.println("Equals 4: " + transaction3.equals(transaction4) + " Expected: true");
}
use of com.google.api.ads.admanager.axis.v202111.Date in project algorithms-sedgewick-wayne by reneargento.
the class Exercise33_RandomTransactions method generateRandomTransactions.
private Exercise21_ComparableTransactions[] generateRandomTransactions(int numberOfObjects) {
Exercise21_ComparableTransactions[] transactions = new Exercise21_ComparableTransactions[numberOfObjects];
for (int i = 0; i < numberOfObjects; i++) {
String who = "Client " + (i + 1);
int month = StdRandom.uniform(12) + 1;
int maxDay = month == 2 ? 28 : 30;
int day = StdRandom.uniform(maxDay) + 1;
int year = StdRandom.uniform(1900, 2018);
Date date = new Date(month, day, year);
double amount = (double) Math.round(StdRandom.uniform(0.0, 1000000.0) * 100) / 100;
Exercise21_ComparableTransactions transaction = new Exercise21_ComparableTransactions(who, date, amount);
transactions[i] = transaction;
}
return transactions;
}
use of com.google.api.ads.admanager.axis.v202111.Date in project algorithms-sedgewick-wayne by reneargento.
the class Exercise25_HashCache method main.
public static void main(String[] args) {
Exercise25_HashCache hashCache = new Exercise25_HashCache();
Transaction transaction = hashCache.new Transaction("Person 1", new Date(1, 10, 5), 1000);
StdOut.println(transaction.hashCode() + " Expected: Cache miss");
StdOut.println(transaction.hashCode() + " Expected: Cache hit");
StdOut.println(transaction.hashCode() + " Expected: Cache hit");
}
use of com.google.api.ads.admanager.axis.v202111.Date in project googleads-java-lib by googleads.
the class RunAdExchangeReport 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 the report's contents could not be written to a temp file.
* @throws InterruptedException if the thread was interrupted while waiting for the report to be
* ready.
*/
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session) 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.AD_EXCHANGE_DATE, Dimension.AD_EXCHANGE_COUNTRY_NAME });
reportQuery.setColumns(new Column[] { Column.AD_EXCHANGE_AD_REQUESTS, Column.AD_EXCHANGE_IMPRESSIONS, Column.AD_EXCHANGE_ESTIMATED_REVENUE });
// Run in pacific time.
reportQuery.setTimeZoneType(TimeZoneType.AD_EXCHANGE);
reportQuery.setAdxReportCurrency("EUR");
// Set the dynamic date range type or a custom start and end date.
reportQuery.setDateRangeType(DateRangeType.YESTERDAY);
// 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("adexchange-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.");
}
Aggregations