Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic parameter array to endpoints #28

Open
plutora-steve-g opened this issue Jan 14, 2022 · 2 comments
Open

Add generic parameter array to endpoints #28

plutora-steve-g opened this issue Jan 14, 2022 · 2 comments

Comments

@plutora-steve-g
Copy link

I needed to get PRs in all states, and the state parameter wasn't available so I locally modified GetRepositoryPullRequestsAsync:

		public async Task<IEnumerable<PullRequest>> GetRepositoryPullRequestsAsync(string workspaceId, string repositorySlug, int? maxPages = null, string q = null, PullRequestStates[] states = null)
		{
			var queryParamValues = new Dictionary<string, object>
			{
				[nameof(q)] = q,
				["state"] = states
			};

It would be nice to add Dictionary<string, object> otherQueryParameters to all APIs which would be less work than working out which parameters could be added per call, and it futureproofs the library if there are new parameters added to the Bitbucket API.

An alternate/complimentary idea would be to have some sort of callback after SetQueryParams(qpv) to let the query string to be modified. Leads to the potential for other callbacks, although you probably would want to abstract furl away from the callbacks.

Example, although, being lazy, I'd be inclined to create new furl extensions that would combine the existing furl call with the callback.

			return await GetPagedResultsAsync(maxPages, queryParamValues, async qpv =>
					await GetPullRequestsUrl(workspaceId, repositorySlug)
                                                // Modify the URL
                                                .GetPullRequestsUrlEvent()
						.SetQueryParams(qpv)
                                                // modify parameters
                                                .SetQueryParamsEvent()
						.GetJsonAsync<PagedResults<PullRequest>>()
                                                // hack/log json?
                                                .GetJsonAsyncEvent()
						.ConfigureAwait(false))
				.ConfigureAwait(false);

Finally, thanks for writing this library!

@erayit
Copy link

erayit commented Mar 16, 2023

This enhancement would be fantastic. I ended up scrapping the use of the library due to this limitation and building my own using REST API calls which is a bunch of unnecessary work. This library is very nice and I hope it can be updated soon

@nickntg
Copy link

nickntg commented Apr 9, 2023

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants