Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ConsoleApp/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,15 @@ public async Task RunAsync()
var retrievedCheck = await _postGrid.Checks.GetAsync(checkResponse.Id);
var checkJson = System.Text.Json.JsonSerializer.Serialize(retrievedCheck, new System.Text.Json.JsonSerializerOptions { WriteIndented = true });
Console.WriteLine(checkJson);

var checkList = await _postGrid.Checks.ListAsync();

var deleteResponse = await _postGrid.Checks.DeleteAsync(checkResponse.Id);
Console.WriteLine($"Check deleted: {deleteResponse}");
Console.ReadLine();

var getResponse2 = await _postGrid.Checks.GetAsync(checkResponse.Id);
Console.WriteLine($"Check after delete: {getResponse2}");
Console.ReadLine();
}
}
17 changes: 17 additions & 0 deletions src/Project/Checks/CheckCancellationInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Shane32.PostGrid.Checks;

/// <summary>
/// Represents cancellation information for a check
/// </summary>
public class CheckCancellationInfo
{
/// <summary>
/// The ID of the user who cancelled the check
/// </summary>
public required string CancelledByUser { get; set; }

/// <summary>
/// The reason for cancellation
/// </summary>
public required string Reason { get; set; }
}
30 changes: 30 additions & 0 deletions src/Project/Checks/CheckResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,34 @@ public class CheckResponse
/// See Metadata
/// </summary>
public Dictionary<string, string>? Metadata { get; set; }

/// <summary>
/// The envelope type used for the check
/// </summary>
public required string Envelope { get; set; }

/// <summary>
/// The size of the check (e.g., us_letter)
/// </summary>
public required string Size { get; set; }

/// <summary>
/// The number of pages in the check document
/// </summary>
public int? PageCount { get; set; }

/// <summary>
/// The date and time when the check was created
/// </summary>
public required DateTimeOffset CreatedAt { get; set; }

/// <summary>
/// The date and time when the check was last updated
/// </summary>
public required DateTimeOffset UpdatedAt { get; set; }

/// <summary>
/// Cancellation information if the check has been cancelled
/// </summary>
public CheckCancellationInfo? Cancellation { get; set; }
}
15 changes: 5 additions & 10 deletions src/Project/Contacts/ContactBaseResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class ContactBaseResponse
/// </summary>
public string? CountryCode { get; set; }

/// <summary>
/// Full country name
/// </summary>
public string? Country { get; set; }

/// <summary>
/// One of verified, corrected, or failed
/// </summary>
Expand Down Expand Up @@ -89,14 +94,4 @@ public class ContactBaseResponse
/// Hide contact details apart from final print
/// </summary>
public required bool Secret { get; set; }

/// <summary>
/// The date and time when the contact was created
/// </summary>
public DateTimeOffset CreatedAt { get; set; }

/// <summary>
/// The date and time when the contact was last updated
/// </summary>
public DateTimeOffset UpdatedAt { get; set; }
}
10 changes: 10 additions & 0 deletions src/Project/Contacts/ContactResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,14 @@ public class ContactResponse : ContactBaseResponse
/// Override the given address verification status
/// </summary>
public required bool ForceVerifiedStatus { get; set; }

/// <summary>
/// The date and time when the contact was created
/// </summary>
public required DateTimeOffset CreatedAt { get; set; }

