Skip to content

Commit 13116a1

Browse files
committed
Reports namespace operations & unit tests
1 parent 46e6c76 commit 13116a1

8 files changed

Lines changed: 103 additions & 5 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"autoload-dev": {
3232
"psr-4": {
33-
"Office365\\": ["tests/", "tests/common/", "tests/sharepoint/", "tests/onenote/", "tests/onedrive/", "tests/outlookservices/", "tests/directory/", "tests/teams/"]
33+
"Office365\\": ["tests/", "tests/common/", "tests/sharepoint/", "tests/onenote/", "tests/onedrive/", "tests/outlookservices/", "tests/directory/", "tests/teams/", "tests/reports/"]
3434
}
3535
},
3636
"autoload": {

examples/Reports/getReports.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ function acquireToken()
2121
$result = $client->getReports()->getOffice365ActivationCounts()->executeQuery();
2222
var_dump($result->getValue());
2323

24+
$result = $client->getReports()->getOffice365ActiveUserDetail("D7")->executeQuery();
25+
var_dump($result->getValue());
26+
2427

2528

2629

src/GraphServiceClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Office365\Runtime\ClientRuntimeContext;
1616
use Office365\Runtime\Actions\DeleteEntityQuery;
1717
use Office365\Runtime\Http\HttpMethod;
18-
use Office365\Runtime\OData\JsonFormat;
18+
use Office365\Runtime\OData\V4\JsonFormat;
1919
use Office365\Runtime\OData\ODataMetadataLevel;
2020
use Office365\Runtime\OData\ODataRequest;
2121
use Office365\Runtime\Office365Version;

src/Reports/ReportRoot.php

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ class ReportRoot extends Entity
1515

1616
/**
1717
* @param $name string
18+
* @param $period string
1819
* @return ClientResult
1920
*/
20-
private function addReportQuery($name){
21+
private function addReportQuery($name,$period=null){
2122
$qry = new InvokeMethodQuery($this, $name);
23+
if(!is_null($period))
24+
$qry->MethodParameters = array("period" => $period);
2225
$this->getContext()->getPendingRequest()->beforeExecuteRequestOnce(function (RequestOptions $request){
2326
$request->FollowLocation = true;
2427
});
@@ -51,4 +54,75 @@ function getOffice365ActivationCounts(){
5154
function getOffice365ActivationsUserCounts(){
5255
return $this->addReportQuery("getOffice365ActivationsUserCounts");
5356
}
57+
58+
59+
/**
60+
* Get details about Microsoft 365 active users.
61+
* @return ClientResult
62+
*/
63+
function getOffice365ActiveUserDetail($period){
64+
return $this->addReportQuery("getOffice365ActiveUserDetail",$period);
65+
}
66+
67+
68+
/**
69+
* Get the count of daily active users in the reporting period by product.
70+
* @return ClientResult
71+
*/
72+
function getOffice365ActiveUserCounts($period){
73+
return $this->addReportQuery("getOffice365ActiveUserCounts",$period);
74+
}
75+
76+
77+
/**
78+
* Get the count of users by activity type and service.
79+
* @return ClientResult
80+
*/
81+
function getOffice365ServicesUserCounts($period){
82+
return $this->addReportQuery("getOffice365ServicesUserCounts",$period);
83+
}
84+
85+
/**
86+
* Get details about Microsoft 365 groups activity by group.
87+
* @return ClientResult
88+
*/
89+
function getOffice365GroupsActivityDetail($period){
90+
return $this->addReportQuery("getOffice365GroupsActivityDetail",$period);
91+
}
92+
93+
/**
94+
* Get the number of group activities across group workloads.
95+
* @return ClientResult
96+
*/
97+
function getOffice365GroupsActivityCounts($period){
98+
return $this->addReportQuery("getOffice365GroupsActivityCounts",$period);
99+
}
100+
101+
/**
102+
* Get the daily total number of groups and how many of them were active based on email conversations,
103+
* Yammer posts, and SharePoint file activities.
104+
* @return ClientResult
105+
*/
106+
function getOffice365GroupsActivityGroupCounts($period){
107+
return $this->addReportQuery("getOffice365GroupsActivityGroupCounts",$period);
108+
}
109+
110+
/**
111+
* Get the total storage used across all group mailboxes and group sites.
112+
* @return ClientResult
113+
*/
114+
function getOffice365GroupsActivityStorage($period){
115+
return $this->addReportQuery("getOffice365GroupsActivityStorage",$period);
116+
}
117+
118+
/**
119+
* Get the total number of files and how many of them were active across all group sites associated with
120+
* a Microsoft 365 group.
121+
* @return ClientResult
122+
*/
123+
function getOffice365GroupsActivityFileCounts($period){
124+
return $this->addReportQuery("getOffice365GroupsActivityFileCounts",$period);
125+
}
126+
127+
54128
}

src/Runtime/OData/ODataRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Office365\Runtime\Actions\InvokeMethodQuery;
2020
use Office365\Runtime\Actions\InvokePostMethodQuery;
2121
use Office365\Runtime\OData\V3\JsonLightFormat;
22+
use Office365\Runtime\OData\V4\JsonFormat;
2223
use Office365\SharePoint\ClientContext;
2324

2425

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

33

4-
namespace Office365\Runtime\OData;
4+
namespace Office365\Runtime\OData\V4;
55

66

77
use Exception;
8+
use Office365\Runtime\OData\ODataFormat;
9+
use Office365\Runtime\OData\ODataMetadataLevel;
810

911
class JsonFormat extends ODataFormat
1012
{

src/SharePoint/Taxonomy/TaxonomyService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use Office365\Runtime\ClientRuntimeContext;
88
use Office365\Runtime\Http\RequestOptions;
9-
use Office365\Runtime\OData\JsonFormat;
9+
use Office365\Runtime\OData\V4\JsonFormat;
1010
use Office365\Runtime\OData\ODataMetadataLevel;
1111
use Office365\Runtime\OData\ODataRequest;
1212
use Office365\Runtime\ResourcePath;

tests/reports/ReportsTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Office365;
4+
5+
6+
use Office365\Reports\Report;
7+
8+
class ReportsTest extends GraphTestCase
9+
{
10+
11+
public function testGetOffice365ActiveUserCounts()
12+
{
13+
$result = self::$graphClient->getReports()->getOffice365ActiveUserCounts("D180")->executeQuery();
14+
self::assertNotNull($result->getValue());
15+
self::assertInstanceOf(Report::class,$result->getValue());
16+
}
17+
18+
}

0 commit comments

Comments
 (0)