Exemplo n.º 1
0
        public InlineKeyboardBuilder AddButton(string text)
        {
            InlineKeyboardItem item = InlineKeyboardItem.Simple(text, text, null);

            rowItems.Add(item);

            return(this);
        }
Exemplo n.º 2
0
        public InlineKeyboardBuilder AddButton(string text, string callbackData, string description = null)
        {
            InlineKeyboardItem item = InlineKeyboardItem.Simple(text, callbackData, description);

            rowItems.Add(item);

            return(this);
        }
Exemplo n.º 3
0
        public InlineKeyboardBuilder AddOpenUrl(string buttonText, string url, OpenMode openMode = OpenMode.Webview, string description = null, string callbackDataTrigger = null)
        {
            InlineKeyboardItem item = InlineKeyboardItem.OpenUrl(buttonText, url, openMode, description, callbackDataTrigger);

            rowItems.Add(item);

            return(this);
        }
Exemplo n.º 4
0
        public InlineKeyboardBuilder AddPayment(string buttonText, int amount, string refId, string description, Currency currency = Currency.IRR)
        {
            InlineKeyboardItem item = InlineKeyboardItem.Payment(buttonText, amount, refId, description, currency);

            rowItems.Add(item);

            return(this);
        }
Exemplo n.º 5
0
        public void Inline_keyboard_serialization_must_be_equal_to_expected()
        {
            InlineKeyboard inlineKeyboard = new InlineKeyboard();

            inlineKeyboard.AddRow(new List <InlineKeyboardItem>()
            {
                InlineKeyboardItem.Simple("simple button", "btnSmpTapped"),
                InlineKeyboardItem.Payment("payment", 5000, "GUID/refId", "give me that.."),
                InlineKeyboardItem.OpenUrl("bing", "https://bing.com")
            });

            string result   = Utils.Serialize(inlineKeyboard).Replace(" ", "").ToLower();
            string expected = Utils.ReadFile(JsonsDirectory + "text\\inlineKeyboard.txt").Replace("\n", "").Replace("\r", "").Replace(" ", "").ToLower();

            result.Should().Be(expected);
        }
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            InlineKeyboardItem replyKeyboard = (InlineKeyboardItem)value;
            JObject            jsonObject    = new JObject();

            foreach (PropertyInfo info in replyKeyboard.GetType().GetProperties())
            {
                if (info.GetValue(replyKeyboard) == null)
                {
                    continue;
                }
                else
                {
                    jsonObject.Add(GapContractResolver.GetGapNamingConvention(info.Name), info.GetValue(replyKeyboard).ToString());
                }
            }

            jsonObject.WriteTo(writer);
            writer.Flush();
        }
Exemplo n.º 7
0
 public InlineKeyboardBuilder AddOpenUrl(InlineKeyboardItem inlineKeyboardItem)
 {
     AddOpenUrl(inlineKeyboardItem.Text, inlineKeyboardItem.Url, inlineKeyboardItem.OpenIn ?? OpenMode.Browser, inlineKeyboardItem.Desc, inlineKeyboardItem.CbData);
     return(this);
 }
Exemplo n.º 8
0
 public InlineKeyboardBuilder AddPayment(InlineKeyboardItem inlineKeyboardItem)
 {
     AddPayment(inlineKeyboardItem.Text, inlineKeyboardItem.Amount.Value, inlineKeyboardItem.RefId, inlineKeyboardItem.Desc, inlineKeyboardItem.Currency ?? Currency.IRR);
     return(this);
 }