/// <summary>
/// The date and time when the contact was last updated
/// </summary>
public required DateTimeOffset UpdatedAt { get; set; }
}
19 changes: 17 additions & 2 deletions src/Tests/ApiApprovalTests.PublicApi.approved.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,26 @@ namespace Shane32.PostGrid.Checks
public string Id { get; set; }
public string? Note { get; set; }
}
public class CheckCancellationInfo
{
[System.Obsolete("Constructors of types with required members are not supported in this version of " +
"your compiler.", true)]
public CheckCancellationInfo() { }
public string CancelledByUser { get; set; }
public string Reason { get; set; }
}
public class CheckResponse
{
[System.Obsolete("Constructors of types with required members are not supported in this version of " +
"your compiler.", true)]
public CheckResponse() { }
public int Amount { get; set; }
public string BankAccount { get; set; }
public Shane32.PostGrid.Checks.CheckCancellationInfo? Cancellation { get; set; }
public System.DateTimeOffset CreatedAt { get; set; }
public string CurrencyCode { get; set; }
public string? Description { get; set; }
public string Envelope { get; set; }
public Shane32.PostGrid.Contacts.ContactBaseResponse From { get; set; }
public string Id { get; set; }
public string? ImbStatus { get; set; }
Expand All @@ -102,9 +113,12 @@ namespace Shane32.PostGrid.Checks
public string? Message { get; set; }
public System.Collections.Generic.Dictionary<string, string>? Metadata { get; set; }
public int Number { get; set; }
public int? PageCount { get; set; }
public System.DateTimeOffset SendDate { get; set; }
public string Size { get; set; }
public string Status { get; set; }
public Shane32.PostGrid.Contacts.ContactBaseResponse To { get; set; }
public System.DateTimeOffset UpdatedAt { get; set; }
public string? Url { get; set; }
}
public class CreateRequest
Expand Down Expand Up @@ -168,8 +182,8 @@ namespace Shane32.PostGrid.Contacts
public string? AddressStatus { get; set; }
public string? City { get; set; }
public string? CompanyName { get; set; }
public string? Country { get; set; }
public string? CountryCode { get; set; }
public System.DateTimeOffset CreatedAt { get; set; }
public string? Description { get; set; }
public string? Email { get; set; }
public string? FirstName { get; set; }
Expand All @@ -181,16 +195,17 @@ namespace Shane32.PostGrid.Contacts
public string? PostalOrZip { get; set; }
public string? ProvinceOrState { get; set; }
public bool Secret { get; set; }
public System.DateTimeOffset UpdatedAt { get; set; }
}
public class ContactResponse : Shane32.PostGrid.Contacts.ContactBaseResponse
{
[System.Obsolete("Constructors of types with required members are not supported in this version of " +
"your compiler.", true)]
public ContactResponse() { }
public System.DateTimeOffset CreatedAt { get; set; }
public bool ForceVerifiedStatus { get; set; }
public bool Live { get; set; }
public bool SkipVerification { get; set; }
public System.DateTimeOffset UpdatedAt { get; set; }
}
public class CreateRequest
{
Expand Down
17 changes: 5 additions & 12 deletions src/Tests/BankAccountsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@ public async Task CreateBankAccount_Successful(bool useSignatureImage)
};

// Set either signature image or text based on the test case
if (useSignatureImage)
{
if (useSignatureImage) {
// Use a sample image for testing
bankAccountRequest.SignatureImage = new byte[] { 0x89, 0x50, 0x4E, 0x47 }; // PNG header bytes
bankAccountRequest.SignatureImageContentType = "image/png";
}
else
{
} else {
bankAccountRequest.SignatureText = "John Doe";
}

Expand Down Expand Up @@ -76,8 +73,7 @@ async Task<HttpResponseMessage> VerifyRequestAndCreateResponse(HttpRequestMessag
request.Headers.GetValues("x-api-key").ShouldBe(new string[] { "test_api_key_123" });

// Verify form data
if (request.Content is MultipartFormDataContent multipartContent && useSignatureImage)
{
if (request.Content is MultipartFormDataContent multipartContent && useSignatureImage) {
// Verify the multipart form data contains all expected parts with correct values
multipartContent.ShouldContainPart("signatureImage", "image/png");
multipartContent.ShouldContainPartWithValue("bankName", "Test Bank");
Expand All @@ -88,9 +84,7 @@ async Task<HttpResponseMessage> VerifyRequestAndCreateResponse(HttpRequestMessag
multipartContent.ShouldContainPartWithValue("bankSecondaryLine", "New York, NY 10001");
multipartContent.ShouldContainPartWithValue("description", "Test bank account");
multipartContent.ShouldContainPartWithValue("metadata[type]", "checking");
}
else
{
} else {
// For signature text, we expect form URL encoded content
request.Content.ShouldBeOfType<FormUrlEncodedContent>();
var formData = await request.Content.ReadAsStringAsync();
Expand Down Expand Up @@ -326,8 +320,7 @@ public async Task ListAllBankAccounts_Successful()

// Act
var results = new List<BankAccountResponse>();
await foreach (var bankAccountEntry in PostGrid.BankAccounts.ListAllAsync(search: "Test"))
{
await foreach (var bankAccountEntry in PostGrid.BankAccounts.ListAllAsync(search: "Test")) {
results.Add(bankAccountEntry);
}

Expand Down
Loading