Skip to content

Conversation

@dr-3lo
Copy link
Collaborator

@dr-3lo dr-3lo commented Oct 21, 2025

Disable Contacts::GetAll method temporary because backend implementation is not complete

Motivation

Backend still doesn't support GetAll for Contatcs API, so need to temporary remove it from .NET client
This update for issue #126

Changes

  • Removed GetAll from IContactCollectionResource
  • Updated Contacts and ContactEvents example projects with respect of removed GetAll functionality
  • Updated Integration tests for Contacts API (disabled corresponding tests)

How to test

Summary by CodeRabbit

  • Breaking Changes
    • Removed the ability to retrieve all contacts. Applications depending on this functionality will require updates.

@coderabbitai
Copy link

coderabbitai bot commented Oct 21, 2025

Walkthrough

This pull request removes the GetAll() method from the IContactCollectionResource interface and replaces its usages in examples and integration tests with placeholder empty-list implementations, effectively disabling contact list retrieval functionality.

Changes

Cohort / File(s) Summary
Interface method removal
src/Mailtrap.Abstractions/Contacts/IContactCollectionResource.cs
Removed GetAll(CancellationToken) method declaration and its XML documentation; updated Create method's cancellationToken documentation to be explicit.
Example placeholder implementations
examples/Mailtrap.Example.Contact/Program.cs, examples/Mailtrap.Example.ContactEvents/Program.cs
Replaced await contactsResource.GetAll() calls with hard-coded empty lists and TODO comments indicating the method is not yet implemented.
Integration test removal
tests/Mailtrap.IntegrationTests/Contacts/ContactsIntegrationTests.cs
Removed GetAll_Success() test method and replaced test body with commented-out code and a TODO comment; other contact tests remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • #152: Adds Events(contactId) method to the same IContactCollectionResource interface that is modified in this PR.
  • #143: Previously added GetAll() and related navigation methods to contacts API, which this PR removes.
  • #153: Modifies the Contacts collection resource API surface, including changes to the GetAll() signature that this PR removes entirely.

Suggested reviewers

  • mklocek
  • zhaparoff

Poem

