Skip to content

Commit

Permalink
README.md updated (replaced refs OutlookClient with GraphServiceClient)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvgrem@gmail.com authored and vvgrem@gmail.com committed May 10, 2021
1 parent e946c97 commit b16aed8
Show file tree
Hide file tree
Showing 19 changed files with 133 additions and 140 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -6,7 +6,6 @@ dist: trusty
php:
# using major version aliases
- 5.6
- 7.3
- 7.4

matrix:
Expand Down
60 changes: 33 additions & 27 deletions README.md
Expand Up @@ -67,31 +67,39 @@ The list of supported SharePoint versions:

The following auth flows supported:

- app principals (client credentials) auth (refer [Granting access using SharePoint App-Only](https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs) for a details):
```
$credentials = new ClientCredential($clientId, $clientSecret);
$ctx = (new ClientContext($url))->withCredentials($credentials);
```
- app principals (client credentials) auth (refer [Granting access using SharePoint App-Only](https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs) for a details):

```php

use Office365\Runtime\Auth\ClientCredential;
use Office365\SharePoint\ClientContext;

$credentials = new ClientCredential("{clientId}", "{clientSecret}");
$ctx = (new ClientContext("{siteUrl}"))->withCredentials($credentials);
```

- user credentials auth:
```php

- user credentials auth:

```php

$credentials = new UserCredentials($userName, $password);
$ctx = (new ClientContext($url))->withCredentials($credentials);
use Office365\Runtime\Auth\UserCredentials;
use Office365\SharePoint\ClientContext;

```
$credentials = new UserCredentials("{userName}", "{password}");
$ctx = (new ClientContext("{siteUrl}"))->withCredentials($credentials);
```


- NTLM auth (for SharePoint On-Premises):
```php
```php
use Office365\Runtime\Auth\UserCredentials;
use Office365\SharePoint\ClientContext;

$credentials = new UserCredentials($username, $password);
$ctx = (new ClientContext($siteUrl))->withNtlm($credentials);
$credentials = new UserCredentials("{userName}", "{password}");
$ctx = (new ClientContext("{siteUrl}"))->withNtlm($credentials);

```
```

#### Examples

Expand All @@ -118,10 +126,10 @@ foreach($items as $item) {
}
```


or via Fluent API syntax:
or via fluent API syntax:

```php

use Office365\SharePoint\ClientContext;
use Office365\Runtime\Auth\ClientCredential;
use Office365\SharePoint\ListItem;
Expand Down Expand Up @@ -200,7 +208,8 @@ Supported list of APIs:
The following example demonstrates how to send a message via Outlook Mail API:

```php
use Office365\OutlookServices\OutlookClient;
use Office365\GraphServiceClient;
use Office365\OutlookServices\Message;
use Office365\OutlookServices\ItemBody;
use Office365\OutlookServices\BodyType;
use Office365\OutlookServices\EmailAddress;
Expand All @@ -211,22 +220,19 @@ The following example demonstrates how to send a message via Outlook Mail API:
function acquireToken()
{
$tenant = "{tenant}.onmicrosoft.com";
$resource = "https://outlook.office365.com";
$resource = "https://graph.microsoft.com";

$provider = new AADTokenProvider($tenant);
return $provider->acquireTokenForPassword($resource, "{clientId}",
new UserCredentials("{UserName}", "{Password}"));
}


$client = new OutlookClient("acquireToken");

$message = $client->getMe()->getMessages()->createMessage();
$message->Subject = "Meet for lunch?";
$message->Body = new ItemBody(BodyType::Text,"The new cafeteria is open.");
$message->ToRecipients = array(
new Recipient(new EmailAddress(null,"{username}@{tenant_prefix}.onmicrosoft.com"))
);
$client = new GraphServiceClient("acquireToken");
/** @var Message $message */
$message = $client->getMe()->getMessages()->createType();
$message->setSubject("Meet for lunch?");
$message->setBody(new ItemBody(BodyType::Text,"The new cafeteria is open."));
$message->getToRecipients()->addChild(new Recipient(new EmailAddress(null,"fannyd@contoso.onmicrosoft.com")));
$client->getMe()->sendEmail($message,true)->executeQuery();
```

