From c192e4c6c100d2a826c4bd9898c1548c84500946 Mon Sep 17 00:00:00 2001 From: Maxwell Weru Date: Tue, 30 Aug 2022 07:35:42 +0300 Subject: [PATCH 1/2] Remove SendBatchAsync(...) --- src/FaluSdk/Messages/MessagesServiceClient.cs | 27 ------------ .../Clients/MessagesServiceClientTests.cs | 44 ------------------- 2 files changed, 71 deletions(-) diff --git a/src/FaluSdk/Messages/MessagesServiceClient.cs b/src/FaluSdk/Messages/MessagesServiceClient.cs index 281d85ca..34d58bd5 100644 --- a/src/FaluSdk/Messages/MessagesServiceClient.cs +++ b/src/FaluSdk/Messages/MessagesServiceClient.cs @@ -92,33 +92,6 @@ public virtual Task> UpdateAsync(string id, return UpdateResourceAsync(id, patch, options, cancellationToken); } - /// Send a batch of messages. - /// - /// Options to use for the request. - /// - /// - [Obsolete("Migrate to using MessageBatch API resource.")] - public virtual Task> SendBatchAsync(IList messages, - RequestOptions? options = null, - CancellationToken cancellationToken = default) - { - if (messages is null) throw new ArgumentNullException(nameof(messages)); - - if (messages.Count > 1_000) - { - throw new ArgumentOutOfRangeException(paramName: nameof(messages), - message: "The service does not support more than 1,000 (1k) messages"); - } - - foreach (var m in messages) - { - m.Template?.Model?.GetType().EnsureAllowedForMessageTemplateModel(); - } - - var uri = MakePath("/batch"); - return RequestAsync(uri, HttpMethod.Post, messages, options, cancellationToken); - } - /// Cancel a message preventing further updates. /// Unique identifier for the message. /// Options to use for the request. diff --git a/tests/FaluSdk.Tests/Clients/MessagesServiceClientTests.cs b/tests/FaluSdk.Tests/Clients/MessagesServiceClientTests.cs index 519566a5..7cc7c2ae 100644 --- a/tests/FaluSdk.Tests/Clients/MessagesServiceClientTests.cs +++ b/tests/FaluSdk.Tests/Clients/MessagesServiceClientTests.cs @@ -110,50 +110,6 @@ await TestAsync(handler, async (client) => }); } - [Theory] - [MemberData(nameof(RequestOptionsData))] - public async Task SendBatchAsync_Works(RequestOptions options) - { - var handler = new DynamicHttpMessageHandler((req, ct) => - { - Assert.Equal(HttpMethod.Post, req.Method); - Assert.Equal($"{BasePath}/batch", req.RequestUri!.AbsolutePath); - - AssertRequestHeaders(req, options); - - var content = new MessageCreateResponse - { - Created = Data.Created, - Ids = new[] { Data.Id!, }, - Live = Data.Live, - Workspace = Data.Workspace, - }; - var response = new HttpResponseMessage(HttpStatusCode.OK) - { - Content = new StringContent(JsonSerializer.Serialize(content), Encoding.UTF8, MediaTypeNames.Application.Json) - }; - - return response; - }); - - await TestAsync(handler, async (client) => - { - var model = new MessageCreateRequest - { - To = new[] { Data!.To!, }, - Body = Data!.Body - }; - -#pragma warning disable CS0618 // Type or member is obsolete - var response = await client.Messages.SendBatchAsync(new[] { model }, options); -#pragma warning restore CS0618 // Type or member is obsolete - - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.NotNull(response.Resource?.Ids); - Assert.Single(response.Resource.Ids); - }); - } - [Theory] [MemberData(nameof(RequestOptionsData))] public async Task UpdateAsync_Works(RequestOptions options) From 327e36819e4d3a72135e3a8aa1c81597cce277c2 Mon Sep 17 00:00:00 2001 From: Maxwell Weru Date: Wed, 31 Aug 2022 09:34:25 +0300 Subject: [PATCH 2/2] Remove obsolete SendAsync(...) --- src/FaluSdk/Messages/MessagesServiceClient.cs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/FaluSdk/Messages/MessagesServiceClient.cs b/src/FaluSdk/Messages/MessagesServiceClient.cs index 34d58bd5..4c0effdb 100644 --- a/src/FaluSdk/Messages/MessagesServiceClient.cs +++ b/src/FaluSdk/Messages/MessagesServiceClient.cs @@ -65,19 +65,6 @@ public virtual Task> CreateAsync(Message return CreateResourceAsync(message, options, cancellationToken); } - /// Send a message. - /// - /// Options to use for the request. - /// - /// - [Obsolete("Use 'CreateAsync(...)' instead.")] - public virtual Task> SendAsync(MessageCreateRequest message, - RequestOptions? options = null, - CancellationToken cancellationToken = default) - { - return CreateAsync(message, options, cancellationToken); - } - /// Update a message. /// Unique identifier for the message. ///