Skip to content

Commit

Permalink
Update docs according to rich menu API addition
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyunje Jun committed Nov 2, 2017
1 parent 21844f1 commit 261630b
Showing 1 changed file with 178 additions and 40 deletions.
218 changes: 178 additions & 40 deletions docs/pages/api-reference/client.md
Expand Up @@ -9,19 +9,37 @@ corresponding to [messaging APIs](https://developers.line.me/en/docs/messaging-a
class Client {
public config: ClientConfig

constructor(config: ClientConfig)
constructor(config: ClientConfig) {}

pushMessage(to: string, messages: Message | Message[]): Promise<{}>
replyMessage(replyToken: string, messages: Message | Message[]): Promise<{}>
multicast(to: string[], messages: Message | Message[]): Promise<{}>
// Message
pushMessage(to: string, messages: Message | Message[]): Promise<any>
replyMessage(replyToken: string, messages: Message | Message[]): Promise<any>
multicast(to: string[], messages: Message | Message[]): Promise<any>
getMessageContent(messageId: string): Promise<Readable>

// Profile
getProfile(userId: string): Promise<Profile>

// Group
getGroupMemberProfile(groupId: string, userId: string): Promise<Profile>
getRoomMemberProfile(roomId: string, userId: string): Promise<Profile>
getGroupMemberIds(groupId: string): Promise<string[]>
leaveGroup(groupId: string): Promise<any>

// Room
getRoomMemberProfile(roomId: string, userId: string): Promise<Profile>
getRoomMemberIds(roomId: string): Promise<string[]>
getMessageContent(messageId: string): Promise<ReadableStream>
leaveGroup(groupId: string): Promise<{}>
leaveRoom(roomId: string): Promise<{}>
leaveRoom(roomId: string): Promise<any>

// Rich menu
getRichMenu(richMenuId: string): Promise<RichMenuResponse>
createRichMenu(richMenu: RichMenu): Promise<string>
deleteRichMenu(richMenuId: string): Promise<any>
getRichMenuIdOfUser(userId: string): Promise<string>
linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>
unlinkRichMenuFromUser(userId: string, richMenuId: string): Promise<any>
getRichMenuImage(richMenuId: string): Promise<Readable>
setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>
getRichMenuList(): Promise<Array<RichMenuResponse>>
}
```

Expand Down Expand Up @@ -51,7 +69,9 @@ goes wrong, such as HTTP errors or parsing errors. You can catch them with the
`.catch()` method of the promises. The detailed error handling is explained
in [the Client guide](../guide/client.md).

### `pushMessage(to: string, messages: Message | Message[]): Promise<{}>`
### Message

#### `pushMessage(to: string, messages: Message | Message[]): Promise<any>`

It corresponds to the [Push message](https://developers.line.me/en/docs/messaging-api/reference/#send-push-message) API.

Expand All @@ -64,7 +84,7 @@ client.pushMessage('user_or_group_or_room_id', {
})
```

### `replyMessage(replyToken: string, messages: Message | Message[]): Promise<{}>`
#### `replyMessage(replyToken: string, messages: Message | Message[]): Promise<any>`

It corresponds to the [Reply message](https://developers.line.me/en/docs/messaging-api/reference/#send-reply-message) API.

Expand All @@ -79,7 +99,7 @@ client.replyMessage(event.replyToken, {
})
```

### `multicast(to: string[], messages: Message | Message[]): Promise<{}>`
#### `multicast(to: string[], messages: Message | Message[]): Promise<any>`

It corresponds to the [Multicast](https://developers.line.me/en/docs/messaging-api/reference/#send-multicast-messages) API.

Expand All @@ -93,7 +113,32 @@ client.multicast(['user_id_1', 'user_id_2', 'room_id_1'], {
})
```

### `getProfile(userId: string): Promise<Profile>`
#### `getMessageContent(messageId: string): Promise<Readable>`

It corresponds to the [Content](https://developers.line.me/en/docs/messaging-api/reference/#get-content) API.

The argument is an ID of media messages, such as image, video, and audio. The ID
can be retrieved from a message object of a message event.

Please beware that what it returns is promise of [readable stream](https://nodejs.org/dist/latest/docs/api/stream.html#stream_readable_streams).
You can pipe the stream into a file, an HTTP response, etc.

``` js
client.getMessageContent('message_id')
.then((stream) => {
stream.on('data', (chunk) => {
...
})
stream.on('error', (err) => {
...
})
stream.pipe(...)
})
```

### Profile

#### `getProfile(userId: string): Promise<Profile>`

It corresponds to the [Profile](https://developers.line.me/en/docs/messaging-api/reference/#get-profile) API.

Expand All @@ -105,7 +150,9 @@ client.getProfile('user_id').then((profile) => {
});
```

### `getGroupMemberProfile(groupId: string, userId: string): Promise<Profile>`
### Group

#### `getGroupMemberProfile(groupId: string, userId: string): Promise<Profile>`

It corresponds to the [Group Member Profile](https://developers.line.me/en/docs/messaging-api/reference/#get-group-member-profile) API.

Expand All @@ -118,7 +165,33 @@ client.getGroupMemberProfile('group_id', 'user_id').then((profile) => {
})
```

### `getRoomMemberProfile(roomId: string, userId: string): Promise<Profile>`
#### `getGroupMemberIds(groupId: string): Promise<string[]>`

It corresponds to the [Group Member IDs](https://developers.line.me/en/docs/messaging-api/reference/#get-group-member-user-ids) API.

*FYI: This feature is only available for LINE@ Approved accounts or official accounts.*

The argument is a group ID and the method returns a promise of an array of user IDs.

``` js
client.getGroupMemberIds('group_id').then((ids) => {
ids.forEach((id) => console.log(id));
})
```

#### `leaveGroup(groupId: string): Promise<any>`

It corresponds to the [Leave group](https://developers.line.me/en/docs/messaging-api/reference/#leave-group) API.

The argument is a group ID.

``` js
client.leaveGroup('group_id')
```

### Room

#### `getRoomMemberProfile(roomId: string, userId: string): Promise<Profile>`

It corresponds to the [Room Member Profile](https://developers.line.me/en/docs/messaging-api/reference/#get-room-member-profile) API.

Expand All @@ -131,46 +204,111 @@ client.getRoomMemberProfile('room_id', 'user_id').then((profile) => {
})
```

### `getGroupMemberIds(groupId: string): Promise<string[]>`
#### `getRoomMemberIds(roomId: string): Promise<string[]>`

It corresponds to the [Group Member IDs](https://developers.line.me/en/docs/messaging-api/reference/#get-group-member-user-ids) API.
It corresponds to the [Room Member IDs](https://developers.line.me/en/docs/messaging-api/reference/#get-room-member-user-ids) API.

*FYI: This feature is only available for LINE@ Approved accounts or official accounts.*

The argument is a group ID and the method returns a promise of an array of user IDs.
The argument is a room ID and the method returns a promise of an array of user IDs.

``` js
client.getGroupMemberIds('group_id').then((ids) => {
client.getRoomMemberIds('room_id').then((ids) => {
ids.forEach((id) => console.log(id));
})
```

### `getRoomMemberIds(roomId: string): Promise<string[]>`
#### `leaveRoom(roomId: string): Promise<any>`

It corresponds to the [Room Member IDs](https://developers.line.me/en/docs/messaging-api/reference/#get-room-member-user-ids) API.
It corresponds to the [Leave room](https://developers.line.me/en/docs/messaging-api/reference/#leave-room) API.

*FYI: This feature is only available for LINE@ Approved accounts or official accounts.*
The argument is a room ID.

The argument is a room ID and the method returns a promise of an array of user IDs.
``` js
client.leaveGroup('room_id')
```

### Rich menu

#### `getRichMenu(richMenuId: string): Promise<RichMenuResponse>`

It corresponds to the [Get rich menu](https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu) API.

The argument is a rich menu ID. The return type is [a rich menu response object](https://developers.line.me/en/docs/messaging-api/reference/#rich-menu-response-object).

``` js
client.getRoomMemberIds('room_id').then((ids) => {
ids.forEach((id) => console.log(id));
client.getRichMenu('rich_menu_id').then((richMenu) => {
console.log(richMenu.size);
console.log(richMenu.areas[0].bounds);
})
```

### `getMessageContent(messageId: string): Promise<ReadableStream>`
#### `createRichMenu(richMenu: RichMenu): Promise<string>`

It corresponds to the [Content](https://developers.line.me/en/docs/messaging-api/reference/#get-content) API.
It corresponds to the [Create rich menu](https://developers.line.me/en/docs/messaging-api/reference/#create-rich-menu) API.

The argument is an ID of media messages, such as image, video, and audio. The ID
can be retrieved from a message object of a message event.
The argument is [a rich menu object](https://developers.line.me/en/docs/messaging-api/reference/#rich-menu-object).
For the detail of the object format, please refer to the official documentation.
It returns the result rich menu ID.

``` js
client.createRichMenu({ size: { width: 2500, height: 1686 }, ... })
.then((richMenuId) => console.log(richMenuId))
```

#### `deleteRichMenu(richMenuId: string): Promise<any>`

It corresponds to the [Delete rich menu](https://developers.line.me/en/docs/messaging-api/reference/#delete-rich-menu) API.

The argument is a rich menu ID.

``` js
client.deleteRichMenu('rich_menu_id')
```

#### `getRichMenuIdOfUser(userId: string): Promise<string>`

It corresponds to the [Get rich menu ID of user](https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-id-of-user) API.

The argument is a user ID. It returns a rich menu ID to be used with other APIs.

``` js
client.getRichMenuIdOfUser('user_id').then((richMenuId) => {
console.log(richMenuId);
})
```

#### `linkRichMenuToUser(userId: string, richMenuId: string): Promise<any>`

It corresponds to the [Link rich menu to user](https://developers.line.me/en/docs/messaging-api/reference/#link-rich-menu-to-user) API.

The arguments are a user ID and a rich menu ID.

``` js
client.linkRichMenuToUser('user_id', 'rich_menu_id')
```

#### `unlinkRichMenuFromUser(userId: string, richMenuId: string): Promise<any>`

It corresponds to the [Unlink rich menu from user](https://developers.line.me/en/docs/messaging-api/reference/#unlink-rich-menu-from-user) API.

The arguments are a user ID and a rich menu ID.

``` js
client.unlinkRichMenuFromUser('user_id', 'rich_menu_id')
```

#### `getRichMenuImage(richMenuId: string): Promise<Readable>`

It corresponds to the [Download rich menu image](https://developers.line.me/en/docs/messaging-api/reference/#download-rich-menu-image) API.

The argument is a rich menu ID.

Please beware that what it returns is promise of [readable stream](https://nodejs.org/dist/latest/docs/api/stream.html#stream_readable_streams).
You can pipe the stream into a file, an HTTP response, etc.

``` js
client.getMessageContent('message_id')
client.getRichMenuImage('rich_menu_id')
.then((stream) => {
stream.on('data', (chunk) => {
...
Expand All @@ -182,22 +320,22 @@ client.getMessageContent('message_id')
})
```

### `leaveGroup(groupId: string): Promise<{}>`
#### `setRichMenuImage(richMenuId: string, data: Buffer | Readable, contentType?: string): Promise<any>`

It corresponds to the [Leave group](https://developers.line.me/en/docs/messaging-api/reference/#leave-group) API.
It corresponds to the [Upload rich menu image](https://developers.line.me/en/docs/messaging-api/reference/#upload-rich-menu-image) API.

The argument is a group ID.
The 1st argument is a rich menu ID. For 2nd argument, a buffer or a readable
stream of an image should be provided. For the restriction of the image, please
refer to the official documentation. The last argument is optional. If it's not
provided, the mime type will be guessted from `data`. Only `image/jpeg` or
`image/png` is allowed for the content type.

``` js
client.leaveGroup('group_id')
client.setRichMenuImage('rich_menu_id', fs.createReadStream('./some_image.png'))
```

### `leaveRoom(roomId: string): Promise<{}>`

It corresponds to the [Leave room](https://developers.line.me/en/docs/messaging-api/reference/#leave-room) API.
#### `getRichMenuList(): Promise<Array<RichMenuResponse>>`

The argument is a room ID.
It corresponds to the [Get rich menu list](https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-list) API.

``` js
client.leaveGroup('room_id')
```
The return type is a list of [rich menu response objects](https://developers.line.me/en/docs/messaging-api/reference/#rich-menu-response-object).

0 comments on commit 261630b

Please sign in to comment.