• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Shane32 / PostGrid / 13908682632

17 Mar 2025 07:58PM UTC coverage: 82.329% (+0.9%) from 81.421%
13908682632

push

github

web-flow
Remove delete from check API (#11)

194 of 266 branches covered (72.93%)

Branch coverage included in aggregate %.

4 of 14 new or added lines in 2 files covered. (28.57%)

3 existing lines in 1 file now uncovered.

612 of 713 relevant lines covered (85.83%)

5.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.29
/src/Project/Helpers/PostGridChecks.cs
1
using Shane32.PostGrid.Checks;
2

3
namespace Shane32.PostGrid.Helpers;
4

5
/// <summary>
6
/// Provides methods for working with checks in the PostGrid API.
7
/// </summary>
8
public class PostGridChecks
9
{
10
    private readonly IPostGridConnection _connection;
11

12
    /// <summary>
13
    /// Initializes a new instance of the <see cref="PostGridChecks"/> class.
14
    /// </summary>
15
    /// <param name="connection">The connection to use for API requests.</param>
16
    public PostGridChecks(IPostGridConnection connection)
6✔
17
    {
6✔
18
        _connection = connection;
6✔
19
    }
6✔
20

21
    /// <summary>
22
    /// Creates a new check in PostGrid.
23
    /// </summary>
24
    /// <param name="request">The check creation request.</param>
25
    /// <param name="cancellationToken">A token to cancel the operation.</param>
26
    /// <returns>A task representing the asynchronous operation, containing the response from the API.</returns>
27
    public async Task<CheckResponse> CreateAsync(CreateRequest request, CancellationToken cancellationToken = default)
28
    {
2✔
29
        return await _connection.ExecuteAsync(request, cancellationToken);
2✔
30
    }
2✔
31

32
    /// <summary>
33
    /// Gets a check from PostGrid by ID.
34
    /// </summary>
35
    /// <param name="id">The ID of the check to retrieve.</param>
36
    /// <param name="cancellationToken">A token to cancel the operation.</param>
37
    /// <returns>A task representing the asynchronous operation, containing the response from the API.</returns>
38
    public async Task<CheckResponse> GetAsync(string id, CancellationToken cancellationToken = default)
39
    {
2✔
40
        var request = new GetRequest { Id = id };
2✔
41
        return await _connection.ExecuteAsync(request, cancellationToken);
2✔
42
    }
2✔
43

44
    /// <summary>
45
    /// Cancels a check from PostGrid by ID.
46
    /// </summary>
47
    /// <param name="id">The ID of the check to cancel.</param>
48
    /// <param name="note">An optional note explaining the reason for cancellation.</param>
49
    /// <param name="cancellationToken">A token to cancel the operation.</param>
50
    /// <returns>A task representing the asynchronous operation, containing the response from the API.</returns>
51
    public async Task<CheckResponse> CancelAsync(string id, string? note, CancellationToken cancellationToken = default)
UNCOV
52
    {
×
NEW
53
        var request = new CancelRequest { Id = id, Note = note };
×
UNCOV
54
        return await _connection.ExecuteAsync(request, cancellationToken);
×
UNCOV
55
    }
×
56

57
    /// <summary>
58
    /// Cancels a check from PostGrid by ID.
59
    /// </summary>
60
    /// <param name="id">The ID of the check to cancel.</param>
61
    /// <param name="cancellationToken">A token to cancel the operation.</param>
62
    /// <returns>A task representing the asynchronous operation, containing the response from the API.</returns>
63
    public async Task<CheckResponse> CancelAsync(string id, CancellationToken cancellationToken = default)
64
    {
1✔
65
        var request = new CancelRequest { Id = id };
1✔
66
        return await _connection.ExecuteAsync(request, cancellationToken);
1✔
67
    }
1✔
68

69
    /// <summary>
70
    /// Lists checks from PostGrid with pagination and search options.
71
    /// </summary>
72
    /// <param name="skip">The number of items to skip for pagination.</param>
73
    /// <param name="limit">The maximum number of items to return.</param>
74
    /// <param name="cancellationToken">A token to cancel the operation.</param>
75
    /// <returns>A task representing the asynchronous operation, containing the paginated list response from the API.</returns>
76
    public async Task<ListResponse<CheckResponse>> ListAsync(int? skip = null, int? limit = null, CancellationToken cancellationToken = default)
77
    {
×
78
        var request = new ListRequest {
×
79
            Skip = skip,
×
80
            Limit = limit,
×
81
        };
×
82

83
        return await _connection.ExecuteAsync(request, cancellationToken);
×
84
    }
×
85

86
    /// <summary>
87
    /// Lists checks from PostGrid with the specified request parameters.
88
    /// </summary>
89
    /// <param name="request">The list request parameters.</param>
90
    /// <param name="cancellationToken">A token to cancel the operation.</param>
91
    /// <returns>A task representing the asynchronous operation, containing the paginated list response from the API.</returns>
92
    public async Task<ListResponse<CheckResponse>> ListAsync(ListRequest request, CancellationToken cancellationToken = default)
93
    {
1✔
94
        return await _connection.ExecuteAsync(request, cancellationToken);
1✔
95
    }
1✔
96

97
    /// <summary>
98
    /// Lists all checks from PostGrid by making multiple API calls as needed.
99
    /// </summary>
100
    /// <param name="pageLimit">The maximum number of items to return per page (default: 100).</param>
101
    /// <param name="cancellationToken">A token to cancel the operation.</param>
102
    /// <returns>An asynchronous enumerable containing all checks from the API.</returns>
103
    public async IAsyncEnumerable<CheckResponse> ListAllAsync(int pageLimit = 100, [System.Runtime.CompilerServices.EnumeratorCancellation] CancellationToken cancellationToken = default)
104
    {
×
105
        int skip = 0;
×
106
        bool hasMore = true;
×
107

108
        while (hasMore) {
×
109
            var response = await ListAsync(skip, pageLimit, cancellationToken);
×
110

111
            if (response.Data == null || response.Data.Length == 0)
×
112
                break;
×
113

114
            foreach (var check in response.Data) {
×
115
                yield return check;
×
116
            }
×
117

118
            skip += response.Data.Length;
×
119
            hasMore = skip < response.TotalCount;
×
120
        }
×
121
    }
×
122
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc