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

Add PrimaryEmail method for Directory User #169

Merged
merged 4 commits into from
Oct 25, 2022

Conversation

AshGodfrey
Copy link
Contributor

Adds a method to get the primary email of a directory user.

@AshGodfrey AshGodfrey requested a review from a team as a code owner September 9, 2022 19:20
@linear
Copy link

linear bot commented Sep 9, 2022

expected: "firstprimaryemail@foo-corp.com",
},
{
scenario: "No primary emails returns null",
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we're returning an error rather than null here. Can we rename these tests to indicate an error is returned as well as an empty string?

@@ -72,3 +73,13 @@ func DeleteDirectory(
) error {
return DefaultClient.DeleteDirectory(ctx, opts)
}

// PrimaryEmail is a method for finding a user's primary email (when applicable)
func (r User) PrimaryEmail() (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this logic be in the client.go file, like the other methods? And then called via DefaultClient?

Copy link
Contributor Author

@AshGodfrey AshGodfrey Oct 24, 2022

Choose a reason for hiding this comment

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

I could be wrong here, but my gut said no. Client performs Directory Sync requests to the WorkOS API, but primary email doesn't actually make a request to the API, it just takes information that already exists from the User type and distills it.

Someone more familiar than me may need to confirm my understanding.

Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand this correctly, I do think that the PrimaryEmail should be a method on the User object rather than being tied with the methods on the client that actually call the API.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh ok, that makes sense. It's just we only have methods that use the client that connects to the API, so that's why we have that logic in the client now.

@AshGodfrey AshGodfrey merged commit a4da745 into main Oct 25, 2022
@AshGodfrey AshGodfrey deleted the feature/sup-630-add-get-primary-email-method-go branch October 25, 2022 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants