Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Feature Request: Extended schemas #4

Open
North101 opened this issue Jan 4, 2021 · 7 comments
Open

Feature Request: Extended schemas #4

North101 opened this issue Jan 4, 2021 · 7 comments

Comments

@North101
Copy link
Contributor

North101 commented Jan 4, 2021

I am currently using this hacky code to get the data I need. I'm not sure if theres a proper way to do it

const UserQueryObject = new Schemas.UserSchema({
  relationships: {
    memberships: Schemas.user_constants.relationships?.memberships,
    "memberships.campaign": "memberships.campaign", // not supported by lib but works
    campaign: Schemas.user_constants.relationships.campaign,
  } as any,
});

const endpointQuery = Endpoints.BuildEndpointQuery(UserQueryObject);
endpointQuery["fields[member]"] = "patron_status"; // not supported by lib but works

const query: string = Endpoints.BuildSimpleEndpoint(
  Endpoints.SimpleEndpoints.Identity,
  endpointQuery
);

const result: UserMembership = JSON.parse(
  await PatreonRequest(CreatePatreonTokenFromOAuthToken(accessToken), query)
);
@Zageron
Copy link
Owner

Zageron commented Jan 4, 2021

Looking in to this particular case.

@Zageron
Copy link
Owner

Zageron commented Jan 4, 2021

Man the patreon API continually surprises me at how nonsensical it is. 😂

@North101
Copy link
Contributor Author

North101 commented Jan 4, 2021

I was surprised when this worked tbh

@Zageron
Copy link
Owner

Zageron commented Jan 4, 2021

Yeah, I haven't used my own library to tease the API much, only using it for what I needed.
This definitely expands the ability to "just get everything all at once" rather than making multiple queries for specific information.
But at the same time it totally mucks up the typing paradigm I assumed.

It allows nested schemas... I assumed it only supported the APIs / schemas they listed.

@Zageron
Copy link
Owner

Zageron commented Jan 4, 2021

Ah, https://docs.patreon.com/#more-data-paging-and-sorting
Major oversight on my part.

@Zageron
Copy link
Owner

Zageron commented Jan 8, 2021

I'll be investigating a way to add this additional "fields["extras"]" thing, I think I should be able to do it more elegantly than it is currently. I'll update you in a week at most.

@North101
Copy link
Contributor Author

North101 commented Jan 8, 2021

Cool. No rush as the hack is working for me

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

No branches or pull requests

2 participants