Skip to content

Commit

Permalink
Merge pull request #2720 from patrick-rodgers/version-3
Browse files Browse the repository at this point in the history
fix and docs update for #2567
  • Loading branch information
patrick-rodgers authored Jun 16, 2023
2 parents d33b121 + 585acb9 commit 3692937
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 6 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ coverage
.eslintrc.cjs
debug
buildsystem-config.ts
settings.js
14 changes: 12 additions & 2 deletions docs/graph/teams.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ const newChannel = await graph.teams.getById('3531f3fb-f9ee-4f43-982a-6c90d82265

```

## List Messages

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

const graph = graphfi(...);

const chatMessages = await graph.teams.getById('3531fzfb-f9ee-4f43-982a-6c90d8226528').channels.getById('19:65723d632b384xa89c81115c281428a3@thread.skype').messages();
```

## Add chat message to Channel

```TypeScript
Expand All @@ -197,8 +208,7 @@ const message = {
"content": "Hello World"
}
}
const chatMessage: ChatMessage = await graph.teams.getById('3531f3fb-f9ee-4f43-982a-6c90d8226528').channels.getById('19:65723d632b384ca89c81115c281428a3@thread.skype').messages(message);

const chatMessage: ChatMessage = await graph.teams.getById('3531fzfb-f9ee-4f43-982a-6c90d8226528').channels.getById('19:65723d632b384xa89c81115c281428a3@thread.skype').messages.add(message);
```

## Get installed Apps
Expand Down
51 changes: 47 additions & 4 deletions packages/graph/teams/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ export const Teams = graphInvokableFactory<ITeams>(_Teams);
/**
* Channel
*/
export class _Channel extends _GraphQueryableInstance {
export class _Channel extends _GraphQueryableInstance<IChannel> {
public get tabs(): ITabs {
return Tabs(this);
}

public async messages(message: IChatMessage): Promise<IChatMessage> {
return graphPost(Channel(this, "messages"), body(message));
public get messages(): IMessages {
return Messages(this);
}
}
export interface IChannel extends _Channel { }
Expand All @@ -147,7 +147,7 @@ export const Channel = graphInvokableFactory<IChannel>(_Channel);
*/
@defaultPath("channels")
@getById(Channel)
export class _Channels extends _GraphQueryableCollection {
export class _Channels extends _GraphQueryableCollection<IChannel[]> {

/**
* Creates a new Channel in the Team
Expand All @@ -173,6 +173,44 @@ export class _Channels extends _GraphQueryableCollection {
export interface IChannels extends _Channels, IGetById<IChannel> { }
export const Channels = graphInvokableFactory<IChannels>(_Channels);

/**
* Channel
*/
export class _Message extends _GraphQueryableInstance<IChatMessage> { }
export interface IMessage extends _Message { }
export const Message = graphInvokableFactory<IMessage>(_Message);

/**
* Channels
*/
@defaultPath("messages")
@getById(Message)
export class _Messages extends _GraphQueryableCollection<IChatMessage[]> {

/**
* Creates a new Channel in the Team
* @param displayName The display name of the new channel
* @param description Optional description of the channel
*
*/
public async add(displayName: string, description = ""): Promise<IMessageCreateResult> {

const postBody = {
description,
displayName,
};

const data = await graphPost(this, body(postBody));

return {
message: (<any>this).getById(data.id),
data,
};
}
}
export interface IMessages extends _Messages, IGetById<IMessage> { }
export const Messages = graphInvokableFactory<IMessages>(_Messages);

/**
* Tab
*/
Expand Down Expand Up @@ -225,6 +263,11 @@ export interface IChannelCreateResult {
channel: IChannel;
}

export interface IMessageCreateResult {
data: any;
message: IMessage;
}

export interface ITabCreateResult {
data: any;
tab: ITab;
Expand Down

0 comments on commit 3692937

Please sign in to comment.