Created
September 3, 2019 12:52
-
-
Save ntakouris/b9923ea833072c4e3ba13d654e377a37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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