Skip to content

Commit

Permalink
Dropped support for the most points endpoints from API V1
Browse files Browse the repository at this point in the history
  • Loading branch information
Misha12 committed Oct 26, 2024
1 parent 09a6b4f commit e754128
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 346 deletions.
5 changes: 1 addition & 4 deletions src/GrillBot.App/Actions/ActionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,7 @@ private static IServiceCollection AddApiActions(this IServiceCollection services
services
.AddScoped<Api.V1.Points.ComputeUserPoints>()
.AddScoped<Api.V1.Points.GetPointsLeaderboard>()
.AddScoped<Api.V1.Points.GetTransactionList>()
.AddScoped<Api.V1.Points.ServiceIncrementPoints>()
.AddScoped<Api.V1.Points.ServiceTransferPoints>()
.AddScoped<Api.V1.Points.GetUserList>();
.AddScoped<Api.V1.Points.ServiceIncrementPoints>();

// PublicApiClients
services
Expand Down
60 changes: 0 additions & 60 deletions src/GrillBot.App/Actions/Api/V1/Points/GetTransactionList.cs

This file was deleted.

46 changes: 0 additions & 46 deletions src/GrillBot.App/Actions/Api/V1/Points/GetUserList.cs

This file was deleted.

110 changes: 0 additions & 110 deletions src/GrillBot.App/Actions/Api/V1/Points/ServiceTransferPoints.cs

This file was deleted.

76 changes: 1 addition & 75 deletions src/GrillBot.App/Controllers/PointsController.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
using GrillBot.App.Actions;
using GrillBot.App.Actions.Api;
using GrillBot.App.Actions.Api.V1.Points;
using GrillBot.Core.Models.Pagination;
using GrillBot.Core.Services.PointsService;
using GrillBot.Core.Services.PointsService.Models;
using GrillBot.Core.Services.PointsService.Models.Events;
using GrillBot.Core.Services.PointsService.Models.Users;
using GrillBot.Data.Models.API.Points;
using GrillBot.App.Actions.Api.V1.Points;
using GrillBot.Data.Models.API.Users;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
Expand Down Expand Up @@ -34,38 +26,6 @@ public PointsController(IServiceProvider serviceProvider) : base(serviceProvider
public async Task<IActionResult> GetPointsLeaderboardAsync()
=> await ProcessAsync<GetPointsLeaderboard>();

/// <summary>
/// Get paginated list of transactions.
/// </summary>
/// <response code="200">Returns paginated list of transactions.</response>
/// <response code="400">Validation failed.</response>
[HttpPost("transactions/list")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
[ProducesResponseType(typeof(PaginatedResponse<PointsTransaction>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> GetTransactionListAsync([FromBody] AdminListRequest request)
{
ApiAction.Init(this, request);
return await ProcessAsync<GetTransactionList>(request);
}

/// <summary>
/// Get data for graph.
/// </summary>
/// <response code="200">Returns data for graphs.</response>
/// <response code="400">Validation failed.</response>
[HttpPost("graph/data")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
[ProducesResponseType(typeof(List<PointsChartItem>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> GetGraphDataAsync([FromBody] AdminListRequest parameters)
{
ApiAction.Init(this, parameters);

var executor = new Func<IPointsServiceClient, Task<object>>(async (IPointsServiceClient client) => await client.GetChartDataAsync(parameters));
return await ProcessAsync<ServiceBridgeAction<IPointsServiceClient>>(executor);
}

/// <summary>
/// Compute current points status of user.
/// </summary>
Expand Down Expand Up @@ -94,38 +54,4 @@ public async Task<IActionResult> ComputeLoggedUserPointsAsync()
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> ServiceIncrementPointsAsync(ulong guildId, ulong toUserId, int amount)
=> await ProcessAsync<ServiceIncrementPoints>(guildId, toUserId, amount);

/// <summary>
/// Service transfer of points between accounts.
/// </summary>
[HttpPut("service/transfer/{guildId}/{fromUserId}/{toUserId}/{amount:int}")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> ServiceTransferPointsAsync(ulong guildId, ulong fromUserId, ulong toUserId, int amount)
=> await ProcessAsync<ServiceTransferPoints>(guildId, fromUserId, toUserId, amount);

/// <summary>
/// Remove transaction.
/// </summary>
/// <response code="200"></response>
[HttpDelete("{guildId}/{messageId}")]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
[ProducesResponseType(StatusCodes.Status200OK)]
public async Task<IActionResult> DeleteTransactionAsync(string guildId, string messageId, string? reactionId)
=> await ProcessAsync<RabbitMQPublisherAction>(new DeleteTransactionsPayload(guildId, messageId, reactionId));

/// <summary>
/// Gets paginated list of users.
/// </summary>
/// <response code="200">Returns paginated list of users from points service.</response>
/// <response code="400">Validation failed.</response>
[HttpPost("users/list")]
[ProducesResponseType(typeof(PaginatedResponse<Data.Models.API.Points.UserListItem>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme, Roles = "Admin")]
public async Task<IActionResult> GetUserListAsync(UserListRequest request)
{
ApiAction.Init(this, request);
return await ProcessAsync<GetUserList>(request);
}
}
18 changes: 0 additions & 18 deletions src/GrillBot.Data/Models/API/Points/PointsMergeInfo.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/GrillBot.Data/Models/API/Points/PointsTransaction.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/GrillBot.Data/Models/API/Points/UserListItem.cs

This file was deleted.

0 comments on commit e754128

Please sign in to comment.