Files
messengerapi/code/MessengerApi.Contracts.MessageParser/IMessageParser.cs
T

23 lines
974 B
C#

namespace MessengerApi.Contracts.MessageParser
{
/// <summary>
/// A tool that helps converting POCO request/response models into <see cref="InboxMessage"/>, <see cref="OutboxMessage"/> and back.
/// </summary>
/// <remarks>
/// If you implement this, it's gonna be a lot easier for you to translate
/// dumb request class into <see cref="OutboxMessage"/>, then convert
/// <see cref="InboxMessage"/> back to request at server-side, and do the
/// same with the response all the way down to the client.
/// </remarks>
public interface IMessageParser<TRequest, TResponse>
{
OutboxMessage GetMessageFromRequest(TRequest request, int targetUserId);
TRequest GetRequestFromMessage(InboxMessage message);
OutboxMessage GetMessageFromResponse(TResponse response, string apiKey, int targetUserId, InboxMessage requestOrigin = null);
TResponse GetResponseFromMessage(InboxMessage message);
}
}