/// <summary> /// Retrieves the details of the requested order. /// </summary> /// /// <param name="log">The logging instance to use for emitting information.</param> /// <param name="client">The client to use for interacting with the eCommerce service.</param> /// <param name="partner">The partner associated with the order.</param> /// <param name="orderId">The unique identifier of the order to retrieve the detials of.</param> /// <param name="correlationId">An optional identifier used to correlate activities across the disparate parts of processing, including external interations.</param> /// <param name="emulatedResult">An optional emulated result to use in place of querying the eCommerce service.</param> /// /// <returns>The result of the operation.</returns> /// /// <remarks> /// This method owns responsibility for logging the results of the operation and how /// it was produced. /// </remarks> /// protected virtual async Task <OperationResult> RetrieveOrderDetailsAsync(ILogger log, IEcommerceClient client, string partner, string orderId, string correlationId = null, OperationResult emulatedResult = null) { OperationResult result; try { result = emulatedResult ?? (await client.GetOrderDetailsAsync(orderId, correlationId)); log.Information("Order details for {Partner}//{Order} have been retrieved. Emulated: {Emulated}. Result: {Result}", partner, orderId, (emulatedResult != null), result); } catch (Exception ex) { log.Error(ex, "An error occured while requesting the order details for {Partner}//{Order}", partner, orderId); return(OperationResult.ExceptionResult); } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="OrderProcessor"/> class. /// </summary> /// /// <param name="configuration">The configuration to use for influencing order processing behavior.</param> /// <param name="ecommerceClient">The client to use for interacting with the eCommerce service.</param> /// <param name="orderStorage">The storage to use for orders.</param> /// <param name="skuMetadataProcessor">The processor for the metadata associated with a SKU.</param> /// <param name="logger">The logger to be used for emitting telemetry from the controller.</param> /// <param name="clock">The clock instance to use for date/time related operations.</param> /// <param name="jsonSerializerSettings">The settings to use for JSON serializerion.</param> /// public OrderProcessor(OrderProcessorConfiguration configuration, IEcommerceClient ecommerceClient, IOrderStorage orderStorage, ISkuMetadataProcessor skuMetadataProcessor, ILogger logger, IClock clock, JsonSerializerSettings jsonSerializerSettings) { this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); this.ecommerceClient = ecommerceClient ?? throw new ArgumentNullException(nameof(ecommerceClient)); this.orderStorage = orderStorage ?? throw new ArgumentNullException(nameof(orderStorage)); this.skuMetadataProcessor = skuMetadataProcessor ?? throw new ArgumentNullException(nameof(skuMetadataProcessor)); this.Log = logger ?? throw new ArgumentNullException(nameof(logger)); this.clock = clock ?? throw new ArgumentNullException(nameof(clock)); this.jsonSerializerSettings = jsonSerializerSettings ?? throw new ArgumentNullException(nameof(jsonSerializerSettings)); this.rng = new Random(); }