Add stuff for the test menu.

This commit is contained in:
Kayori
2025-07-31 00:08:03 +02:00
parent 4ea74ea1f0
commit 6126676fa1
5 changed files with 98 additions and 3 deletions
@@ -7,13 +7,21 @@ namespace MedusaPluginChargeMachine;
public class ChargeMachinePlugin: IMedusaPlugin
{
public Task<bool> DoesProfileExist(string cardId)
{
return Task.FromResult(true);
}
public string Name => "Charge Machine";
public string Version => "1.0.0";
public string Description => "Plugin for the paseli charge machine";
public string GameCode => "LA9";
public int? MinVer => null;
public int? MaxVer => null;
public Task OnBuilderInitialize(WebApplicationBuilder builder)
{
builder.Services.AddTransient<ISessionService, SessionService>();
builder.Services.AddSingleton<ISessionService, SessionService>();
return Task.CompletedTask;
}
@@ -5,7 +5,7 @@ using MedusaPluginChargeMachine.Services;
namespace MedusaPluginChargeMachine.Handlers.LA9
{
public class CheckInEaChargeHandler(ISessionService sessionService, ICardService cardService, XDocument body): Handler
public class CheckinEaChargeHandler(ISessionService sessionService, ICardService cardService, XDocument body): Handler
{
private readonly XDocument _body = body;
private readonly ISessionService _sessionService = sessionService;
@@ -0,0 +1,29 @@
using System.Xml.Linq;
using Abstractions.Handlers;
namespace MedusaPluginChargeMachine.Handlers.LA9;
public class GetLastLogEaChargeHandler(): Handler
{
public override void Configure()
{
Module("eacharge");
Method("getlastlog");
}
public override XDocument Handle(string model)
{
var chargedaily = new XElement("chargedaily", 0, new XAttribute("__type", "s32"));
var header = new XElement("header", chargedaily);
var getLastLog = new XElement("getlastlog", new XAttribute("status", "0"), header);
var document = new XDocument(
new XElement("response",
getLastLog
)
);
return document;
}
}
@@ -0,0 +1,32 @@
using System.Xml.Linq;
using Abstractions.Handlers;
using MedusaPluginChargeMachine.Services;
namespace MedusaPluginChargeMachine.Handlers.LA9;
public class OpCheckinEaChargeHandler(ISessionService sessionService, XDocument body): Handler
{
public override void Configure()
{
Module("eacharge");
Method("opcheckin");
}
public override XDocument Handle(string model)
{
var rootCall = body.Root;
var srcId = rootCall?.Attribute("srcid")?.Value!;
var sessionId = sessionService.AddSession(srcId);
var sessionIdXElement = new XElement("sessid", sessionId, new XAttribute("__type", "str"));
var opCheckin = new XElement("opcheckin", sessionIdXElement, new XAttribute("status", "0"), new XAttribute("expire", "1200"));
var document = new XDocument(
new XElement("response",
opCheckin
)
);
return document;
}
}
@@ -0,0 +1,26 @@
using System.Xml.Linq;
using Abstractions.Handlers;
using MedusaPluginChargeMachine.Services;
namespace MedusaPluginChargeMachine.Handlers.LA9;
public class OpCheckoutEaChargeHandler(ISessionService sessionService, XDocument body): Handler
{
public override void Configure()
{
Module("eacharge");
Method("opcheckout");
}
public override XDocument Handle(string model)
{
var eaCharge = body.Root?.Element("eacharge")!;
var sessionId = eaCharge.Element("sessid")!.Value!;
sessionService.RemoveSession(sessionId);
var checkoutCharge = new XElement("eacharge", new XAttribute("status", "0"));
var document = new XDocument(new XElement("response", checkoutCharge));
return document;
}
}