Пример #1
0
        public void Should_send_successfully_and_had_four_button_in_two_row()
        {
            GapClient     gapClient = new GapClient(Token);
            ReplyKeyboard keyboard  = new ReplyKeyboard();

            keyboard.AddRow(new List <ReplyKeyboardItem>()
            {
                new ReplyKeyboardItem("item1", "value one"),
                new ReplyKeyboardItem("item2", "value two"),
            });

            keyboard.AddRow(new List <ReplyKeyboardItem>()
            {
                new ReplyKeyboardLocationItem("location"),
                new ReplyKeyboardContactItem("contact")
            });

            Message message = new Message
            {
                ChatId        = ChatId,
                Data          = "salam iran",
                ReplyKeyboard = keyboard
            };


            PostResult result = gapClient.Send(message).Result;

            result.StatusCode.Should().Be(StatusCode.Success);
        }
Пример #2
0
        public void Client_should_receive_a_form_whit_all_input_types()
        {
            GapClient gapClient = new GapClient(Token);

            Message message = new Message()
            {
                ChatId = ChatId,
                Data   = "فرم زیر با پر نمایید"
            };


            FormItem inputForm = new FormItem()
            {
                Label = "name",
                Name  = "name",
                Type  = FormType.Text
            };

            FormItem checkboxForm = new FormItem()
            {
                Label = "checkbox label",
                Name  = "chk",
                Type  = FormType.Checkbox
            };

            FormItemOptional listForm = new FormItemOptional()
            {
                Label   = "list label",
                Name    = "listLbl",
                Type    = FormType.Select,
                Options = new List <KeyValuePair <string, string> >()
                {
                    new KeyValuePair <string, string>("row1", "row 1"),
                    new KeyValuePair <string, string>("row2", "row 2")
                }
            };


            message.Form = new Form
            {
                inputForm,
                checkboxForm,
                listForm
            };


            PostResult result = gapClient.Send(message).Result;

            result.Id.Should().NotBeNull();
            result.ErrorMessage.Should().BeNull();
            result.StatusCode.Should().Be(200);
        }
Пример #3
0
        public void Should_get_invalid_token_error_on_send_text_message()
        {
            GapClient gapClient = new GapClient(Utils.ReadValue("token"));
            Message   message   = new Message()
            {
                ChatId = "invalid id", // invalid chat id
                Data   = "salam iran"
            };


            PostResult result = gapClient.Send(message).Result;

            result.StatusCode.Should().Be(StatusCode.InvalidChatIdOrToken);
        }
Пример #4
0
        public void Should_send_2X2_reply_keyboard()
        {
            GapClient gapClient = new GapClient(Token);
            Message   message   = new Message()
            {
                ChatId        = ChatId,
                ReplyKeyboard = ReplyKeyboard.Builder().AddGetContact("share phone").Add("button two").AddRow().AddRow().AddGetLocation("share location").Add("button four").Build(),
                Data          = "send to me your phone or location"
            };


            PostResult postResult = gapClient.Send(message).Result;

            postResult.StatusCode.Should().Be(StatusCode.Success);
        }
Пример #5
0
        public void Should_send_an_get_contact_inline_button()
        {
            GapClient gapClient = new GapClient(Token);
            Message   message   = new Message()
            {
                ChatId        = ChatId,
                ReplyKeyboard = ReplyKeyboard.Builder().AddGetContact("share phone").Build(),
                Data          = "let me khnow your phone number..."
            };


            PostResult postResult = gapClient.Send(message).Result;

            postResult.StatusCode.Should().Be(StatusCode.Success);
        }
Пример #6
0
        public void Delete_message()
        {
            GapClient gapClient = new GapClient(Token);

            Message message = new Message
            {
                ChatId = ChatId,
                Data   = "salam donya"
            };

            PostResult postResult = gapClient.Send(message).Result;
            MessageId  messageId  = Newtonsoft.Json.JsonConvert.DeserializeObject <MessageId>(postResult.RawBody);

            PostResult deleteResult = gapClient.Delete(ChatId, messageId.Id).Result;

            deleteResult.StatusCode.Should().Be(200);
        }
Пример #7
0
        public void Upload_and_send_an_textFile_to_the_client()
        {
            GapClient  gapClient       = new GapClient(Token);
            string     fileDescription = "some desc";
            PostResult uploadResult    = gapClient.Upload(FilesDirectory + "sampleText.txt", "textfile.txt", UploadFileType.File, fileDescription).Result;
            File       file            = Utils.Deserialize <File>(uploadResult.RawBody);

            file.Desc = fileDescription;
            Message message = new Message(MessageType.File)
            {
                ChatId = ChatId,
                Data   = Utils.Serialize(file)
            };

            PostResult postResult = gapClient.Send(message).Result;

            postResult.StatusCode.Should().Be(StatusCode.Success);
        }
Пример #8
0
        public void Upload_and_send_an_image_to_the_client()
        {
            GapClient  gapClient       = new GapClient(Token);
            string     fileDescription = "coolzila :)";
            PostResult uploadResult    = gapClient.Upload(FilesDirectory + "godzila.jpg", "godzila.jpg", UploadFileType.Image, fileDescription).Result;
            File       file            = Utils.Deserialize <File>(uploadResult.RawBody);

            file.Desc = fileDescription;
            Message message = new Message(MessageType.Image)
            {
                ChatId = ChatId,
                Data   = Utils.Serialize(file)
            };

            PostResult postResult = gapClient.Send(message).Result;

            postResult.StatusCode.Should().Be(StatusCode.Success);
        }
Пример #9
0
        public void Upload_and_send_an_mp3_to_the_client()
        {
            GapClient  gapClient       = new GapClient(Token);
            string     fileDescription = "FiveFin"; // 4.7MB
            PostResult uploadResult    = gapClient.Upload(FilesDirectory + "FiveF.mp3", "haghighat_audio.mp3", UploadFileType.Audio, fileDescription).Result;
            File       file            = Utils.Deserialize <File>(uploadResult.RawBody);

            file.Desc = fileDescription;
            Message message = new Message(MessageType.Audio)
            {
                ChatId = ChatId,
                Data   = Utils.Serialize(file)
            };

            PostResult postResult = gapClient.Send(message).Result;

            postResult.StatusCode.Should().Be(StatusCode.Success);
        }