Table of Contents

Class RichMenuClient

Namespace
Line.OpenApi.Messaging
Assembly
Line.OpenApi.Messaging.dll

Facade for the Rich Menu use case. Rich Menu spans both Messaging hosts — control operations on api.line.me and image upload/download on api-data.line.me — so this facade wraps a MessagingClient (which already solves the host split / BaseUrl handling) and exposes the common create → image → set-default → link flow through thin convenience methods.

The generated builders remain available via Messaging (.Api for control, .Blob for image data plane) for the less common operations (alias CRUD, bulk link/unlink, batch) that are intentionally not surfaced here.

The image helpers are the main ergonomic value: SetImageFromFileAsync(string, string, CancellationToken) infers the required image/png / image/jpeg content type from the file extension, which LINE mandates for the upload (the generated builder requires it as an explicit argument).

Usage: var rich = RichMenuClient.CreateWithStaticToken("CHANNEL_ACCESS_TOKEN"); var id = await rich.CreateAsync(new RichMenuRequest { /* ... */ }); await rich.SetImageFromFileAsync(id!, "menu.png"); await rich.SetDefaultAsync(id!);

public sealed class RichMenuClient
Inheritance
RichMenuClient
Inherited Members

Constructors

RichMenuClient(MessagingClient)

Wraps an existing MessagingClient.

public RichMenuClient(MessagingClient messaging)

Parameters

messaging MessagingClient

RichMenuClient(IAuthenticationProvider, HttpClient?)

public RichMenuClient(IAuthenticationProvider authProvider, HttpClient? httpClient = null)

Parameters

authProvider IAuthenticationProvider

Authentication provider (static or refreshing, either works).

httpClient HttpClient

The HttpClient shared by the adapters. Supplied by IHttpClientFactory via DI. When null, a default HttpClient is created (for quick use).

Properties

Messaging

The underlying Messaging client (exposed for low-level operations: alias / bulk / batch).

public MessagingClient Messaging { get; }

Property Value

MessagingClient

Methods

CancelDefaultAsync(CancellationToken)

Cancels the default rich menu (DELETE /v2/bot/user/all/richmenu).

public Task CancelDefaultAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task

CreateWithStaticToken(string)

Helper to quickly construct from a long-lived channel access token.

public static RichMenuClient CreateWithStaticToken(string channelAccessToken)

Parameters

channelAccessToken string

Returns

RichMenuClient

DeleteAsync(string, CancellationToken)

Deletes a rich menu (DELETE /v2/bot/richmenu/{richMenuId}).

public Task DeleteAsync(string richMenuId, CancellationToken cancellationToken = default)

Parameters

richMenuId string
cancellationToken CancellationToken

Returns

Task

GetAsync(string, CancellationToken)

Gets a rich menu by id (GET /v2/bot/richmenu/{richMenuId}). Returns null if the id does not exist.

public Task<RichMenuResponse?> GetAsync(string richMenuId, CancellationToken cancellationToken = default)

Parameters

richMenuId string
cancellationToken CancellationToken

Returns

Task<RichMenuResponse>

GetDefaultIdAsync(CancellationToken)

Gets the default rich menu id (GET /v2/bot/user/all/richmenu). Returns null if none is set (LINE returns 404).

public Task<string?> GetDefaultIdAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<string>

GetIdOfUserAsync(string, CancellationToken)

Gets the rich menu id linked to a user (GET /v2/bot/user/{userId}/richmenu). Returns null if none (LINE returns 404).

public Task<string?> GetIdOfUserAsync(string userId, CancellationToken cancellationToken = default)

Parameters

userId string
cancellationToken CancellationToken

Returns

Task<string>

GetImageAsync(string, CancellationToken)

Downloads the rich menu image (GET /v2/bot/richmenu/{richMenuId}/content, data plane).

public Task<Stream?> GetImageAsync(string richMenuId, CancellationToken cancellationToken = default)

Parameters

richMenuId string
cancellationToken CancellationToken

Returns

Task<Stream>

InferImageContentType(string)

Maps a rich menu image file extension to its required content type.

public static string InferImageContentType(string filePath)

Parameters

filePath string

Returns

string

LinkToUserAsync(string, string, CancellationToken)

Links a rich menu to a user (POST /v2/bot/user/{userId}/richmenu/{richMenuId}).

public Task LinkToUserAsync(string userId, string richMenuId, CancellationToken cancellationToken = default)

Parameters

userId string
richMenuId string
cancellationToken CancellationToken

Returns

Task

ListAsync(CancellationToken)

Lists the channel's rich menus (GET /v2/bot/richmenu/list).

public Task<RichMenuListResponse?> ListAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<RichMenuListResponse>

SetDefaultAsync(string, CancellationToken)

Sets the default rich menu for all users (POST /v2/bot/user/all/richmenu/{richMenuId}).

public Task SetDefaultAsync(string richMenuId, CancellationToken cancellationToken = default)

Parameters

richMenuId string
cancellationToken CancellationToken

Returns

Task

SetImageAsync(string, Stream, string, CancellationToken)

Uploads the rich menu image (POST /v2/bot/richmenu/{richMenuId}/content, data plane). contentType must be image/png or image/jpeg.

public Task SetImageAsync(string richMenuId, Stream image, string contentType, CancellationToken cancellationToken = default)

Parameters

richMenuId string
image Stream
contentType string
cancellationToken CancellationToken

Returns

Task

SetImageFromFileAsync(string, string, CancellationToken)

Uploads the rich menu image from a file, inferring the content type from the extension (.png → image/png, .jpg/.jpeg → image/jpeg). Other extensions are rejected.

public Task SetImageFromFileAsync(string richMenuId, string filePath, CancellationToken cancellationToken = default)

Parameters

richMenuId string
filePath string
cancellationToken CancellationToken

Returns

Task

UnlinkFromUserAsync(string, CancellationToken)

Unlinks the rich menu from a user (DELETE /v2/bot/user/{userId}/richmenu).

public Task UnlinkFromUserAsync(string userId, CancellationToken cancellationToken = default)

Parameters

userId string
cancellationToken CancellationToken

Returns

Task