🐰 Hop! The contacts have all gone away,
Empty lists lead the day—
GetAll removed, a TODO waits,
For future implementations create!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "Disable Contacts::GetAll method from .NET client" directly and specifically describes the main change in the changeset. The title clearly indicates that the GetAll method is being disabled (removed) from the Contacts resource in the .NET client. This aligns perfectly with the core objective of the PR, which is to remove the GetAll method from IContactCollectionResource and update related code accordingly. The title is concise, specific, and avoids vague terminology, making it clear to teammates scanning the repository history what the primary change entails.
Description Check ✅ Passed The pull request description includes all required sections from the template: Motivation explains why the change is necessary (backend doesn't support GetAll yet), Changes lists three specific updates made to the codebase, and How to test provides concrete testing steps with checkboxes. The description is comprehensive and provides sufficient context about the PR's purpose and implementation. While the Images and GIFs section is not included, this appears to be optional or not applicable for this type of backend API change, and its absence does not detract from the overall completeness of the description.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/126-patch1-Contacts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dr-3lo dr-3lo linked an issue Oct 21, 2025 that may be closed by this pull request
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
examples/Mailtrap.Example.ContactEvents/Program.cs (1)

36-37: Consider enhancing the TODO comment with additional context.

The workaround is functional, but note that using an empty list will cause the example to always create a new contact on each run rather than reusing existing ones. Consider adding a brief explanation about the backend limitation to help users understand why GetAll is temporarily unavailable.

Apply this diff to provide more context:

-    // TODO: Enable when GetAll is implemented
+    // TODO: Enable when GetAll is implemented (backend support pending)
+    // Note: Currently creates a new contact on each run
     IList<Contact> contacts = /*await contactsResource.GetAll()*/ [];
examples/Mailtrap.Example.Contact/Program.cs (1)

35-36: Consider enhancing the TODO comment with additional context.

The empty list workaround means the example will always create a new contact (line 42-52) instead of finding and reusing an existing one. Adding context about the backend limitation would help users understand this temporary behavior.

Apply this diff to provide more context:

-    // TODO: Enable when GetAll is implemented
+    // TODO: Enable when GetAll is implemented (backend support pending)
+    // Note: Currently creates a new contact on each run instead of reusing existing ones
     IList<Contact> contacts = /*await contactsResource.GetAll()*/ [];
tests/Mailtrap.IntegrationTests/Contacts/ContactsIntegrationTests.cs (1)

32-71: Prefer [Ignore] attribute over commenting out the test.

While commenting out the test is functional, using the [Ignore("Backend support pending")] attribute would be more maintainable. This approach:

  • Keeps the test visible in test runners and reports
  • Makes it clear the test is temporarily disabled
  • Prevents the test from being forgotten when GetAll is re-implemented
  • Maintains test count metrics

Apply this diff to use the Ignore attribute:

-    // TODO: Enable when GetAll is implemented
-    // [Test]
-    // public async Task GetAll_Success()
-    // {
-    //     // Arrange
-    //     var httpMethod = HttpMethod.Get;
-    //     var requestUri = _resourceUri.AbsoluteUri;
-
-    //     using var responseContent = await Feature.LoadFileToStringContent();
-
-    //     using var mockHttp = new MockHttpMessageHandler();
-    //     mockHttp
-    //         .Expect(httpMethod, requestUri)
-    //         .WithHeaders("Authorization", $"Bearer {_clientConfig.ApiToken}")
-    //         .WithHeaders("Accept", MimeTypes.Application.Json)
-    //         .WithHeaders("User-Agent", HeaderValues.UserAgent.ToString())
-    //         .Respond(HttpStatusCode.OK, responseContent);
-
-    //     using var serviceCollection = new ServiceCollection();
-    //     serviceCollection
-    //         .AddMailtrapClient(_clientConfig)
-    //         .ConfigurePrimaryHttpMessageHandler(() => mockHttp);
-
-    //     using var services = serviceCollection.BuildServiceProvider();
-    //     var client = services.GetRequiredService<IMailtrapClient>();
-
-    //     // Act
-    //     var result = await client
-    //         .Account(_accountId)
-    //         .Contacts()
-    //         .GetAll()
-    //         .ConfigureAwait(false);
-
-    //     // Assert
-    //     mockHttp.VerifyNoOutstandingExpectation();
-
-    //     result.Should()
-    //         .NotBeNull().And
-    //         .HaveCount(3);
-    // }
+    [Test]
+    [Ignore("GetAll not yet implemented - backend support pending (issue #126)")]
+    public async Task GetAll_Success()
+    {
+        // Arrange
+        var httpMethod = HttpMethod.Get;
+        var requestUri = _resourceUri.AbsoluteUri;
+
+        using var responseContent = await Feature.LoadFileToStringContent();
+
+        using var mockHttp = new MockHttpMessageHandler();
+        mockHttp
+            .Expect(httpMethod, requestUri)
+            .WithHeaders("Authorization", $"Bearer {_clientConfig.ApiToken}")
+            .WithHeaders("Accept", MimeTypes.Application.Json)
+            .WithHeaders("User-Agent", HeaderValues.UserAgent.ToString())
+            .Respond(HttpStatusCode.OK, responseContent);
+
+        using var serviceCollection = new ServiceCollection();
+        serviceCollection
+            .AddMailtrapClient(_clientConfig)
+            .ConfigurePrimaryHttpMessageHandler(() => mockHttp);
+
+        using var services = serviceCollection.BuildServiceProvider();
+        var client = services.GetRequiredService<IMailtrapClient>();
+
+        // Act
+        var result = await client
+            .Account(_accountId)
+            .Contacts()
+            .GetAll()
+            .ConfigureAwait(false);
+
+        // Assert
+        mockHttp.VerifyNoOutstandingExpectation();
+
+        result.Should()
+            .NotBeNull().And
+            .HaveCount(3);
+    }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0cdc391 and 6862b42.

📒 Files selected for processing (4)
  • examples/Mailtrap.Example.Contact/Program.cs (1 hunks)
  • examples/Mailtrap.Example.ContactEvents/Program.cs (1 hunks)
  • src/Mailtrap.Abstractions/Contacts/IContactCollectionResource.cs (1 hunks)
  • tests/Mailtrap.IntegrationTests/Contacts/ContactsIntegrationTests.cs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: dr-3lo
PR: railsware/mailtrap-dotnet#152
File: src/Mailtrap.Abstractions/ContactEvents/IContactsEventsCollectionResource.cs:6-6
Timestamp: 2025-09-23T10:44:34.331Z
Learning: The Contact Events API backend does not provide a GetAll/list method - only Create is supported. The ContactsEventCollectionResource implementation should not include a GetAll method.
📚 Learning: 2025-09-23T10:44:34.331Z
Learnt from: dr-3lo
PR: railsware/mailtrap-dotnet#152
File: src/Mailtrap.Abstractions/ContactEvents/IContactsEventsCollectionResource.cs:6-6
Timestamp: 2025-09-23T10:44:34.331Z
Learning: The Contact Events API backend does not provide a GetAll/list method - only Create is supported. The ContactsEventCollectionResource implementation should not include a GetAll method.

Applied to files:

  • src/Mailtrap.Abstractions/Contacts/IContactCollectionResource.cs
🔇 Additional comments (1)
src/Mailtrap.Abstractions/Contacts/IContactCollectionResource.cs (1)

108-108: LGTM!

The cancellationToken parameter documentation has been appropriately updated to be self-contained following the removal of the GetAll method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contacts API: Contacts

2 participants