Skip to content

Commit 4675e02

Browse files
committed
Reports namespace, Outlook model update (Calendars nav prop and etc)
1 parent 0aee602 commit 4675e02

9 files changed

Lines changed: 139 additions & 6 deletions

File tree

examples/Outlook/ListCals.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
4+
use Office365\GraphServiceClient;
5+
use Office365\Outlook\Calendars\Calendar;
6+
use Office365\Runtime\Auth\AADTokenProvider;
7+
use Office365\Runtime\Auth\UserCredentials;
8+
9+
require_once '../vendor/autoload.php';
10+
11+
function acquireToken()
12+
{
13+
$resource = "https://graph.microsoft.com";
14+
$settings = include('../../tests/Settings.php');
15+
$provider = new AADTokenProvider($settings['TenantName']);
16+
return $provider->acquireTokenForPassword($resource, $settings['ClientId'],
17+
new UserCredentials($settings['UserName'], $settings['Password']));
18+
}
19+
20+
$client = new GraphServiceClient("acquireToken");
21+
22+
$userCals = $client->getMe()->getCalendars()->get()->executeQuery();
23+
/** @var Calendar $cal */
24+
foreach ($userCals as $cal){
25+
echo "Calendar name: \n" . $cal->getName();
26+
}
27+
28+
29+

examples/Reports/getReports.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
4+
use Office365\GraphServiceClient;
5+
use Office365\Runtime\Auth\AADTokenProvider;
6+
use Office365\Runtime\Auth\ClientCredential;
7+
8+
9+
require_once '../vendor/autoload.php';
10+
11+
function acquireToken()
12+
{
13+
$resource = "https://graph.microsoft.com";
14+
$settings = include('../../tests/Settings.php');
15+
$provider = new AADTokenProvider($settings['TenantName']);
16+
return $provider->acquireTokenForClientCredential($resource,
17+
new ClientCredential($settings['ClientId'], $settings['ClientSecret']),["/.default"]);
18+
}
19+
20+
$client = new GraphServiceClient("acquireToken");
21+
$result = $client->getReports()->getOffice365ActivationCounts()->executeQuery();
22+
var_dump($result->getValue());
23+
24+
25+
26+

generator/Settings.SharePoint.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"docsRoot": "https:\/\/docs.microsoft.com\/en-us\/openspecs\/sharepoint_protocols\/ms-csomspt\/",
77
"rootNamespace": "Office365\\SharePoint",
88
"entityRootNamespace": "SP",
9-
"version": "16.0.21221.12006",
10-
"timestamp": "2021-05-05T14:47:20+00:00",
9+
"version": "16.0.21611.12002",
10+
"timestamp": "2021-08-22T17:22:47+03:00",
1111
"placeholder": "This file was generated by phpSPO model generator",
1212
"typeMappings": {
1313
"SP.List": "SP.SPList",

generator/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
],
88
"autoload": {
99
"psr-4": {
10-
"Office365\\": "../src/",
11-
"Office365\\Generator\\": ""
10+
"Office365\\Generator\\": "./generator/",
11+
"Office365\\": "../src/"
1212
}
1313
},
1414
"name": "vgrem/php-office365-sdk-generator",

generator/metadata/SharePoint.xml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

src/Directory/Users/User.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Office365\OneDrive\Drives\DriveCollection;
1414
use Office365\OneNote\Onenote;
1515
use Office365\Outlook\Calendars\Calendar;
16+
use Office365\Outlook\Calendars\CalendarGroup;
1617
use Office365\Outlook\Contacts\Contact;
1718
use Office365\Outlook\Events\Event;
1819
use Office365\Outlook\MailboxSettings;
@@ -1020,4 +1021,26 @@ public function getMailFolders()
10201021
new EntityCollection($this->getContext(),
10211022
new ResourcePath("MailFolders", $this->getResourcePath()),MailFolder::class));
10221023
}
1024+
1025+
/**
1026+
* Get all the user's calendars
1027+
* @return EntityCollection
1028+
*/
1029+
public function getCalendars()
1030+
{
1031+
return $this->getProperty("Calendars",
1032+
new EntityCollection($this->getContext(),
1033+
new ResourcePath("Calendars", $this->getResourcePath()),Calendar::class));
1034+
}
1035+
1036+
/**
1037+
* Get the user's calendar groups.
1038+
* @return EntityCollection
1039+
*/
1040+
public function getCalendarGroups()
1041+
{
1042+
return $this->getProperty("CalendarGroups",
1043+
new EntityCollection($this->getContext(),
1044+
new ResourcePath("CalendarGroups", $this->getResourcePath()),CalendarGroup::class));
1045+
}
10231046
}

