Skip to content

Commit

Permalink
Reports namespace operations & unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Oct 9, 2021
1 parent 46e6c76 commit 13116a1
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"autoload-dev": {
"psr-4": {
"Office365\\": ["tests/", "tests/common/", "tests/sharepoint/", "tests/onenote/", "tests/onedrive/", "tests/outlookservices/", "tests/directory/", "tests/teams/"]
"Office365\\": ["tests/", "tests/common/", "tests/sharepoint/", "tests/onenote/", "tests/onedrive/", "tests/outlookservices/", "tests/directory/", "tests/teams/", "tests/reports/"]
}
},
"autoload": {
Expand Down
3 changes: 3 additions & 0 deletions examples/Reports/getReports.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ function acquireToken()
$result = $client->getReports()->getOffice365ActivationCounts()->executeQuery();
var_dump($result->getValue());

$result = $client->getReports()->getOffice365ActiveUserDetail("D7")->executeQuery();
var_dump($result->getValue());




2 changes: 1 addition & 1 deletion src/GraphServiceClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Office365\Runtime\ClientRuntimeContext;
use Office365\Runtime\Actions\DeleteEntityQuery;
use Office365\Runtime\Http\HttpMethod;
use Office365\Runtime\OData\JsonFormat;
use Office365\Runtime\OData\V4\JsonFormat;
use Office365\Runtime\OData\ODataMetadataLevel;
use Office365\Runtime\OData\ODataRequest;
use Office365\Runtime\Office365Version;
Expand Down
76 changes: 75 additions & 1 deletion src/Reports/ReportRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ class ReportRoot extends Entity

/**
* @param $name string
* @param $period string
* @return ClientResult
*/
private function addReportQuery($name){
private function addReportQuery($name,$period=null){
$qry = new InvokeMethodQuery($this, $name);
if(!is_null($period))
$qry->MethodParameters = array("period" => $period);
$this->getContext()->getPendingRequest()->beforeExecuteRequestOnce(function (RequestOptions $request){
$request->FollowLocation = true;
});
Expand Down Expand Up @@ -51,4 +54,75 @@ function getOffice365ActivationCounts(){
function getOffice365ActivationsUserCounts(){
return $this->addReportQuery("getOffice365ActivationsUserCounts");
}


/**
* Get details about Microsoft 365 active users.
* @return ClientResult
*/
function getOffice365ActiveUserDetail($period){
return $this->addReportQuery("getOffice365ActiveUserDetail",$period);
}


/**
* Get the count of daily active users in the reporting period by product.
* @return ClientResult
*/
function getOffice365ActiveUserCounts($period){
return $this->addReportQuery("getOffice365ActiveUserCounts",$period);
}


/**
* Get the count of users by activity type and service.
* @return ClientResult
*/
function getOffice365ServicesUserCounts($period){
return $this->addReportQuery("getOffice365ServicesUserCounts",$period);
}

/**
* Get details about Microsoft 365 groups activity by group.
* @return ClientResult
*/
function getOffice365GroupsActivityDetail($period){
return $this->addReportQuery("getOffice365GroupsActivityDetail",$period);
}

/**
* Get the number of group activities across group workloads.
* @return ClientResult
*/
function getOffice365GroupsActivityCounts($period){
return $this->addReportQuery("getOffice365GroupsActivityCounts",$period);
}

/**
* Get the daily total number of groups and how many of them were active based on email conversations,
* Yammer posts, and SharePoint file activities.
* @return ClientResult
*/
function getOffice365GroupsActivityGroupCounts($period){
return $this->addReportQuery("getOffice365GroupsActivityGroupCounts",$period);
}

/**
* Get the total storage used across all group mailboxes and group sites.
* @return ClientResult
*/
function getOffice365GroupsActivityStorage($period){
return $this->addReportQuery("getOffice365GroupsActivityStorage",$period);
}

/**
* Get the total number of files and how many of them were active across all group sites associated with
* a Microsoft 365 group.
* @return ClientResult
*/
function getOffice365GroupsActivityFileCounts($period){
return $this->addReportQuery("getOffice365GroupsActivityFileCounts",$period);
}


}
1 change: 1 addition & 0 deletions src/Runtime/OData/ODataRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Office365\Runtime\Actions\InvokeMethodQuery;
use Office365\Runtime\Actions\InvokePostMethodQuery;
use Office365\Runtime\OData\V3\JsonLightFormat;
use Office365\Runtime\OData\V4\JsonFormat;
use Office365\SharePoint\ClientContext;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php


namespace Office365\Runtime\OData;
namespace Office365\Runtime\OData\V4;


use Exception;
use Office365\Runtime\OData\ODataFormat;
use Office365\Runtime\OData\ODataMetadataLevel;

class JsonFormat extends ODataFormat
{
Expand Down
2 changes: 1 addition & 1 deletion src/SharePoint/Taxonomy/TaxonomyService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Office365\Runtime\ClientRuntimeContext;
use Office365\Runtime\Http\RequestOptions;
use Office365\Runtime\OData\JsonFormat;
use Office365\Runtime\OData\V4\JsonFormat;
use Office365\Runtime\OData\ODataMetadataLevel;
use Office365\Runtime\OData\ODataRequest;
use Office365\Runtime\ResourcePath;
Expand Down
18 changes: 18 additions & 0 deletions tests/reports/ReportsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Office365;


use Office365\Reports\Report;

class ReportsTest extends GraphTestCase
{

public function testGetOffice365ActiveUserCounts()
{
$result = self::$graphClient->getReports()->getOffice365ActiveUserCounts("D180")->executeQuery();
self::assertNotNull($result->getValue());
self::assertInstanceOf(Report::class,$result->getValue());
}

}

0 comments on commit 13116a1

Please sign in to comment.