2022-09-08 08:04:32 -07:00

55 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace LineMessaging
{
public partial class LineMessagingClient
{
private const string RoomMemberApiPath = "/v2/bot/room/{0}/member/{1}";
private const string RoomMembersApiPath = "/v2/bot/room/{0}/members/ids";
private const string LeaveRoomApiPath = "/v2/bot/room/{0}/leave";
public async Task<LineProfile> GetRoomMember(string roomId, string userId)
{
if (string.IsNullOrEmpty(roomId))
{
throw new ArgumentException($"{nameof(roomId)} is null or empty.");
}
if (string.IsNullOrEmpty(userId))
{
throw new ArgumentException($"{nameof(userId)} is null or empty.");
}
return await Get<LineProfile>(string.Format(RoomMemberApiPath, roomId, userId));
}
public async Task<LineMembers> GetRoomMembers(string roomId, string start = null)
{
if (string.IsNullOrEmpty(roomId))
{
throw new ArgumentException($"{nameof(roomId)} is null or empty.");
}
var query = new Dictionary<string, object>();
if (start != null)
{
query["start"] = start;
}
return await Get<LineMembers>(string.Format(RoomMembersApiPath, roomId), query);
}
public async Task LeaveRoom(string roomId)
{
if (string.IsNullOrEmpty(roomId))
{
throw new ArgumentException($"{nameof(roomId)} is null or empty.");
}
await Post(string.Format(LeaveRoomApiPath, roomId));
}
}
}