/// <summary> /// Constructor /// </summary> /// <param name="richMenuId"> /// Rich menu ID /// </param> /// <param name="source"> /// Rich menu object /// </param> public ResponseRichMenu(string richMenuId, RichMenu source) { RichMenuId = richMenuId; Size = source.Size; Selected = source.Selected; Name = source.Name; ChatBarText = source.ChatBarText; Areas = source.Areas; }
/// <summary> /// Creates a rich menu. /// Note: You must upload a rich menu image and link the rich menu to a user for the rich menu to be displayed.You can create up to 10 rich menus for one bot. /// The rich menu represented as a rich menu object. /// https://developers.line.me/en/docs/messaging-api/reference/#create-rich-menu /// </summary> /// <param name="richMenu">RichMenu</param> /// <returns>RichMenu Id</returns> public async Task <string> CreateRichMenuAsync(RichMenu richMenu) { var request = new HttpRequestMessage(HttpMethod.Post, $"{_uri}/bot/richmenu"); var content = JsonConvert.SerializeObject(richMenu, _jsonSerializerSettings); request.Content = new StringContent(content, Encoding.UTF8, "application/json"); var response = await _client.SendAsync(request).ConfigureAwait(false); await response.EnsureSuccessStatusCodeAsync().ConfigureAwait(false); var json = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeAnonymousType(json, new { richMenuId = "" }).richMenuId); }
internal static ResponseRichMenu CreateFrom(dynamic dynamicObject) { var areas = new List <ActionArea>(); foreach (var area in dynamicObject?.areas ?? Enumerable.Empty <dynamic>()) { areas.Add(ActionArea.CreateFrom(area)); } var menu = new RichMenu() { Name = (string)dynamicObject?.name, Size = new ImagemapSize((int)(dynamicObject?.size?.width ?? 0), (int)(dynamicObject?.size?.height ?? 0)), Selected = (bool)(dynamicObject?.selected ?? false), ChatBarText = (string)dynamicObject?.chatBarText, Areas = areas }; return(new ResponseRichMenu((string)dynamicObject?.richMenuId, menu)); }