Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access report Header or Rows directly from AdMob\GenerateNetworkReportResponse #444

Open
ps613 opened this issue Aug 11, 2021 · 0 comments
Labels
type: question Request for information or clarification. Not an issue.

Comments

@ps613
Copy link

ps613 commented Aug 11, 2021

It seems accessing "header" and "row" data from AdMob's GenerateNetworkReportRequest doesn't work as expected. Maybe I'm missing something obvious, but I can't find anything about access the report values of this object like we can with the AdSese report response. The returned object "Google\Service\AdMob\GenerateNetworkReportResponse" doesn't return any values for calls to getHeader() or getRow(), nor do the magic functions of the base model "\Google\Model" work because there are no types set for "headerDataType" or "rowDataType".

The equivalent "Google\Service\Adsense\ReportResult" works well for AdSense, but the AdMob Report Result doesn't seem to have any built-in way to access the underlying data except to convert the reponse using "toSimpleObject()";

Am I missing something or does should "headerDataType" and "rowDataType" of GenerateNetworkReportRequest be set to "array"?

Environment details

  • OS: Ubuntu 18.04.5 LTS
  • PHP version: 7.4.18
  • Package name and version: v2.10.1

Steps to reproduce

  1. Generate a GenerateNetworkReportRequest
  2. Set the setReportSpec()
  3. Call the AdMob service accounts_networkReport->generate($name, $reportRequest);
  4. This returns "Google\Service\AdMob\GenerateNetworkReportResponse" as expected and "modelData[]" is complete with the request report data. But there are no methods available to access the data without converting to a simple object.

Code example

// Load the GoogleClient - This works
$GoogleClient = new \Google\Client();
$GoogleClient->addScope(\Google\Service\AdMob::ADMOB_READONLY );
$GoogleClient->setAccessType('offline');
$GoogleClient->setAuthConfigFile(  ...  );   // Omitted - Authentication works fine 

// Create an AdMob Service - This works - We can query for the Account data and run reports 
$AdMobService= new \Google\Service\AdMob($this->GoogleClient);

// Setup date range - Skipped details for brevity 
$dateRange = new \Google\Service\AdMob\DateRange();
$dateRange->setStartDate( ... )  
$dateRange->setEndDate( ... ) 

// Setup report spec - Date and Earnings over range 
$reportSpec = new \Google\Service\AdMob\NetworkReportSpec();
$reportSpec->setDimensions([ 'DATE' ]);
$reportSpec->setMetrics([ 'ESTIMATED_EARNINGS' ]);
$reportSpec->setDateRange($dateRange);

// Generate network report - Returns an AdMob\GenerateNetworkReportRequest 
$networkReportRequest = new \Google\Service\AdMob\GenerateNetworkReportRequest();
$networkReportRequest ->setReportSpec($reportSpec);
$ReportResponse = $AdMobService->accounts_networkReport->generate("AccountName", $networkReportRequest );

// Try and output any values of the report  - Like we can with the AdSense report result
var_dump($ReportResponse ->header);   // NULL
var_dump($ReportResponse ->getHeader());   // NULL
var_dump($ReportResponse ->row);   // NULL
var_dump($ReportResponse ->rows);   // NULL
var_dump($ReportResponse ->getRow());   // NULL

// This works - OBJ is populated with the contents of the report 
$OBJ = $ReportResponse->toSimpleObject();

The $ReportResponse will contain all of the data of the report, I've pasted part of the response below.

Maybe I'm doing something wrong, but it seems I should be able to access the report data directly from the response object.

Google\Service\AdMob\GenerateNetworkReportResponse^ {#2515
#footerType: "Google\Service\AdMob\ReportFooter"
#footerDataType: ""
#headerType: "Google\Service\AdMob\ReportHeader"
#headerDataType: ""
#rowType: "Google\Service\AdMob\ReportRow"
#rowDataType: ""
#internal_gapi_mappings: []
#modelData: array:5 [
0 => array:1 [
"header" => array:2 [
"dateRange" => array:2 [
"startDate" => array:3 [
"year" => 2021
"month" => 8
"day" => 4
]
"endDate" => array:3 [
"year" => 2021
"month" => 8
"day" => 11
]
]
"localizationSettings" => array:1 [
"currencyCode" => "USD"
]
]
]
1 => array:1 [
"row" => array:2 [
"dimensionValues" => array:1 [
"DATE" => array:1 [
"value" => "20210804"
]
]
"metricValues" => array:1 [
"ESTIMATED_EARNINGS" => array:1 [
"microsValue" => "3570"
]
]
.....

@dwsupplee dwsupplee added the type: question Request for information or clarification. Not an issue. label Aug 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants