/// <inheritdoc cref="IServiceNotificationTransformer.FromNotification"/> public ServiceNotification FromNotification( CoinbaseNotification coinbaseNotification) { return(new ServiceNotification { Id = coinbaseNotification.Id.ToString(), Type = coinbaseNotification.Type, Resource = coinbaseNotification.Resource, AccountId = coinbaseNotification.Account?.Id.ToString(), UserId = coinbaseNotification.User?.Id.ToString(), TransactionId = coinbaseNotification.Data?.Transaction?.Id.ToString(), Address = coinbaseNotification.Data?.Address, CreatedAt = coinbaseNotification.CreatedAt, DeliveryAttempts = coinbaseNotification.DeliveryAttempts, Payload = JsonConvert.SerializeObject(coinbaseNotification) }); }
public StatusCodeResult Post( [FromBody] CoinbaseNotification coinbaseNotification) { if (coinbaseNotification == null) { _logger.LogError(ToDebugString(ModelState)); _logger.LogWarning("POST request was null."); return(ReturnStatusCode(HttpStatusCode.BadRequest)); } var savedCoinbaseNotification = _repository.Get(coinbaseNotification.Id.ToString()); if (savedCoinbaseNotification != null) { return(ReturnStatusCode(HttpStatusCode.OK)); } var notification = _transformer.FromNotification(coinbaseNotification); _repository.Add(notification); return(ReturnStatusCode(HttpStatusCode.OK)); }