Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4 - Graph Mail endpoints #2873

Merged
merged 5 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
"typescript.tsdk": "./node_modules/typescript/lib",
"editor.tabSize": 4,
"cSpell.words": [
"deleteable",
"graphfi",
"graphqueryable",
"Invokable",
"queryables"
],
}
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- All GraphQueryable*, _GraphQueryable*, and IGraphQueryable* have been renamed to remove "Queryable" (ex: GraphQueryableCollection is now GraphCollection)
- @pnp/graph/onedrive renamed to @pnp/graph/files
- ISites.getByUrl is now async
- @pnp/graph/outlook is not in @pnp/graph/mail, included all mail endpoints
- mailCategory.add() returns Microsoft Graph types OutlookCategory vs object with data property.

- sp
- _Items and IItems now supports async iterator pattern
Expand Down
38 changes: 38 additions & 0 deletions docs/graph/attachments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Graph Attachments

More information can be found in the official Graph documentation:

- [Attachments Resource Type](https://learn.microsoft.com/en-us/graph/api/resources/attachment?view=graph-rest-1.0)

Attachments work with [Calendar Events](./calendars.md), [Mail Message](./mail-messages.md), and [Conversation Thread Posts](./conversations.md). The samples below are generic on purpose.

## IAttachment, IAttachments

[![Invokable Banner](https://img.shields.io/badge/Invokable-informational.svg)](../concepts/invokable.md) [![Selective Imports Banner](https://img.shields.io/badge/Selective%20Imports-informational.svg)](../concepts/selective-imports.md)

## Get Attachments

```TypeScript
import { graphfi } from "@pnp/graph";
// Imports required for the object you're obtaining attachments for.
import "@pnp/graph/attachments";

const graph = graphfi(...);

const event_message_post = graph.xxx;
const a = await event_message_post.attachments();
```

## Get Attachment By Id

```TypeScript
import { graphfi } from "@pnp/graph";
// Imports required for the object you're obtaining attachments for.
import "@pnp/graph/attachments";

const graph = graphfi(...);

const event_message_post = graph.xxx;
const attachmentId = "";
const a = await event_message_post.attachments.getById(attachmentId)();
```
4 changes: 4 additions & 0 deletions docs/graph/calendars.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,7 @@ const instances2 = await event.instances("2020-01-01", "2020-03-01").select("sub
// you can specify times along with the dates
const instance3 = await event.instances("2020-01-01T19:00:00-08:00", "2020-03-01T19:00:00-08:00")();
```

## Event Attachments

See [Attachments](./attachments.md)
294 changes: 294 additions & 0 deletions docs/graph/conversations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
# Graph Conversations

More information can be found in the official Graph documentation:

- [Conversation Resource Type](https://learn.microsoft.com/en-us/graph/api/resources/conversation?view=graph-rest-1.0)
- [Conversation Thread Resource Type](https://learn.microsoft.com/en-us/graph/api/resources/conversationthread?view=graph-rest-1.0)
- [Post Resource Type](https://learn.microsoft.com/en-us/graph/api/resources/post?view=graph-rest-1.0)

## IConversation, IConversations, IPost, IPostForwardInfo, IPosts, ISenders, IThread, IThreads

[![Invokable Banner](https://img.shields.io/badge/Invokable-informational.svg)](../concepts/invokable.md) [![Selective Imports Banner](https://img.shields.io/badge/Selective%20Imports-informational.svg)](../concepts/selective-imports.md)

## Get Group Accepted/Rejected Senders

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";

const graph = graphfi(...);

const accepted = await graph.groups.getById(groupId).acceptedSenders();
const rejected = await graph.groups.getById(groupId).rejectedSenders();
```

## Add Group Accepted/Rejected Senders

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";

const graph = graphfi(...);

const sender = "https://graph.microsoft.com/v1.0/users/[email protected]";
await graph.groups.getById(groupId).acceptedSenders.add(sender);
await graph.groups.getById(groupId).rejectedSenders.add(sender);
```

## Delete Group Accepted/Rejected Senders

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";

const graph = graphfi(...);

const sender = "https://graph.microsoft.com/v1.0/users/[email protected]";
await graph.groups.getById(groupId).acceptedSenders.remove(sender);
await graph.groups.getById(groupId).rejectedSenders.remove(sender);
```

## Get Group Conversations

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";

const graph = graphfi(...);

const c = await graph.groups.getById(groupId).conversations();
```

## Get Group Conversation by Id

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";

const graph = graphfi(...);

const conversationId = "";
const c = await graph.groups.getById(groupId).conversations.getById(conversationId)();
```

## Add/Update/Delete a Group Conversation

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";
import { Conversation } from "@microsoft/microsoft-graph-types";

const graph = graphfi(...);

const conversation: Conversation = {
topic: "My New Conversation",
...
};

const c = await graph.groups.getById(groupId).conversations.add(conversation);

const conversationId = "";
const update = await graph.groups.getById(groupId).conversations.getById(conversationId)
.update({topic: "My Conversation"});
await graph.groups.getById(groupId).conversations.getById(conversationId).delete();
```

## Get Group Conversation Threads

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";
import { Conversation } from "@microsoft/microsoft-graph-types";

const graph = graphfi(...);

const groupId = "";
const conversationId = "";
const t = await graph.groups.getById(groupId).conversations.getById(conversationId).threads();
```

## Get Group Conversation Thread by Id

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";

const graph = graphfi(...);

const conversationId = "";
const threadId = "";
const c = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId)();
```

## Create/Update/Delete a Group Conversation Thread

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";
import { ConversationThread } from "@microsoft/microsoft-graph-types";

const graph = graphfi(...);

const conversationThread: ConversationThread = {
topic: "My New Conversation",
...
};

const conversationId = "";
const t = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.add(conversationThread);

const threadId = "";
const update = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId)
.update({topic: "My Conversation"});
await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).delete();
```

## Reply to a Group Conversation Thread

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";
import { Post } from "@microsoft/microsoft-graph-types";

const graph = graphfi(...);

const post: Post = {
body: { content: "This is a post" },
from: {
emailAddress: {
address: "",
name: "",
},
},
};

const conversationId = "";
const threadId = "";
const reply = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).reply(post);
```

## Get Group Conversation Thread Posts

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";

const graph = graphfi(...);

const groupId = "";
const conversationId = "";
const threadId = "";
const p = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).posts();
```

## Get Group Conversation Thread Post by Id

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";

const graph = graphfi(...);

const conversationId = "";
const threadId = "";
const postId = "";
const p = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).posts.getById(postId)();
```

## Create/Update/Delete a Group Conversation Thread Post

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";
import { Post } from "@microsoft/microsoft-graph-types";

const graph = graphfi(...);

const post: Post = {
body: { content: "This is a post" },
from: {
emailAddress: {
address: "",
name: "",
},
},
};

const conversationId = "";
const threadId = "";
const p = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).posts.add(post);

const postId = "";
const update = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).posts.getById(postId)
.update({body: {content: "New Post Content"}});
await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).posts.getById(postId).delete();
```

## Reply to a Group Conversation Thread Post

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";
import { Post } from "@microsoft/microsoft-graph-types";

const graph = graphfi(...);

const post: Post = {
body: { content: "This is a post" },
from: {
emailAddress: {
address: "",
name: "",
},
},
};

const conversationId = "";
const threadId = "";
const reply = await graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).posts.getById(postId).reply(post);
```

## Forward a Group Conversation Thread Post

```TypeScript
import { graphfi } from "@pnp/graph";
import "@pnp/graph/groups";
import "@pnp/graph/conversations";
import { IPostForwardInfo } from "@pnp/graph/conversations";

