private QuickReply(QuickReplyContentType type, string title, string payload, string url) { if (type == QuickReplyContentType.Text && string.IsNullOrEmpty(title)) { throw new ArgumentException("Text quick replies should not have a null or empty title", nameof(title)); } if (type == QuickReplyContentType.Text && string.IsNullOrEmpty(payload)) { throw new ArgumentException("Text quick replies should not have a null or empty payload", nameof(payload)); } ContentType = type; Title = title; Payload = payload; ImageUrl = url; }
/// <summary> /// Adds a quick reply of type <see cref="QuickReplyContentType.Location"/>, <see cref="QuickReplyContentType.UserEmail"/> or <see cref="QuickReplyContentType.UserPhoneNumber"/>. /// </summary> /// <param name="type">The quick reply type. Must not be Text.</param> internal void AddQuickReply(QuickReplyContentType type) { //todo check if postback is also sent if type is not Text switch (type) { case QuickReplyContentType.Text: throw new ArgumentException("Type must not be 'Text'. Call method AddTextQuickReply."); case QuickReplyContentType.Location: AssureQuickReplyCreated(); MessageEntity.QuickReplies.Add(new QuickReplyEntity { ContentType = "location" }); break; case QuickReplyContentType.UserPhoneNumber: AssureQuickReplyCreated(); MessageEntity.QuickReplies.Add(new QuickReplyEntity { ContentType = "user_phone_number" }); break; case QuickReplyContentType.UserEmail: AssureQuickReplyCreated(); MessageEntity.QuickReplies.Add(new QuickReplyEntity { ContentType = "user_email" }); break; default: throw new QuickReplyContentTypeNotSupportedException(type); } }
public QuickReplyContentTypeNotSupportedException(QuickReplyContentType type) : base($"Invalid quick reply content type: {type.ToString()}") { }
/// <summary> /// Adds a quick reply of type <see cref="QuickReplyContentType.Location"/>, <see cref="QuickReplyContentType.UserEmail"/> or <see cref="QuickReplyContentType.UserPhoneNumber"/>. /// </summary> /// <param name="type">The quick reply type. Must not be Text.</param> public MessageOptionalElementSetter AddQuickReply(QuickReplyContentType type) { _message.AddQuickReply(type); return(this); }