Expand Down
9 changes: 5 additions & 4 deletions src/Common/EducationOrganization.php
@@ -1,13 +1,14 @@
<?php

/**
* Generated by phpSPO model generator 2020-05-24T22:10:26+00:00
* Modified: 2020-05-24T22:10:26+00:00
*/
namespace Office365\Common;

use Office365\Runtime\ClientObject;
use Office365\Runtime\ResourcePath;
class EducationOrganization extends ClientObject
use Office365\Entity;


class EducationOrganization extends Entity
{
/**
* @return string
Expand Down
6 changes: 3 additions & 3 deletions src/Common/OfficeGraphInsights.php
Expand Up @@ -5,11 +5,11 @@
*/
namespace Office365\Common;

use Office365\Runtime\ClientObject;
use Office365\Runtime\ResourcePath;
use Office365\Entity;

/**
* "Insights are relationships calculated using advanced analytics and machine learning techniques. You can, for example, identify OneDrive for Business documents trending around users."
*/
class OfficeGraphInsights extends ClientObject
class OfficeGraphInsights extends Entity
{
}
23 changes: 6 additions & 17 deletions src/Common/User.php
@@ -1,7 +1,7 @@
<?php

/**
* Generated by phpSPO model generator 2020-05-27T07:36:43+00:00
* Modified: 2020-05-27T07:36:43+00:00
*/
namespace Office365\Common;

Expand Down Expand Up @@ -974,21 +974,16 @@ public function setSkills($value)
*/
public function getManager()
{
if (!$this->isPropertyAvailable("Manager")) {
$this->setProperty("Manager", new DirectoryObject($this->getContext(), new ResourcePath("Manager", $this->getResourcePath())));
}
return $this->getProperty("Manager");
return $this->getProperty("Manager",
new DirectoryObject($this->getContext(), new ResourcePath("Manager", $this->getResourcePath())));
}
/**
* Contains extensionAttributes 1-15 for the user. Note that the individual extension attributes are neither selectable nor filterable. For an `onPremisesSyncEnabled` user, this set of properties is mastered on-premises and is read-only. For a cloud-only user (where `onPremisesSyncEnabled` is false), these properties may be set during creation or update.
* @return OnPremisesExtensionAttributes
*/
public function getOnPremisesExtensionAttributes()
{
if (!$this->isPropertyAvailable("OnPremisesExtensionAttributes")) {
return null;
}
return $this->getProperty("OnPremisesExtensionAttributes");
return $this->getProperty("OnPremisesExtensionAttributes", new OnPremisesExtensionAttributes());
}
/**
* Contains extensionAttributes 1-15 for the user. Note that the individual extension attributes are neither selectable nor filterable. For an `onPremisesSyncEnabled` user, this set of properties is mastered on-premises and is read-only. For a cloud-only user (where `onPremisesSyncEnabled` is false), these properties may be set during creation or update.
Expand All @@ -1004,10 +999,7 @@ public function setOnPremisesExtensionAttributes($value)
*/
public function getPasswordProfile()
{
if (!$this->isPropertyAvailable("PasswordProfile")) {
return null;
}
return $this->getProperty("PasswordProfile");
return $this->getProperty("PasswordProfile", new PasswordProfile());
}
/**
* Specifies the password profile for the user. The profile contains the user’s password. This property is required when a user is created. The password in the profile must satisfy minimum requirements as specified by the **passwordPolicies** property. By default, a strong password is required.
Expand All @@ -1023,10 +1015,7 @@ public function setPasswordProfile($value)
*/
public function getMailboxSettings()
{
if (!$this->isPropertyAvailable("MailboxSettings")) {
return null;
}
return $this->getProperty("MailboxSettings");
return $this->getProperty("MailboxSettings", new MailboxSettings());
}
/**
* Settings for the primary mailbox of the signed-in user. You can [get](../api/user-get-mailboxsettings.md) or [update](../api/user-update-mailboxsettings.md) settings for sending automatic replies to incoming messages, locale and time zone.
Expand Down
8 changes: 4 additions & 4 deletions src/Common/UserSettings.php
@@ -1,16 +1,16 @@
<?php

/**
* Generated by phpSPO model generator 2020-05-24T22:08:35+00:00
* Modified: 2020-05-24T22:08:35+00:00
*/
namespace Office365\Common;

use Office365\Runtime\ClientObject;
use Office365\Runtime\ResourcePath;
use Office365\Entity;

/**
* "The current user settings for content discovery. "
*/
class UserSettings extends ClientObject
class UserSettings extends Entity
{
/**
* When set to true, the delegate access to the user's [trending](/graph/api/resources/insights-trending?view=graph-rest-beta) API is disabled. When set to true, documents in the user's Office Delve are disabled. When set to true, the relevancy of the content displayed in Office 365, for example in Suggested sites in SharePoint Home and the Discover view in OneDrive for Business is affected. Users can control this setting in [Office Delve](https://support.office.com/en-us/article/are-my-documents-safe-in-office-delve-f5f409a2-37ed-4452-8f61-681e5e1836f3?ui=en-US&rs=en-US&ad=US#bkmk_optout).
Expand Down
9 changes: 9 additions & 0 deletions src/GraphServiceClient.php
Expand Up @@ -7,6 +7,7 @@
use Office365\Common\User;
use Office365\Common\UserCollection;
use Office365\OneDrive\DriveCollection;
use Office365\OneDrive\Site;
use Office365\Runtime\ClientRuntimeContext;
use Office365\Runtime\Actions\DeleteEntityQuery;
use Office365\Runtime\Http\HttpMethod;
Expand Down Expand Up @@ -74,6 +75,14 @@ public function getMe(){
return new User($this,new ResourcePath("me"));
}


/**
* @return EntityCollection
*/
public function getSites(){
return new EntityCollection($this,new ResourcePath("sites"),Site::class);
}

/**
* @return DriveCollection
*/
Expand Down
3 changes: 3 additions & 0 deletions src/OneDrive/Site.php
Expand Up @@ -131,4 +131,7 @@ public function getDrives()
}
return $this->getProperty("Drives");
}



}
4 changes: 2 additions & 2 deletions src/Runtime/ClientObjectCollection.php
Expand Up @@ -236,8 +236,8 @@ public function skiptoken($value)
*/
public function createType()
{
$clientObjectType = $this->getItemTypeName();
$clientObject = new $clientObjectType($this->getContext());
$itemTypeName = $this->getItemTypeName();
$clientObject = new $itemTypeName($this->getContext());
$clientObject->parentCollection = $this;
return $clientObject;
}
Expand Down
4 changes: 1 addition & 3 deletions src/SharePoint/FieldThumbnail.php
Expand Up @@ -5,9 +5,7 @@
*/
namespace Office365\SharePoint;

