From af3f97180159845f6fec4224e8f3efff5c37c902 Mon Sep 17 00:00:00 2001 From: Matthew Parker Date: Sun, 20 Oct 2024 21:00:01 +0100 Subject: [PATCH 1/2] Removed update team membership status from server SDK --- .../Clients/ITeamsClient.cs | 13 +-- .../Clients/TeamsClient.cs | 17 ---- ...sClientTests.UpdateTeamMembershipStatus.cs | 90 ------------------- 3 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 tests/PinguApps.Appwrite.Server.Tests/Clients/Teams/TeamsClientTests.UpdateTeamMembershipStatus.cs diff --git a/src/PinguApps.Appwrite.Server/Clients/ITeamsClient.cs b/src/PinguApps.Appwrite.Server/Clients/ITeamsClient.cs index ad75fde0..f21c3b30 100644 --- a/src/PinguApps.Appwrite.Server/Clients/ITeamsClient.cs +++ b/src/PinguApps.Appwrite.Server/Clients/ITeamsClient.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using PinguApps.Appwrite.Shared; using PinguApps.Appwrite.Shared.Requests.Teams; @@ -96,16 +95,6 @@ public interface ITeamsClient /// The membership Task> UpdateMembership(UpdateMembershipRequest request); - /// - /// Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user. - /// If the request is successful, a session for the user is automatically created. - /// Appwrite Docs - /// - /// The request content - /// The membership - [Obsolete("This method on the server SDK currently will not work. You can track this bug on the Appwrite Github: https://github.com/appwrite/appwrite/issues/8828", false)] - Task> UpdateTeamMembershipStatus(UpdateTeamMembershipStatusRequest request); - /// /// Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in user preferences. /// Appwrite Docs diff --git a/src/PinguApps.Appwrite.Server/Clients/TeamsClient.cs b/src/PinguApps.Appwrite.Server/Clients/TeamsClient.cs index fd671aa4..c23acbab 100644 --- a/src/PinguApps.Appwrite.Server/Clients/TeamsClient.cs +++ b/src/PinguApps.Appwrite.Server/Clients/TeamsClient.cs @@ -194,23 +194,6 @@ public async Task> UpdateMembership(UpdateMembershipR } } - /// - public async Task> UpdateTeamMembershipStatus(UpdateTeamMembershipStatusRequest request) - { - try - { - request.Validate(true); - - var result = await _teamsApi.UpdateTeamMembershipStatus(request.TeamId, request.MembershipId, request); - - return result.GetApiResponse(); - } - catch (Exception e) - { - return e.GetExceptionResponse(); - } - } - /// public async Task>> GetTeamPreferences(GetTeamPreferencesRequest request) { diff --git a/tests/PinguApps.Appwrite.Server.Tests/Clients/Teams/TeamsClientTests.UpdateTeamMembershipStatus.cs b/tests/PinguApps.Appwrite.Server.Tests/Clients/Teams/TeamsClientTests.UpdateTeamMembershipStatus.cs deleted file mode 100644 index 399d932f..00000000 --- a/tests/PinguApps.Appwrite.Server.Tests/Clients/Teams/TeamsClientTests.UpdateTeamMembershipStatus.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Net; -using PinguApps.Appwrite.Shared.Requests.Teams; -using PinguApps.Appwrite.Shared.Tests; -using PinguApps.Appwrite.Shared.Utils; -using RichardSzalay.MockHttp; - -namespace PinguApps.Appwrite.Server.Tests.Clients.Teams; -public partial class TeamsClientTests -{ - [Fact] - public async Task UpdateTeamMembershipStatus_ShouldReturnSuccess_WhenApiCallSucceeds() - { - // Arrange - var request = new UpdateTeamMembershipStatusRequest - { - TeamId = IdUtils.GenerateUniqueId(), - MembershipId = IdUtils.GenerateUniqueId(), - UserId = IdUtils.GenerateUniqueId(), - Secret = IdUtils.GenerateUniqueId() - }; - - _mockHttp.Expect(HttpMethod.Patch, $"{TestConstants.Endpoint}/teams/{request.TeamId}/memberships/{request.MembershipId}/status") - .ExpectedHeaders() - .WithJsonContent(request, _jsonSerializerOptions) - .Respond(TestConstants.AppJson, TestConstants.MembershipResponse); - - // Act -#pragma warning disable CS0618 // Type or member is obsolete - var result = await _appwriteClient.Teams.UpdateTeamMembershipStatus(request); -#pragma warning restore CS0618 // Type or member is obsolete - - // Assert - Assert.True(result.Success); - } - - [Fact] - public async Task UpdateTeamMembershipStatus_ShouldHandleException_WhenApiCallFails() - { - // Arrange - var request = new UpdateTeamMembershipStatusRequest - { - TeamId = IdUtils.GenerateUniqueId(), - MembershipId = IdUtils.GenerateUniqueId(), - UserId = IdUtils.GenerateUniqueId(), - Secret = IdUtils.GenerateUniqueId() - }; - - _mockHttp.Expect(HttpMethod.Patch, $"{TestConstants.Endpoint}/teams/{request.TeamId}/memberships/{request.MembershipId}/status") - .ExpectedHeaders() - .WithJsonContent(request, _jsonSerializerOptions) - .Respond(HttpStatusCode.BadRequest, TestConstants.AppJson, TestConstants.AppwriteError); - - // Act -#pragma warning disable CS0618 // Type or member is obsolete - var result = await _appwriteClient.Teams.UpdateTeamMembershipStatus(request); -#pragma warning restore CS0618 // Type or member is obsolete - - // Assert - Assert.True(result.IsError); - Assert.True(result.IsAppwriteError); - } - - [Fact] - public async Task UpdateTeamMembershipStatus_ShouldReturnErrorResponse_WhenExceptionOccurs() - { - // Arrange - var request = new UpdateTeamMembershipStatusRequest - { - TeamId = IdUtils.GenerateUniqueId(), - MembershipId = IdUtils.GenerateUniqueId(), - UserId = IdUtils.GenerateUniqueId(), - Secret = IdUtils.GenerateUniqueId() - }; - - _mockHttp.Expect(HttpMethod.Patch, $"{TestConstants.Endpoint}/teams/{request.TeamId}/memberships/{request.MembershipId}/status") - .ExpectedHeaders() - .WithJsonContent(request, _jsonSerializerOptions) - .Throw(new HttpRequestException("An error occurred")); - - // Act -#pragma warning disable CS0618 // Type or member is obsolete - var result = await _appwriteClient.Teams.UpdateTeamMembershipStatus(request); -#pragma warning restore CS0618 // Type or member is obsolete - - // Assert - Assert.False(result.Success); - Assert.True(result.IsInternalError); - Assert.Equal("An error occurred", result.Result.AsT2.Message); - } -} From 0001ff681555d693ed899668821b0f62316dd2ef Mon Sep 17 00:00:00 2001 From: Matthew Parker Date: Sun, 20 Oct 2024 21:01:17 +0100 Subject: [PATCH 2/2] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1b1860e5..332e94d7 100644 --- a/README.md +++ b/README.md @@ -141,9 +141,9 @@ string emailAddressOrErrorMessage = userResponse.Result.Match( ## ⌛ Progress -![Server & Client - 126 / 318](https://img.shields.io/badge/Server_&_Client-126%20%2F%20318-gold?style=for-the-badge) +![Server & Client - 125 / 317](https://img.shields.io/badge/Server_&_Client-125%20%2F%20317-gold?style=for-the-badge) -![Server - 66 / 225](https://img.shields.io/badge/Server-66%20%2F%20225-red?style=for-the-badge) +![Server - 65 / 224](https://img.shields.io/badge/Server-65%20%2F%20224-red?style=for-the-badge) ![Client - 60 / 93](https://img.shields.io/badge/Client-60%20%2F%2093-gold?style=for-the-badge) @@ -256,7 +256,7 @@ string emailAddressOrErrorMessage = userResponse.Result.Match( | [Update Phone Verification](https://appwrite.io/docs/references/1.6.x/server-rest/users#updatePhoneVerification) | ❌ | ✅ | ### Teams -![Teams - 26 / 26](https://img.shields.io/badge/Teams-24%20%2F%2026-blue?style=for-the-badge) +![Teams - 25 / 25](https://img.shields.io/badge/Teams-25%20%2F%2025-blue?style=for-the-badge) | Endpoint | Client | Server | |:-:|:-:|:-:| @@ -270,7 +270,7 @@ string emailAddressOrErrorMessage = userResponse.Result.Match( | [Get Team Membership](https://appwrite.io/docs/references/1.6.x/client-rest/teams#getMembership) | ✅ | ✅ | | [Update Membership](https://appwrite.io/docs/references/1.6.x/client-rest/teams#updateMembership) | ✅ | ✅ | | [Delete Team Membership](https://appwrite.io/docs/references/1.6.x/client-rest/teams#deleteMembership) | ✅ | ✅ | -| [Update Team Membership Status](https://appwrite.io/docs/references/1.6.x/client-rest/teams#updateMembershipStatus) | ✅ | ✅ | +| [Update Team Membership Status](https://appwrite.io/docs/references/1.6.x/client-rest/teams#updateMembershipStatus) | ✅ | ❌ | | [Get Team Memberships](https://appwrite.io/docs/references/1.6.x/client-rest/teams#getPrefs) | ✅ | ✅ | | [Update Preferences](https://appwrite.io/docs/references/1.6.x/client-rest/teams#updatePrefs) | ✅ | ✅ |