const graph = graphfi(...);

const postForwardInfo: IPostForwardInfo = {
toRecipients: [
{
emailAddress: {
address: "",
name: "",
},
},
],
};

const conversationId = "";
const threadId = "";
const post = graph.groups.getById(groupId).conversations.getById(conversationId).threads.getById(threadId).posts.getById(postId);
await post.forward(postForwardInfo);
```

## Group Conversation Thread Post Attachments

See [Attachments](./attachments.md)
12 changes: 8 additions & 4 deletions docs/graph/groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ const endDate = new Date("2020-03-01");
const events = graph.groups.getById("7d2b9355-0891-47d3-84c8-bf2cd9c62177").getCalendarView(startDate, endDate);
```

## Group Photo Operations

See [Photos](./photos.md)

## Group Membership

Get the members and/or owners of a group.
Expand All @@ -162,3 +158,11 @@ const graph = graphfi(...);
const teamSite = await graph.groups.getById("7d2b9355-0891-47d3-84c8-bf2cd9c62177").sites.root();
const url = teamSite.webUrl
```

## Group Photo Operations

See [Photos](./photos.md)

## Group Conversation Operations

See [Conversations](./conversations.md)
4 changes: 1 addition & 3 deletions docs/graph/outlook.md → docs/graph/mail-categories.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# @pnp/graph/outlook

Represents the Outlook services available to a user. Currently, only interacting with categories is supported.
# Graph Mail Categories

You can learn more by reading the [Official Microsoft Graph Documentation](https://docs.microsoft.com/en-us/graph/api/resources/outlookuser?view=graph-rest-1.0).

Expand Down
Loading