use Office365\Runtime\ClientObject;


class FieldThumbnail extends ClientObject
class FieldThumbnail extends BaseEntity
{
}
13 changes: 6 additions & 7 deletions src/SharePoint/ObjectSharingSettings.php
@@ -1,19 +1,19 @@
<?php

/**
* This file was generated by phpSPO model generator 2021-03-12T16:05:00+00:00 16.0.21103.12002
* Modified: 2021-03-12T16:05:00+00:00
* API version: 16.0.21103.12002
*/
namespace Office365\SharePoint;

use Office365\Runtime\ClientObject;
use Office365\Runtime\ResourcePath;
/**
* This class
* contains the information necessary to read and change the sharing status of a
* SharePoint object. It also contains a reference to SharePoint specific settings
* denoted by "SharePointSettings".
*/
class ObjectSharingSettings extends ClientObject
class ObjectSharingSettings extends BaseEntity
{
/**
* Boolean
Expand Down Expand Up @@ -838,10 +838,9 @@ public function getObjectSharingInformation()
*/
public function getSharePointSettings()
{
if (!$this->isPropertyAvailable("SharePointSettings")) {
$this->setProperty("SharePointSettings", new SharePointSharingSettings($this->getContext(), new ResourcePath("SharePointSettings", $this->getResourcePath())));
}
return $this->getProperty("SharePointSettings");
return $this->getProperty("SharePointSettings",
new SharePointSharingSettings($this->getContext(),
new ResourcePath("SharePointSettings", $this->getResourcePath())));
}
/**
* @return bool
Expand Down

0 comments on commit b16aed8

Please sign in to comment.