public static IList <Category> GetAllCategoriesRequest(this BaseApiRequestExecutor apiClient) { var candidateResults = apiClient.HttpGetListDeserialized <Category>(PrefixRoutePath); candidateResults.BuildTree(); return(candidateResults); }
public static string EchoRequest(this BaseApiRequestExecutor apiClient, string echoParam) { if (string.IsNullOrWhiteSpace(echoParam)) { throw new System.ArgumentNullException(nameof(echoParam)); } var reqRoutePath = "/api/v1/echo/{echoParam}"; reqRoutePath = reqRoutePath.Replace("{echoParam}", echoParam); return(apiClient.HttpGetDeserialized <string>(reqRoutePath)); }
public static Category CategoryCreateRequest(this BaseApiRequestExecutor apiClient, Category newCategory) { if (apiClient == null) { throw new ArgumentNullException(nameof(apiClient)); } if (newCategory == null) { throw new ArgumentNullException(nameof(newCategory)); } var reqRoutePath = PrefixRoutePath; return(apiClient.HttpPostDeserialized(reqRoutePath, newCategory)); }
public static Category CategoryByIdRequest(this BaseApiRequestExecutor apiClient, string categoryId) { if (string.IsNullOrEmpty(categoryId)) { throw new ArgumentException(nameof(categoryId)); } var reqRoutePathPattern = PrefixRoutePath + "/{0}"; var resultCandidate = apiClient.HttpGetDeserialized <Category>(string.Format(reqRoutePathPattern, categoryId)); resultCandidate.FullPath = resultCandidate.Name; var parentId = resultCandidate.ParentID; while (!string.IsNullOrEmpty(parentId)) { var parent = apiClient.HttpGetDeserialized <Category>(string.Format(reqRoutePathPattern, parentId)); resultCandidate.FullPath = $"{parent.Name}{Category.CFullPathSeparator}{resultCandidate.FullPath}"; parentId = parent.ParentID; } return(resultCandidate); }