mirror of
https://github.com/bitwarden/server.git
synced 2025-07-05 10:02:47 -05:00
[AC-2568] Added invoices and transaction history endpoints. Added cursor paging for each (#4692)
* Added invoices and transaction history endpoints. Added cursor paging for each * Removed try/catch since it's handled by middleware. Updated condition to use pattern matching * Added unit tests for PaymentHistoryService * Removed organizationId from account billing controller endpoints
This commit is contained in:
@ -20,38 +20,60 @@ public class TransactionRepository : Repository<Transaction, Guid>, ITransaction
|
||||
: base(connectionString, readOnlyConnectionString)
|
||||
{ }
|
||||
|
||||
public async Task<ICollection<Transaction>> GetManyByUserIdAsync(Guid userId, int? limit = null)
|
||||
{
|
||||
using (var connection = new SqlConnection(ConnectionString))
|
||||
{
|
||||
var results = await connection.QueryAsync<Transaction>(
|
||||
$"[{Schema}].[Transaction_ReadByUserId]",
|
||||
new { UserId = userId, Limit = limit ?? int.MaxValue },
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ICollection<Transaction>> GetManyByOrganizationIdAsync(Guid organizationId, int? limit = null)
|
||||
public async Task<ICollection<Transaction>> GetManyByUserIdAsync(
|
||||
Guid userId,
|
||||
int? limit = null,
|
||||
DateTime? startAfter = null)
|
||||
{
|
||||
await using var connection = new SqlConnection(ConnectionString);
|
||||
|
||||
var results = await connection.QueryAsync<Transaction>(
|
||||
$"[{Schema}].[Transaction_ReadByOrganizationId]",
|
||||
new { OrganizationId = organizationId, Limit = limit ?? int.MaxValue },
|
||||
$"[{Schema}].[Transaction_ReadByUserId]",
|
||||
new
|
||||
{
|
||||
UserId = userId,
|
||||
Limit = limit ?? int.MaxValue,
|
||||
StartAfter = startAfter
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Transaction>> GetManyByProviderIdAsync(Guid providerId, int? limit = null)
|
||||
public async Task<ICollection<Transaction>> GetManyByOrganizationIdAsync(
|
||||
Guid organizationId,
|
||||
int? limit = null,
|
||||
DateTime? startAfter = null)
|
||||
{
|
||||
await using var connection = new SqlConnection(ConnectionString);
|
||||
|
||||
var results = await connection.QueryAsync<Transaction>(
|
||||
$"[{Schema}].[Transaction_ReadByOrganizationId]",
|
||||
new
|
||||
{
|
||||
OrganizationId = organizationId,
|
||||
Limit = limit ?? int.MaxValue,
|
||||
StartAfter = startAfter
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
}
|
||||
|
||||
public async Task<ICollection<Transaction>> GetManyByProviderIdAsync(
|
||||
Guid providerId,
|
||||
int? limit = null,
|
||||
DateTime? startAfter = null)
|
||||
{
|
||||
await using var sqlConnection = new SqlConnection(ConnectionString);
|
||||
|
||||
var results = await sqlConnection.QueryAsync<Transaction>(
|
||||
$"[{Schema}].[Transaction_ReadByProviderId]",
|
||||
new { ProviderId = providerId, Limit = limit ?? int.MaxValue },
|
||||
new
|
||||
{
|
||||
ProviderId = providerId,
|
||||
Limit = limit ?? int.MaxValue,
|
||||
StartAfter = startAfter
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
|
||||
return results.ToList();
|
||||
|
Reference in New Issue
Block a user