/// <summary> /// Updates the given <see cref="Redirect"/>. /// </summary> /// <param name="redirectId">Id of the object being updated.</param> /// <param name="redirect">The <see cref="Redirect"/> to update.</param> /// <returns>The updated <see cref="Redirect"/>.</returns> public virtual async Task <Redirect> UpdateAsync(long redirectId, Redirect redirect) { var req = PrepareRequest($"redirects/{redirectId}.json"); var content = new JsonContent(new { redirect = redirect }); return(await ExecuteRequestAsync <Redirect>(req, HttpMethod.Put, content, "redirect")); }
/// <summary> /// Creates a new <see cref="Redirect"/> on the store. The redirect always starts out with a role of /// "unpublished." If the redirect has a different role, it will be assigned that only after all of its /// files have been extracted and stored by Shopify (which might take a couple of minutes). /// </summary> /// <param name="redirect">The new <see cref="Redirect"/>.</param> /// <returns>The new <see cref="Redirect"/>.</returns> public virtual async Task <Redirect> CreateAsync(Redirect redirect) { var req = PrepareRequest("redirects.json"); var content = new JsonContent(new { redirect = redirect }); return(await ExecuteRequestAsync <Redirect>(req, HttpMethod.Post, content, "redirect")); }
/// <summary> /// Creates a new <see cref="Redirect"/> on the store. The redirect always starts out with a role of /// "unpublished." If the redirect has a different role, it will be assigned that only after all of its /// files have been extracted and stored by Shopify (which might take a couple of minutes). /// </summary> /// <param name="redirect">The new <see cref="Redirect"/>.</param> /// <param name="cancellationToken">Cancellation Token</param> /// <returns>The new <see cref="Redirect"/>.</returns> public virtual async Task <Redirect> CreateAsync(Redirect redirect, CancellationToken cancellationToken = default) { var req = PrepareRequest("redirects.json"); var content = new JsonContent(new { redirect = redirect }); var response = await ExecuteRequestAsync <Redirect>(req, HttpMethod.Post, cancellationToken, content, "redirect"); return(response.Result); }