using JsonRpcEndpointSample.Rpc.Abstractions;
using JsonRpcEndpointSample.Shipment.Models;

namespace JsonRpcEndpointSample.Shipment.Handlers;

[RpcMethod(
    "Shipment.Search",
    Description = "Searches shipment status by tracking number.",
    IsReadOnly = true)]
public sealed class ShipmentSearchHandler : RpcRequestHandler<ShipmentSearchRequest, ShipmentSearchResponse>
{
    protected override Task<ShipmentSearchResponse> HandleRequestAsync(ShipmentSearchRequest request)
    {
        ShipmentSearchResponse response = new ShipmentSearchResponse();
        response.TrackingNumber = request.TrackingNumber;
        response.Status = "In Transit";
        response.CurrentLocation = "Toronto Distribution Center";

        return Task.FromResult(response);
    }
}
