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

Feature/endpoint class refactor #174

Merged
merged 6 commits into from
Dec 1, 2023

Conversation

MaxAndreassenRPM
Copy link
Contributor

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.

image

@MaxAndreassenRPM MaxAndreassenRPM changed the base branch from main to develop November 30, 2023 14:45
@@ -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,
Copy link
Contributor Author

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.

@HarrisonHough HarrisonHough self-requested a review December 1, 2023 11:34
Copy link
Collaborator

@HarrisonHough HarrisonHough left a 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!

@MaxAndreassenRPM MaxAndreassenRPM marked this pull request as ready for review December 1, 2023 13:22
@MaxAndreassenRPM MaxAndreassenRPM requested a review from a team as a code owner December 1, 2023 13:22
@@ -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)
Copy link
Collaborator

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?

Copy link
Contributor Author

@MaxAndreassenRPM MaxAndreassenRPM Dec 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be initialized with that value (see screenshot below):

I can update it if you think it makes sense to. Wasn't sure if it was done this way for a reason or not 🤔

image

Copy link
Collaborator

@HarrisonHough HarrisonHough left a 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.

@MaxAndreassenRPM MaxAndreassenRPM merged commit 5ae8679 into develop Dec 1, 2023
@MaxAndreassenRPM MaxAndreassenRPM deleted the feature/endpoint-class-refactor branch December 1, 2023 16:15
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

Successfully merging this pull request may close these issues.

2 participants