public static string ConvertToString(SnippetsContentTypes value) { return(value switch { SnippetsContentTypes.MultipartRelated => "multipart/related", SnippetsContentTypes.MultipartFormdata => "multipart/formdata", _ => "application/json" });
public async Task <object> GetWorkspaceSnippetAsync(string workspaceId, string snippetId, SnippetsContentTypes accept = SnippetsContentTypes.ApplicationJson, Func <MultipartContentSection, object> contentSectionHandler = null) { string acceptString = SnippetsContentTypesConverter.ConvertToString(accept); var request = GetSnippetsUrl(workspaceId) .AppendPathSegment(snippetId) .AllowHttpStatus(HttpStatusCode.NotAcceptable) .WithHeader("Accept", acceptString); return(accept switch { SnippetsContentTypes.MultipartRelated => await request .GetMultipartAsync() .WithMultipartContentSectionsAsync(contentSectionHandler) .ConfigureAwait(false), SnippetsContentTypes.MultipartFormdata => await request .GetMultipartAsync() .WithMultipartContentSectionsAsync(contentSectionHandler) .ConfigureAwait(false), _ => await request .GetJsonAsync <Snippet>() .ConfigureAwait(false) });
public async Task GetWorkspaceSnippetWithMultipartContentSectionHandlerAsync(string workspaceId, SnippetsContentTypes accept) {