public async Task ReceiveAsync(Message message, CancellationToken cancellationToken) { JsonDocument document = new JsonDocument(); document.Add("text", "hello, world!"); //exemplo funcional no messenger await _sender.SendMessageAsync(document, message.From, cancellationToken); }
public async Task ReceiveAsync(Message message, CancellationToken cancellationToken) { //Store last access date var jsonLastAccess = new JsonDocument(); jsonLastAccess.Add("lastAccessDate", DateTimeOffset.Now); await _bucketExtension.SetAsync(message.From.ToString(), jsonLastAccess); //Get last access date await _bucketExtension.GetAsync <JsonDocument>(message.From.ToString()); }
public DocumentSelect getDocumentSelectWithImage() { JsonDocument jsonDocuments = new JsonDocument(); jsonDocuments.Add("action", "show-items"); document2 = new DocumentSelectOption[] { new DocumentSelectOption { Label = new DocumentContainer { Value = new WebLink { Title = "Go to your site", Uri = new Uri("https://meusanimais.com.br/14-nomes-criativos-para-o-seu-gato/") } } }, new DocumentSelectOption { Label = new DocumentContainer { Value = new PlainText { Text = "Show stock here!" } }, Value = new DocumentContainer { Value = jsonDocuments } } }; var document = new DocumentSelect { Header = new DocumentContainer { Value = new MediaLink { Title = "Welcome to mad hatter", Text = "Here we have the best hats for your head.", Type = "image/jpeg", Uri = new Uri("http://i.overboard.com.br/imagens/produtos/0741720126/Ampliada/chapeu-new-era-bucket-print-vibe.jpg"), AspectRatio = "1.1" } }, Options = document2 }; return(document); }
public async Task ReceiveAsync(Message message, CancellationToken cancellationToken) { jsonDocuments = new JsonDocument(); jsonDocuments.Add("Key1", "value1"); jsonDocuments.Add("Key2", "2"); var document = new Select { //Scope = SelectScope.Immediate, (create a quickreply instead menu) Text = "Choice an option:", Options = new SelectOption[] { new SelectOption { Order = 1, Text = "First option!", Value = new PlainText { Text = "1" } }, new SelectOption { Order = 2, Text = "Second option", Value = new PlainText { Text = "2" } }, new SelectOption { Order = 3, Text = "Third option", Value = jsonDocuments } } }; await _sender.SendMessageAsync(document, message.From, cancellationToken); }
public async Task BucketsUnitTest(string commandSuffix) { var jsonDocument = new JsonDocument(); jsonDocument.Add("UnitTest", "success"); var setBucketCommand = new Command { Method = CommandMethod.Set, Uri = new LimeUri($"{commandSuffix}/UnitTests"), Resource = jsonDocument }; var getBucketCommand = new Command { Method = CommandMethod.Get, Uri = new LimeUri($"{commandSuffix}/UnitTests") }; var deleteBucketCommand = new Command { Method = CommandMethod.Delete, Uri = new LimeUri($"{commandSuffix}/UnitTests") }; await _client.SendCommandAsync(setBucketCommand, CancellationToken.None); var resp = await _client.ProcessCommandAsync(getBucketCommand, CancellationToken.None); await _client.SendCommandAsync(deleteBucketCommand, CancellationToken.None); resp.Status.ShouldBe(CommandStatus.Success); resp.To.Domain.ShouldBe("msging.net"); resp.From.Name.ShouldBe("postmaster"); resp.From.Domain.ShouldBe("msging.net"); (resp.Resource as JsonDocument).ShouldNotBeSameAs(jsonDocument); }
public DocumentCollection getDocumentCollectionMenuMultimidia() { jsonDocuments = new JsonDocument(); jsonDocuments2 = new JsonDocument(); jsonDocuments3 = new JsonDocument(); jsonDocuments.Add("Key1", "value1"); jsonDocuments.Add("Key2", "2"); jsonDocuments2.Add("Key3", "value3"); jsonDocuments2.Add("Key4", "4"); jsonDocuments3.Add("Key5", "value5"); jsonDocuments3.Add("Key6", "6"); DocumentSelect[] documents = new DocumentSelect[] { new DocumentSelect { Header = new DocumentContainer { Value = new MediaLink { Title = "Title", Text = "This is a first item", Type = "image/jpeg", Uri = new Uri("http://www.isharearena.com/wp-content/uploads/2012/12/wallpaper-281049.jpg"), } }, Options = new DocumentSelectOption[] { new DocumentSelectOption { Label = new DocumentContainer { Value = new WebLink { Title = "Link", Uri = new Uri("http://www.adoteumgatinho.org.br/") } } }, new DocumentSelectOption { Label = new DocumentContainer { Value = new PlainText { Text = "Text 1" } }, Value = new DocumentContainer { Value = jsonDocuments } } } }, new DocumentSelect { Header = new DocumentContainer { Value = new MediaLink { Title = "Title 2", Text = "This is another item", Type = "image/jpeg", Uri = new Uri("http://www.freedigitalphotos.net/images/img/homepage/87357.jpg") } }, Options = new DocumentSelectOption[] { new DocumentSelectOption { Label = new DocumentContainer { Value = new WebLink { Title = "Second link", Text = "Weblink", Uri = new Uri("https://pt.dreamstime.com/foto-de-stock-brinquedo-pl%C3%A1stico-amarelo-do-pato-image44982058") } } }, new DocumentSelectOption { Label = new DocumentContainer { Value = new PlainText { Text = "Second text" } }, Value = new DocumentContainer { Value = jsonDocuments2 } }, new DocumentSelectOption { Label = new DocumentContainer { Value = new PlainText { Text = "More one text" } }, Value = new DocumentContainer { Value = jsonDocuments3 } } } } }; var document = new DocumentCollection { ItemType = "application/vnd.lime.document-select+json", Items = documents, }; return(document); }
public void prop_Count_get() { var document = new JsonDocument(); Assert.Equal(0, document.Count); document.Add(new JsonObject()); Assert.Equal(1, document.Count); }