Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created September 3, 2019 12:52
Show Gist options
  • Save ntakouris/b9923ea833072c4e3ba13d654e377a37 to your computer and use it in GitHub Desktop.
Save ntakouris/b9923ea833072c4e3ba13d654e377a37 to your computer and use it in GitHub Desktop.
public class UriService : IUriService
{
private readonly string _baseUri;
public UriService(string baseUri)
{
_baseUri = baseUri;
}
public Uri GetPostUri(string postId)
{
return new Uri(_baseUri + ApiRoutes.Posts.Get.Replace("{postId}", postId));
}
public Uri GetAllPostsUri(PaginationQuery pagination = null)
{
var uri = new Uri(_baseUri);
if (pagination == null)
{
return uri;
}
var modifiedUri = QueryHelpers.AddQueryString(_baseUri, "pageNumber", pagination.PageNumber.ToString());
modifiedUri = QueryHelpers.AddQueryString(modifiedUri, "pageSize", pagination.PageSize.ToString());
return new Uri(modifiedUri);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment