-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(users): Add users collection to SDK #52
Conversation
Hey @benmvp, What do you think of this to start? |
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.
Yeah I like where this is going. I think this is much more helpful than having to make the raw call.
I would add two additional things:
- A link somewhere in the API docs that describes what properties exist in a
User
object (we don't want to have to maintain the docs here) - For each method a link to the vanilla/raw API doc
I am going to beef up the test suite for this and add the other methods, unless you spot anything. |
Merged @jcreamer898 changes, and added a commit to make jsonRequest generic, so we only have to instantiate it once. |
src/users.ts
Outdated
const snakeToCamel = (str: string) => | ||
str.replace(SNAKE_CASE_MATCH, (chars: string) => chars[1].toUpperCase()); | ||
|
||
const transformKeysSnakeToCamel = (obj: {}): {} => |
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.
do you wanna use a lib like camelize
? https://yarnpkg.com/en/package/camelize. Cuz now in theory we need tests for transformKeysSnakeToCamel
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.
I will look into a package, however that one will not work because it also converts dotCase to camel, which breaks our API. That is what led us to making this function internally.
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.
This is turning out to be difficult to find something for since it is very generic, but all of them convert expand.destination_event
to expandDestinationEvent
, which is undesired.
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.
What do you think about leaving this and adding tests? It is that or I make a package of 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.
I moved this around and added tests. Also working on adding something to camel-keys to allow us to be able to remove this.
} | ||
|
||
export interface User { | ||
id?: string; |
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.
are these really optional? The API always returns the fields right? Same with Email
above
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.
It's best to leave fields on domain objects optional so when you're doing something like...
api.create({
name: 'foo',
email: '[email protected]'
});
You don't have to specify each field.
The alternative is to do Partial<User>
, but it's really just easier to switch them to optional.
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.
We may need to verify the model 😅. I have null first and last, but I have a name. I imagine image_id is also nullable.
{
"emails": [
{
"email": "<REDACTED>",
"verified": false,
"primary": true
}
],
"id": "<REDACTED>",
"name": "<REDACTED>",
"first_name": null,
"last_name": null,
"is_public": false,
"image_id": "<REDACTED>"
}
fix(types): update generics in request
I think this is all set. Please review again. |
🎉 This PR is included in version 1.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
This is a draft of the users api to be added to the SDK.
For starters, I have added the documentation so we can discuss its usage.
This will be the template we use for implementation and the go forward direction for adding more collections to the SDK.
How Has This Been Tested?
This will be tests through unit tests once implemented. We may also consider adding a simple app to this project to test this on the node and client side.
Screenshots (if appropriate):
Checklist:
yarn validate
to ensure that tests, typescript and linting are all in order.