src/GraphServiceClient.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Office365\OneDrive\DriveItems\DriveItem;
1212
use Office365\OneDrive\Drives\DriveCollection;
1313
use Office365\OneDrive\Sites\Site;
14+
use Office365\Reports\ReportRoot;
1415
use Office365\Runtime\ClientRuntimeContext;
1516
use Office365\Runtime\Actions\DeleteEntityQuery;
1617
use Office365\Runtime\Http\HttpMethod;
@@ -138,6 +139,13 @@ public function getWorkbooks(){
138139
return new EntityCollection($this,new ResourcePath("workbooks"),DriveItem::class);
139140
}
140141

142+
/**
143+
* @return ReportRoot
144+
*/
145+
public function getReports(){
146+
return new ReportRoot($this,new ResourcePath("reports"));
147+
}
148+
141149
/**
142150
* @return string
143151
*/

src/Reports/Report.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@
77

88
use Office365\Runtime\ClientValue;
99
/**
10-
* "With Microsoft Graph, you can access Office 365 usage reports resources to get the information about how people in your business are using Office 365 services. For example, you can identify who is using a service a lot and reaching quotas, or who may not need an Office 365 license at all."
10+
* With Microsoft Graph, you can access Office 365 usage reports resources to get the information
11+
* about how people in your business are using Office 365 services. For example, you can identify who is using
12+
* a service a lot and reaching quotas, or who may not need an Office 365 license at all.
1113
*/
1214
class Report extends ClientValue
1315
{
16+
/**
17+
* @var string
18+
*/
19+
public $Content;
1420
}

src/Reports/ReportRoot.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,47 @@
66
namespace Office365\Reports;
77

88
use Office365\Entity;
9+
use Office365\Runtime\Actions\InvokeMethodQuery;
10+
use Office365\Runtime\Actions\InvokePostMethodQuery;
11+
use Office365\Runtime\ClientResult;
12+
use Office365\Runtime\Http\RequestOptions;
13+
914
class ReportRoot extends Entity
1015
{
16+
/**
17+
* Get details about users who have activated Microsoft 365.
18+
* @return ClientResult
19+
*/
20+
function getOffice365ActivationsUserDetail(){
21+
$qry = new InvokePostMethodQuery($this, "getOffice365ActivationsUserDetail");
22+
$reportResult = new ClientResult($this->getContext(),new Report());
23+
$this->getContext()->addQueryAndResultObject($qry, $reportResult);
24+
return $reportResult;
25+
}
26+
27+
/**
28+
* Get the count of Microsoft 365 activations on desktops and devices.
29+
* @return ClientResult
30+
*/
31+
function getOffice365ActivationCounts(){
32+
$qry = new InvokeMethodQuery($this, "getOffice365ActivationCounts");
33+
$this->getContext()->getPendingRequest()->beforeExecuteRequestOnce(function (RequestOptions $request){
34+
$request->FollowLocation = true;
35+
});
36+
$reportResult = new ClientResult($this->getContext(),new Report());
37+
$this->getContext()->addQueryAndResultObject($qry, $reportResult);
38+
return $reportResult;
39+
}
40+
41+
/**
42+
* Get the count of users that are enabled and those that have activated the Office subscription on
43+
* desktop or devices or shared computers.
44+
* @return ClientResult
45+
*/
46+
function getOffice365ActivationsUserCounts(){
47+
$qry = new InvokePostMethodQuery($this, "getOffice365ActivationsUserCounts");
48+
$reportResult = new ClientResult($this->getContext(),new Report());
49+
$this->getContext()->addQueryAndResultObject($qry, $reportResult);
50+
return $reportResult;
51+
}
1152
}

0 commit comments

Comments
 (0)