/// <summary> /// Use the [GET] request to Inbucket API and return the targeted object. /// </summary> /// <typeparam name="T">The targeted object.</typeparam> /// <param name="self">The instance of the Inbucket client.</param> /// <param name="endpoint">The Inbucket API endpoint.</param> /// <returns>The targeted results.</returns> internal static async Task <T> GetAsync <T>(this InbucketClient self, string endpoint) { if (string.IsNullOrWhiteSpace(endpoint)) { throw new ArgumentNullException("API EndPoint required."); } var response = await self.Client.GetAsync(endpoint); return(await response.ReadAsJsonAsync <T>()); }
/// <summary> /// Use the [DELETE] request to Inbucket API and return the execution status. /// </summary> /// <param name="self">The instance of the Inbucket client.</param> /// <param name="endpoint">The Inbucket API endpoint.</param> /// <returns>True if deleted correctly, False otherwise.</returns> internal static async Task <bool> DeleteAsync(this InbucketClient self, string endpoint) { if (string.IsNullOrWhiteSpace(endpoint)) { throw new ArgumentNullException("API EndPoint required."); } var response = await self.Client.DeleteAsync(endpoint); return(response.IsSuccessStatusCode); }