Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created Apr 6, 2022
Embed
What would you like to do?
public class ExternalOrderIntegration
{
private readonly IMessageSession _messageSession;
private readonly HttpClient _httpClient;
public ExternalOrderIntegration(IMessageSession messageSession, HttpClient httpClient)
{
_messageSession = messageSession;
_httpClient = httpClient;
}
public async Task PlaceOrder()
{
var response = await _httpClient.GetAsync("http://external.com/newOrders");
var externalOrder = await response.Deserialize<ExternalOrder>();
var placeOrder = new PlaceOrder
{
OrderId = externalOrder!.Id,
// Translation to convert an external order or PlaceOrder command
};
await _messageSession.Send(placeOrder);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment