040be2feaa
Convert constructors into primary constructors Simplified logic with use of ??, ??= and method groups Cleaned up redundant conditional access qualifiers
43 lines
1.3 KiB
C#
43 lines
1.3 KiB
C#
using SPTarkov.DI.Annotations;
|
|
using SPTarkov.Server.Core.Callbacks;
|
|
using SPTarkov.Server.Core.DI;
|
|
using SPTarkov.Server.Core.Models.Common;
|
|
using SPTarkov.Server.Core.Models.Eft.Common;
|
|
using SPTarkov.Server.Core.Models.Eft.Common.Request;
|
|
using SPTarkov.Server.Core.Models.Eft.Insurance;
|
|
using SPTarkov.Server.Core.Models.Eft.ItemEvent;
|
|
using SPTarkov.Server.Core.Models.Enums;
|
|
|
|
namespace SPTarkov.Server.Core.Routers.ItemEvents;
|
|
|
|
[Injectable]
|
|
public class InsuranceItemEventRouter(InsuranceCallbacks insuranceCallbacks)
|
|
: ItemEventRouterDefinition
|
|
{
|
|
protected override List<HandledRoute> GetHandledRoutes()
|
|
{
|
|
return [new(ItemEventActions.INSURE, false)];
|
|
}
|
|
|
|
public override ValueTask<ItemEventRouterResponse> HandleItemEvent(
|
|
string url,
|
|
PmcData pmcData,
|
|
BaseInteractionRequestData body,
|
|
MongoId sessionID,
|
|
ItemEventRouterResponse output
|
|
)
|
|
{
|
|
switch (url)
|
|
{
|
|
case ItemEventActions.INSURE:
|
|
return new ValueTask<ItemEventRouterResponse>(
|
|
insuranceCallbacks.Insure(pmcData, body as InsureRequestData, sessionID)
|
|
);
|
|
default:
|
|
throw new Exception(
|
|
$"InsuranceItemEventRouter being used when it cant handle route {url}"
|
|
);
|
|
}
|
|
}
|
|
}
|