/// <summary> /// Updates the given <see cref="WebHookModel"/>. /// Please note that you should always use HTTPS when adding Webhooks in order to ensure security. /// Also, there is no way to validate that the request originate from Bizzebee, so it is important that you always validate these event with an API call. /// For example, if you receive a Webhook event regarding an order status update, validate this and retrieve the actual data of that order using a GET to /api/v2/orders/{order-id} /// All Webhook events will retry up to 10 times or until they get a 20x response. If they don't get a 20x response they will retry again after 30 min. /// </summary> /// <param name="webhookId">Id of the object being updated.</param> /// <param name="webhook">The <see cref="WebHookModel"/> to update.</param> /// <returns>The updated <see cref="WebHookModel"/>.</returns> public virtual async Task <WebHookModel> PatchAsync(int webhookId, WebHookModel webhook) { var req = PrepareRequest($"web-hooks/{webhookId}"); var body = webhook.ToDictionary(); var content = new JsonContent(body); return(await ExecuteRequestAsync <WebHookModel>(req, HttpMethod.Patch, content, "data")); }
/// <summary> /// Creates a new <see cref="WebHookModel"/> on the store. /// Please note that you should always use HTTPS when adding Webhooks in order to ensure security. /// Also, there is no way to validate that the request originate from Bizzebee, so it is important that you always validate these event with an API call. /// For example, if you receive a Webhook event regarding an order status update, validate this and retrieve the actual data of that order using a GET to /api/v2/orders/{order-id} /// All Webhook events will retry up to 10 times or until they get a 20x response. If they don't get a 20x response they will retry again after 30 min. /// </summary> /// <param name="webhook">A new <see cref="WebHookModel"/>. Id should be set to null.</param> /// <returns>The new <see cref="WebHookModel"/>.</returns> public virtual async Task <WebHookModel> CreateAsync(WebHookModel webhook) { var req = PrepareRequest("web-hooks"); var body = webhook.ToDictionary(); var content = new JsonContent(body); return(await ExecuteRequestAsync <WebHookModel>(req, HttpMethod.Post, content, "data")); }