/// <summary> /// Get one or many commits /// </summary> public async Task<ResponseWrapper<Commit>> Get(string projectKey, string repositorySlug, RequestOptions requestOptions = null, RequestOptionsForCommits commitRequestOptions = null) { string requestUrl = UrlBuilder.FormatRestApiUrlWithCommitOptions(MANY_COMMITS, requestOptions, commitRequestOptions, projectKey, repositorySlug); ResponseWrapper<Commit> response = await _httpWorker.GetAsync<ResponseWrapper<Commit>>(requestUrl).ConfigureAwait(false); return response; }
public static string FormatRestApiUrlWithCommitOptions(string restUrl, RequestOptions requestOptions = null, RequestOptionsForCommits commitRequestOptions = null, params string[] inputs) { string resultingUrl = FormatRestApiUrl(restUrl, requestOptions, inputs); if (commitRequestOptions != null) { string partialUrl = ""; bool urlHasQueryParams = restUrl.IndexOf('?') > -1; if (!string.IsNullOrWhiteSpace(commitRequestOptions.Path)) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("path={0}", commitRequestOptions.Path); } if (!string.IsNullOrWhiteSpace(commitRequestOptions.Since)) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("since={0}", commitRequestOptions.Since); } if (!string.IsNullOrWhiteSpace(commitRequestOptions.Until)) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("until={0}", commitRequestOptions.Until); } if (commitRequestOptions.WithCounts) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += "withCounts=true"; } resultingUrl += partialUrl; } return resultingUrl; }
public static string FormatRestApiUrlWithCommitOptions(string restUrl, RequestOptions requestOptions = null, RequestOptionsForCommits commitRequestOptions = null, params string[] inputs) { string resultingUrl = FormatRestApiUrl(restUrl, requestOptions, inputs); if (commitRequestOptions != null) { string partialUrl = ""; bool urlHasQueryParams = restUrl.IndexOf('?') > -1; if (!string.IsNullOrWhiteSpace(commitRequestOptions.Path)) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("path={0}", commitRequestOptions.Path); } if (!string.IsNullOrWhiteSpace(commitRequestOptions.Since)) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("since={0}", commitRequestOptions.Since); } if (!string.IsNullOrWhiteSpace(commitRequestOptions.Until)) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += string.Format("until={0}", commitRequestOptions.Until); } if (commitRequestOptions.WithCounts) { partialUrl += string.IsNullOrWhiteSpace(partialUrl) && !urlHasQueryParams ? "?" : "&"; partialUrl += "withCounts=true"; } resultingUrl += partialUrl; } return(resultingUrl); }