-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AuthenticationResponse and PasswordChallengeResponse to UserManag…
…ement resources
- Loading branch information
1 parent
a430489
commit f8d1b1e
Showing
4 changed files
with
73 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,90 @@ | ||
from workos.resources.base import WorkOSBaseResource | ||
|
||
|
||
class WorkOSUser(WorkOSBaseResource): | ||
"""Representation of a User as returned by WorkOS through User Management features. | ||
class WorkOSAuthenticationResponse(WorkOSBaseResource): | ||
"""Representation of a User and Session response as returned by WorkOS through User Management features.""" | ||
|
||
@classmethod | ||
def construct_from_response(cls, response): | ||
authentication_response = super( | ||
WorkOSAuthenticationResponse, cls | ||
).construct_from_response(response) | ||
|
||
user = WorkOSUser.construct_from_response(response["user"]) | ||
authentication_response.user = user | ||
|
||
return authentication_response | ||
|
||
def to_dict(self): | ||
authentication_response_dict = super( | ||
WorkOSAuthenticationResponse, self | ||
).to_dict() | ||
|
||
user_dict = self.user.to_dict() | ||
authentication_response_dict["user"] = user_dict | ||
|
||
return authentication_response_dict | ||
|
||
|
||
class WorkOSOrganizationMembership(WorkOSBaseResource): | ||
"""Representation of an Organization Membership as returned by WorkOS through User Management features. | ||
Attributes: | ||
OBJECT_FIELDS (list): List of fields a WorkOSUser comprises. | ||
OBJECT_FIELDS (list): List of fields a WorkOSOrganizationMembership comprises. | ||
""" | ||
|
||
OBJECT_FIELDS = [ | ||
"id", | ||
"email", | ||
"first_name", | ||
"last_name", | ||
"email_verified", | ||
"user_id", | ||
"organization_id", | ||
"created_at", | ||
"updated_at", | ||
] | ||
|
||
|
||
class WorkOSOrganizationMembership(WorkOSBaseResource): | ||
"""Representation of an Organization Membership as returned by WorkOS through User Management features. | ||
class WorkOSPasswordChallengeResponse(WorkOSBaseResource): | ||
"""Representation of a User and token response as returned by WorkOS through User Management features. | ||
Attributes: | ||
OBJECT_FIELDS (list): List of fields a WorkOSPasswordChallengeResponse is comprised of. | ||
""" | ||
|
||
OBJECT_FIELDS = [ | ||
"token", | ||
] | ||
|
||
@classmethod | ||
def construct_from_response(cls, response): | ||
challenge_response = super( | ||
WorkOSPasswordChallengeResponse, cls | ||
).construct_from_response(response) | ||
|
||
user = WorkOSUser.construct_from_response(response["user"]) | ||
challenge_response.user = user | ||
|
||
return challenge_response | ||
|
||
def to_dict(self): | ||
challenge_response = super(WorkOSPasswordChallengeResponse, self).to_dict() | ||
|
||
user_dict = self.user.to_dict() | ||
challenge_response["user"] = user_dict | ||
|
||
return challenge_response | ||
|
||
|
||
class WorkOSUser(WorkOSBaseResource): | ||
"""Representation of a User as returned by WorkOS through User Management features. | ||
Attributes: | ||
OBJECT_FIELDS (list): List of fields a WorkOSOrganizationMembership comprises. | ||
OBJECT_FIELDS (list): List of fields a WorkOSUser comprises. | ||
""" | ||
|
||
OBJECT_FIELDS = [ | ||
"id", | ||
"user_id", | ||
"organization_id", | ||
"email", | ||
"first_name", | ||
"last_name", | ||
"email_verified", | ||
"created_at", | ||
"updated_at", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters