Skip to content

Commit 46e6c76

Browse files
committed
Reports namespace operations (along with improvements for deserializing resp payload)
1 parent 90cddd0 commit 46e6c76

11 files changed

Lines changed: 42 additions & 35 deletions

File tree

src/Outlook/ItemBody.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ function __construct($contentType=null,$content=null)
3232
public function setProperty($name, $value)
3333
{
3434
$name = ucfirst($name);
35-
parent::setProperty($name, $value);
35+
return parent::setProperty($name, $value);
3636
}
3737
}

src/Reports/Report.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
*/
1414
class Report extends ClientValue
1515
{
16+
17+
public function setProperty($name, $value)
18+
{
19+
$this->Content = $value;
20+
return $this;
21+
}
22+
1623
/**
1724
* @var string
1825
*/

src/Reports/ReportRoot.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,40 @@
77

88
use Office365\Entity;
99
use Office365\Runtime\Actions\InvokeMethodQuery;
10-
use Office365\Runtime\Actions\InvokePostMethodQuery;
1110
use Office365\Runtime\ClientResult;
1211
use Office365\Runtime\Http\RequestOptions;
1312

1413
class ReportRoot extends Entity
1514
{
15+
1616
/**
17-
* Get details about users who have activated Microsoft 365.
17+
* @param $name string
1818
* @return ClientResult
1919
*/
20-
function getOffice365ActivationsUserDetail(){
21-
$qry = new InvokePostMethodQuery($this, "getOffice365ActivationsUserDetail");
20+
private function addReportQuery($name){
21+
$qry = new InvokeMethodQuery($this, $name);
22+
$this->getContext()->getPendingRequest()->beforeExecuteRequestOnce(function (RequestOptions $request){
23+
$request->FollowLocation = true;
24+
});
2225
$reportResult = new ClientResult($this->getContext(),new Report());
2326
$this->getContext()->addQueryAndResultObject($qry, $reportResult);
2427
return $reportResult;
2528
}
2629

30+
/**
31+
* Get details about users who have activated Microsoft 365.
32+
* @return ClientResult
33+
*/
34+
function getOffice365ActivationsUserDetail(){
35+
return $this->addReportQuery("getOffice365ActivationsUserDetail");
36+
}
37+
2738
/**
2839
* Get the count of Microsoft 365 activations on desktops and devices.
2940
* @return ClientResult
3041
*/
3142
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;
43+
return $this->addReportQuery("getOffice365ActivationCounts");
3944
}
4045

4146
/**
@@ -44,9 +49,6 @@ function getOffice365ActivationCounts(){
4449
* @return ClientResult
4550
*/
4651
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;
52+
return $this->addReportQuery("getOffice365ActivationsUserCounts");
5153
}
5254
}

src/Runtime/Auth/AADTokenProvider.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,6 @@ private function prepareTokenRequest($parameters)
163163
*/
164164
private function normalizeToken($tokenValue)
165165
{
166-
$tokenPayload = json_decode($tokenValue,true);
167-
if (!is_null($tokenPayload)) {
168-
if (isset($tokenPayload['id_token'])) {
169-
$idToken = $tokenPayload['id_token'];
170-
$idTokenPayload = base64_decode(
171-
explode('.', $idToken)[1]
172-
);
173-
$tokenPayload['id_token_info'] = json_decode($idTokenPayload, true);
174-
}
175-
}
176-
return $tokenPayload;
166+
return json_decode($tokenValue,true);
177167
}
178168
}

src/Runtime/ClientObjectCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Generator;
77
use IteratorAggregate;
88
use Office365\Runtime\Http\RequestOptions;
9-
use Office365\Runtime\OData\JsonLightFormat;
9+
use Office365\Runtime\OData\V3\JsonLightFormat;
1010
use Traversable;
1111

1212

src/Runtime/ClientValue.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function __construct()
1616
/**
1717
* @param string $name
1818
* @param mixed $value
19+
* @return $this
1920
*/
2021
function setProperty($name, $value)
2122
{
@@ -33,6 +34,7 @@ function setProperty($name, $value)
3334
}
3435
else
3536
$this->{$name} = $value;
37+
return $this;
3638
}
3739

3840
/**
@@ -61,12 +63,12 @@ public function getServerTypeName()
6163
*/
6264
function toJson()
6365
{
64-
$payload = array();
66+
$json = array();
6567
foreach (get_object_vars($this) as $key => $val) {
6668
if (!is_null($val))
67-
$payload[$key] = $val;
69+
$json[$key] = $val;
6870
}
69-
return $payload;
71+
return $json;
7072
}
7173

7274
}

src/Runtime/OData/ODataFormat.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
namespace Office365\Runtime\OData;
55

66

7+
use Office365\Runtime\OData\V3\JsonLightFormat;
8+
79
abstract class ODataFormat
810
{
911

src/Runtime/OData/ODataRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Office365\Runtime\Http\HttpMethod;
1919
use Office365\Runtime\Actions\InvokeMethodQuery;
2020
use Office365\Runtime\Actions\InvokePostMethodQuery;
21+
use Office365\Runtime\OData\V3\JsonLightFormat;
2122
use Office365\SharePoint\ClientContext;
2223

2324

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

33

4-
namespace Office365\Runtime\OData;
4+
namespace Office365\Runtime\OData\V3;
5+
6+
use Office365\Runtime\OData\ODataFormat;
7+
use Office365\Runtime\OData\ODataMetadataLevel;
58

69
class JsonLightFormat extends ODataFormat
710
{

src/SharePoint/ClientContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
use Office365\Runtime\Actions\DeleteEntityQuery;
1212
use Office365\Runtime\Http\HttpMethod;
1313
use Office365\Runtime\OData\ODataRequest;
14+
use Office365\Runtime\OData\V3\JsonLightFormat;
1415
use Office365\Runtime\ResourcePath;
1516
use Office365\Runtime\Actions\UpdateEntityQuery;
1617
use Office365\Runtime\ClientRuntimeContext;
17-
use Office365\Runtime\OData\JsonLightFormat;
1818
use Office365\Runtime\OData\ODataMetadataLevel;
1919
use Office365\Runtime\Http\RequestOptions;
2020

0 commit comments

Comments
 (0)