本文整理汇总了Java中com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java ReportingConfiguration类的具体用法?Java ReportingConfiguration怎么用?Java ReportingConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReportingConfiguration类属于com.google.api.ads.adwords.lib.client.reporting包,在下文中一共展示了ReportingConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
/**
* Get an immutable adwords session from the authentication info.
*/
@Override
public ImmutableAdWordsSession authenticate() throws OAuthException, ValidationException {
// For easy processing, skip report header and summary (but keep column header).
ReportingConfiguration reportingConfig =
new ReportingConfiguration.Builder()
.skipReportHeader(true)
.skipColumnHeader(false)
.skipReportSummary(true)
.includeZeroImpressions(true)
.build();
return new AdWordsSession.Builder()
.withOAuth2Credential(getOAuth2Credential())
.withUserAgent(this.userAgent)
.withClientCustomerId(this.managerAccountId)
.withDeveloperToken(this.developerToken)
.withReportingConfiguration(reportingConfig)
.buildImmutable();
}
示例2: AdWordsSessionTest
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
public AdWordsSessionTest(boolean isImmutable) {
this.isImmutable = isImmutable;
this.credential = new Credential(BearerToken.authorizationHeaderAccessMethod());
this.reportingConfiguration =
new ReportingConfiguration.Builder().skipReportHeader(true).skipReportSummary(true).build();
this.allSettingsBuilder =
new AdWordsSession.Builder()
.withClientCustomerId("customer id")
.withDeveloperToken("developer token")
.withEndpoint("https://www.google.com")
.enablePartialFailure()
.enableValidateOnly()
.withOAuth2Credential(credential)
.withUserAgent("user agent")
.withReportingConfiguration(reportingConfiguration);
}
示例3: testBuilder_withReportingConfiguration
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
@Test
public void testBuilder_withReportingConfiguration() throws Exception {
ReportingConfiguration reportingConfiguration =
new ReportingConfiguration.Builder().skipReportHeader(true).skipReportSummary(true).build();
AdWordsSession adWordsSession =
build(
new AdWordsSession.Builder()
.withUserAgent("FooBar")
.withEndpoint("https://www.google.com")
.withOAuth2Credential(credential)
.withDeveloperToken("developerToken")
.withReportingConfiguration(reportingConfiguration));
ReportingConfiguration sessionReportingConfig = adWordsSession.getReportingConfiguration();
assertNotNull(
"reporting configuration should not be null when passed to the builder",
sessionReportingConfig);
}
示例4: createHeaders
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
/**
* Creates the http headers object for this request, populated from data in
* the session.
* @throws AuthenticationException If OAuth authorization fails.
*/
private HttpHeaders createHeaders(String reportUrl, String version)
throws AuthenticationException {
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAuthorization(
authorizationHeaderProvider.getAuthorizationHeader(session, reportUrl));
httpHeaders.setUserAgent(userAgentCombiner.getUserAgent(session.getUserAgent()));
httpHeaders.set("developerToken", session.getDeveloperToken());
httpHeaders.set("clientCustomerId", session.getClientCustomerId());
ReportingConfiguration reportingConfiguration = session.getReportingConfiguration();
if (reportingConfiguration != null) {
reportingConfiguration.validate(version);
if (reportingConfiguration.isSkipReportHeader() != null) {
httpHeaders.set("skipReportHeader",
Boolean.toString(reportingConfiguration.isSkipReportHeader()));
}
if (reportingConfiguration.isSkipColumnHeader() != null) {
httpHeaders.set("skipColumnHeader",
Boolean.toString(reportingConfiguration.isSkipColumnHeader()));
}
if (reportingConfiguration.isSkipReportSummary() != null) {
httpHeaders.set("skipReportSummary",
Boolean.toString(reportingConfiguration.isSkipReportSummary()));
}
if (reportingConfiguration.isIncludeZeroImpressions() != null) {
httpHeaders.set(
"includeZeroImpressions",
Boolean.toString(reportingConfiguration.isIncludeZeroImpressions()));
}
if (reportingConfiguration.isUseRawEnumValues() != null) {
httpHeaders.set(
"useRawEnumValues",
Boolean.toString(reportingConfiguration.isUseRawEnumValues()));
}
}
return httpHeaders;
}
示例5: from
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
/**
* Reads properties from the provided {@link Configuration} object.<br><br>
* Known properties:
* <ul>
* <li>api.adwords.clientCustomerId</li>
* <li>api.adwords.userAgent</li>
* <li>api.adwords.developerToken</li>
* <li>api.adwords.isPartialFailure</li>
* <li>api.adwords.endpoint</li>
* <li>api.adwords.reporting.skipHeader</li>
* <li>api.adwords.reporting.skipColumnHeader</li>
* <li>api.adwords.reporting.skipSummary</li>
* </ul>
*
* @param config
* @return Builder populated from the Configuration
*/
@Override
public Builder from(Configuration config) {
this.clientCustomerId = config.getString("api.adwords.clientCustomerId", null);
this.userAgent = config.getString("api.adwords.userAgent", null);
this.developerToken = config.getString("api.adwords.developerToken", null);
this.isPartialFailure = config.getBoolean("api.adwords.isPartialFailure", null);
this.endpoint = config.getString("api.adwords.endpoint", null);
// Only create a ReportConfiguration for this object if at least one reporting
// configuration config value is present.
Boolean isSkipReportHeader = config.getBoolean("api.adwords.reporting.skipHeader", null);
Boolean isSkipColumnHeader =
config.getBoolean("api.adwords.reporting.skipColumnHeader", null);
Boolean isSkipReportSummary = config.getBoolean("api.adwords.reporting.skipSummary", null);
Boolean isUseRawEnumValues =
config.getBoolean("api.adwords.reporting.useRawEnumValues", null);
Integer reportDownloadTimeout = config.getInteger("api.adwords.reportDownloadTimeout", null);
this.reportingConfiguration =
new ReportingConfiguration.Builder()
.skipReportHeader(isSkipReportHeader)
.skipColumnHeader(isSkipColumnHeader)
.skipReportSummary(isSkipReportSummary)
.useRawEnumValues(isUseRawEnumValues)
.reportDownloadTimeout(reportDownloadTimeout)
.build();
return this;
}
示例6: testReadPropertiesFromConfiguration
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
/** Tests that the builder correctly reads properties from a configuration. */
@Test
public void testReadPropertiesFromConfiguration() throws ValidationException {
PropertiesConfiguration config = new PropertiesConfiguration();
config.setProperty("api.adwords.clientCustomerId", "1234567890");
config.setProperty("api.adwords.userAgent", "FooBar");
config.setProperty("api.adwords.developerToken", "devTokendevTokendevTok");
config.setProperty("api.adwords.isPartialFailure", "false");
AdWordsSession session =
build(new AdWordsSession.Builder().from(config).withOAuth2Credential(credential));
assertEquals("1234567890", session.getClientCustomerId());
assertEquals("FooBar", session.getUserAgent());
assertEquals("devTokendevTokendevTok", session.getDeveloperToken());
assertFalse(session.isPartialFailure());
ReportingConfiguration reportingConfig = session.getReportingConfiguration();
assertNotNull("reporting configuration is null", reportingConfig);
// Verify that the ReportingConfiguration's attributes are set to the expected default value
// (null).
assertNull(
"include zero impressions is not null when no reporting options in config",
reportingConfig.isIncludeZeroImpressions());
assertNull(
"skip column header is not null, but no reporting options in config",
reportingConfig.isSkipColumnHeader());
assertNull(
"skip report header is not null, but no reporting options in config",
reportingConfig.isSkipReportHeader());
assertNull(
"skip report summary is not null, but no reporting options in config",
reportingConfig.isSkipReportSummary());
assertNull(
"use raw enum values is not null, but no reporting options in config",
reportingConfig.isUseRawEnumValues());
assertNull(
"download timeout is not null, but no reporting options in config",
reportingConfig.getReportDownloadTimeout());
}
示例7: runExample
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
public static void runExample(
AdWordsServicesInterface adWordsServices, AdWordsSession session, String reportFile)
throws Exception {
// Create query.
String query = "SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, "
+ "Impressions, Clicks, Cost FROM CRITERIA_PERFORMANCE_REPORT "
+ "WHERE Status IN [ENABLED, PAUSED] "
+ "DURING YESTERDAY";
// Optional: Set the reporting configuration of the session to suppress header, column name, or
// summary rows in the report output. You can also configure this via your ads.properties
// configuration file. See AdWordsSession.Builder.from(Configuration) for details.
// In addition, you can set whether you want to explicitly include or exclude zero impression
// rows.
ReportingConfiguration reportingConfiguration =
new ReportingConfiguration.Builder()
.skipReportHeader(false)
.skipColumnHeader(false)
.skipReportSummary(false)
// Set to false to exclude rows with zero impressions.
.includeZeroImpressions(true)
.build();
session.setReportingConfiguration(reportingConfiguration);
ReportDownloaderInterface reportDownloader =
adWordsServices.getUtility(session, ReportDownloaderInterface.class);
try {
// Set the property api.adwords.reportDownloadTimeout or call
// ReportDownloader.setReportDownloadTimeout to set a timeout (in milliseconds)
// for CONNECT and READ in report downloads.
ReportDownloadResponse response = reportDownloader.downloadReport(query, DownloadFormat.CSV);
response.saveToFile(reportFile);
System.out.printf("Report successfully downloaded to: %s%n", reportFile);
} catch (ReportDownloadResponseException e) {
System.out.printf("Report was not downloaded due to: %s%n", e);
}
}
示例8: getReportingConfiguration
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
private ReportingConfiguration getReportingConfiguration(Properties properties) {
ReportingConfiguration reportingConfig =
new ReportingConfiguration.Builder()
.skipReportHeader(true)
.skipColumnHeader(false)
.skipReportSummary(true)
.includeZeroImpressions(getIncludeZeroImpressions(properties))
.useRawEnumValues(getUseRawEnumValues(properties))
.build();
return reportingConfig;
}
示例9: getReportingConfiguration
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
/**
* Gets the reporting configuration.
*/
@Nullable
public ReportingConfiguration getReportingConfiguration() {
return reportingConfiguration;
}
示例10: setReportingConfiguration
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
/**
* Sets the reporting configuration.
*/
public void setReportingConfiguration(@Nullable ReportingConfiguration reportingConfiguration) {
this.reportingConfiguration = reportingConfiguration;
}
示例11: withReportingConfiguration
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
public Builder withReportingConfiguration(ReportingConfiguration reportingConfiguration) {
this.reportingConfiguration = reportingConfiguration;
return this;
}
示例12: ReportRequestFactoryHelperTest
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
/**
* Values for these arguments are supplied by the {@link #data()} method.
*
* @param version version of the AdWords API
*/
public ReportRequestFactoryHelperTest(
String version, ReportingConfiguration reportingConfiguration) {
this.version = version;
this.reportingConfiguration = reportingConfiguration;
}
示例13: runExample
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
public static void runExample(
AdWordsServicesInterface adWordsServices, AdWordsSession session, String reportFile)
throws Exception {
// Create selector.
Selector selector = new Selector();
selector.getFields().addAll(Arrays.asList("CampaignId",
"AdGroupId",
"Id",
"CriteriaType",
"Criteria",
"FinalUrls",
"Impressions",
"Clicks",
"Cost"));
// Create report definition.
ReportDefinition reportDefinition = new ReportDefinition();
reportDefinition.setReportName("Criteria performance report #" + System.currentTimeMillis());
reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.YESTERDAY);
reportDefinition.setReportType(ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT);
reportDefinition.setDownloadFormat(DownloadFormat.CSV);
// Optional: Set the reporting configuration of the session to suppress header, column name, or
// summary rows in the report output. You can also configure this via your ads.properties
// configuration file. See AdWordsSession.Builder.from(Configuration) for details.
// In addition, you can set whether you want to explicitly include or exclude zero impression
// rows.
ReportingConfiguration reportingConfiguration =
new ReportingConfiguration.Builder()
.skipReportHeader(false)
.skipColumnHeader(false)
.skipReportSummary(false)
// Enable to allow rows with zero impressions to show.
.includeZeroImpressions(false)
.build();
session.setReportingConfiguration(reportingConfiguration);
reportDefinition.setSelector(selector);
ReportDownloaderInterface reportDownloader =
adWordsServices.getUtility(session, ReportDownloaderInterface.class);
try {
// Set the property api.adwords.reportDownloadTimeout or call
// ReportDownloader.setReportDownloadTimeout to set a timeout (in milliseconds)
// for CONNECT and READ in report downloads.
ReportDownloadResponse response = reportDownloader.downloadReport(reportDefinition);
response.saveToFile(reportFile);
System.out.printf("Report successfully downloaded to: %s%n", reportFile);
} catch (ReportDownloadResponseException e) {
System.out.printf("Report was not downloaded due to: %s%n", e);
}
}
示例14: runExample
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
public static void runExample(AdWordsServicesInterface adWordsServices, AdWordsSession session)
throws Exception {
// Create the query.
String query =
"SELECT Id, AdNetworkType1, Impressions "
+ "FROM CRITERIA_PERFORMANCE_REPORT "
+ "WHERE Status IN [ENABLED, PAUSED] "
+ "DURING LAST_7_DAYS";
// Optional: Set the reporting configuration of the session to suppress header, column name, or
// summary rows in the report output. You can also configure this via your ads.properties
// configuration file. See AdWordsSession.Builder.from(Configuration) for details.
// In addition, you can set whether you want to explicitly include or exclude zero impression
// rows.
ReportingConfiguration reportingConfiguration =
new ReportingConfiguration.Builder()
// Skip all header and summary lines since the loop below expects
// every field to be present in each line.
.skipReportHeader(true)
.skipColumnHeader(true)
.skipReportSummary(true)
// Enable to include rows with zero impressions.
.includeZeroImpressions(false)
.build();
session.setReportingConfiguration(reportingConfiguration);
ReportDownloaderInterface reportDownloader =
adWordsServices.getUtility(session, ReportDownloaderInterface.class);
BufferedReader reader = null;
try {
// Set the property api.adwords.reportDownloadTimeout or call
// ReportDownloader.setReportDownloadTimeout to set a timeout (in milliseconds)
// for CONNECT and READ in report downloads.
final ReportDownloadResponse response =
reportDownloader.downloadReport(query, DownloadFormat.CSV);
// Read the response as a BufferedReader.
reader = new BufferedReader(new InputStreamReader(response.getInputStream(), UTF_8));
// Map to store total impressions by ad network type 1.
Map<String, Long> impressionsByAdNetworkType1 = Maps.newTreeMap();
// Stream the results one line at a time and perform any line-specific processing.
String line;
Splitter splitter = Splitter.on(',');
while ((line = reader.readLine()) != null) {
System.out.println(line);
// Split the line into a list of field values.
List<String> values = splitter.splitToList(line);
// Update the total impressions for the ad network type 1 value.
String adNetworkType1 = values.get(1);
Long impressions = Longs.tryParse(values.get(2));
if (impressions != null) {
Long impressionsTotal = impressionsByAdNetworkType1.get(adNetworkType1);
impressionsTotal = impressionsTotal == null ? 0L : impressionsTotal;
impressionsByAdNetworkType1.put(adNetworkType1, impressionsTotal + impressions);
}
}
// Print the impressions totals by ad network type 1.
System.out.println();
System.out.printf(
"Total impressions by ad network type 1:%n%s%n",
Joiner.on(SystemUtils.LINE_SEPARATOR).join(impressionsByAdNetworkType1.entrySet()));
} finally {
if (reader != null) {
reader.close();
}
}
}
示例15: runExample
import com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration; //导入依赖的package包/类
public static void runExample(
AdWordsServicesInterface adWordsServices, AdWordsSession session, String reportFile)
throws Exception {
// Get the CampaignService.
CampaignServiceInterface campaignService =
adWordsServices.get(session, CampaignServiceInterface.class);
// Create selector.
Selector selector = new Selector();
selector.setFields(new String[] {"Id", "Name"});
// Get all campaigns.
CampaignPage page = campaignService.get(selector);
// Display campaigns.
if (page.getEntries() != null) {
for (Campaign campaign : page.getEntries()) {
System.out.printf("Campaign with name '%s' and ID %d was found.%n", campaign.getName(),
campaign.getId());
}
} else {
System.out.println("No campaigns were found.");
}
// Create selector.
com.google.api.ads.adwords.lib.jaxb.v201702.Selector reportSelector =
new com.google.api.ads.adwords.lib.jaxb.v201702.Selector();
reportSelector.getFields().addAll(Arrays.asList(
"CampaignId",
"AdGroupId",
"Id",
"CriteriaType",
"Criteria",
"Impressions",
"Clicks",
"Cost"));
// Create report definition.
ReportDefinition reportDefinition = new ReportDefinition();
reportDefinition.setReportName("Criteria performance report #" + System.currentTimeMillis());
reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.YESTERDAY);
reportDefinition.setReportType(ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT);
reportDefinition.setDownloadFormat(DownloadFormat.CSV);
reportDefinition.setSelector(reportSelector);
ReportingConfiguration reportingConfig =
new ReportingConfiguration.Builder()
// Enable to allow rows with zero impressions to show.
.includeZeroImpressions(false)
.build();
session.setReportingConfiguration(reportingConfig);
ReportDownloadResponse response =
new ReportDownloader(session).downloadReport(reportDefinition);
if (response.getHttpStatus() == HttpURLConnection.HTTP_OK) {
FileOutputStream fos = new FileOutputStream(new File(reportFile));
Streams.copy(response.getInputStream(), fos);
fos.close();
System.out.printf("Report successfully downloaded: %s%n", reportFile);
} else {
System.out.printf("Report was not downloaded. %d: %s%n", response.getHttpStatus(),
response.getHttpResponseMessage());
}
}