-
Notifications
You must be signed in to change notification settings - Fork 33
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
Feature/endpoint class refactor #174
Conversation
@@ -11,7 +11,7 @@ public static class AvatarRenderHelper | |||
public static async Task<Texture2D> GetPortrait(string avatarId, CancellationToken token = default) | |||
{ | |||
var webRequestDispatcher = new WebRequestDispatcher(); | |||
var response = await webRequestDispatcher.SendRequest<ResponseTexture>(AvatarEndpoints.GetRenderEndpoint(avatarId), HttpMethod.GET, | |||
var response = await webRequestDispatcher.SendRequest<ResponseTexture>($"{Env.RPM_MODELS_BASE_URL}/{avatarId}.png", HttpMethod.GET, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small improvement I'd now make (but haven't done here yet) is to move this into the main avatar api class, since this class isn't a helper, it's just a class with another avatar api request in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Cool stuff!
@@ -9,20 +9,21 @@ public class AuthAPIRequests | |||
{ | |||
private readonly string domain; | |||
private readonly IDictionary<string, string> headers = CommonHeaders.GetHeadersWithAppId(); | |||
private readonly string rpmAuthBaseUrl; | |||
|
|||
private readonly WebRequestDispatcher webRequestDispatcher; | |||
|
|||
public AuthAPIRequests(string domain) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this domain = subdomain? and if so why is it not using core settings subdomain that is used everywhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks fine and seems to work, one question about the API request domain param in constructor. Not sure if I am misinterpreting the use of the domain.
Here is a draft PR for removing the concept of endpoint files whose sole purpose is to define the URLs for requests. In this PR, each lowest level SDK method fully encapsulates what it needs to make a request to the API, and so you only have to look in 1 place to understand how a request works. Furthermore, adding future requests now only requires you to add 1 new function, rather than update 2 classes each time.
This is PR is only a draft, as there was still some debate about this. However, I wanted to create a PR to illustrate how it would work. There is still other work to do, but my hope is that this is another step towards make the project structure of the SDK easier to digest and understand.