public WebhookDeliveryRequest(string webhookId, WebhookEvent webhookEvent, Data.WebhookDeliveryData delivery, WebhookBlob webhookBlob) { WebhookId = webhookId; WebhookEvent = webhookEvent; Delivery = delivery; WebhookBlob = webhookBlob; }
public async Task UpdateWebhook(string storeId, string webhookId, WebhookBlob webhookBlob) { if (webhookId == null) { throw new ArgumentNullException(nameof(webhookId)); } if (storeId == null) { throw new ArgumentNullException(nameof(storeId)); } if (webhookBlob == null) { throw new ArgumentNullException(nameof(webhookBlob)); } using var ctx = _ContextFactory.CreateContext(); var hook = await ctx.StoreWebhooks .Where(s => s.StoreId == storeId && s.WebhookId == webhookId) .Select(s => s.Webhook) .FirstOrDefaultAsync(); if (hook is null) { return; } hook.SetBlob(webhookBlob); await ctx.SaveChangesAsync(); }
public async Task <string> CreateWebhook(string storeId, WebhookBlob blob) { if (storeId == null) { throw new ArgumentNullException(nameof(storeId)); } if (blob == null) { throw new ArgumentNullException(nameof(blob)); } using var ctx = _ContextFactory.CreateContext(); WebhookData data = new WebhookData(); data.Id = Encoders.Base58.EncodeData(RandomUtils.GetBytes(16)); if (string.IsNullOrEmpty(blob.Secret)) { blob.Secret = Encoders.Base58.EncodeData(RandomUtils.GetBytes(16)); } data.SetBlob(blob); StoreWebhookData storeWebhook = new StoreWebhookData(); storeWebhook.StoreId = storeId; storeWebhook.WebhookId = data.Id; ctx.StoreWebhooks.Add(storeWebhook); ctx.Webhooks.Add(data); await ctx.SaveChangesAsync(); return(data.Id); }
public EditWebhookViewModel(WebhookBlob blob) { Active = blob.Active; AutomaticRedelivery = blob.AutomaticRedelivery; Everything = blob.AuthorizedEvents.Everything; Events = blob.AuthorizedEvents.SpecificEvents; PayloadUrl = blob.Url; Secret = blob.Secret; IsNew = false; }
public async Task UpdateWebhook(string storeId, string webhookId, WebhookBlob webhookBlob) { var ctx = _ContextFactory.CreateContext(); var hook = await ctx.StoreWebhooks .Where(s => s.StoreId == storeId && s.WebhookId == webhookId) .Select(s => s.Webhook) .FirstOrDefaultAsync(); if (hook is null) { return; } hook.SetBlob(webhookBlob); await ctx.SaveChangesAsync(); }