Skip to content

Commit 310ad09

Browse files
committed
Add metadata to users and organizations
Eventually the API will always return something, but for now we can default to an empty object (which is what the API will eventually return).
1 parent a33e77a commit 310ad09

File tree

6 files changed

+11
-4
lines changed

6 files changed

+11
-4
lines changed

tests/test_user_management.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ def test_get_user_by_external_id(
411411
assert user.id == "user_01H7ZGXFP5C6BBQY6Z7277ZCT0"
412412
assert user.profile_picture_url == "https://example.com/profile-picture.jpg"
413413
assert user.last_sign_in_at == "2021-06-25T19:07:33.155Z"
414+
assert user.metadata == mock_user["metadata"]
414415

415416
def test_list_users_auto_pagination(
416417
self,

tests/utils/fixtures/mock_organization.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ def __init__(self, id):
2222
domain="example.io",
2323
)
2424
],
25+
metadata={"key": "value"},
2526
)

tests/utils/fixtures/mock_user.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ def __init__(self, id):
1717
last_sign_in_at="2021-06-25T19:07:33.155Z",
1818
created_at=now,
1919
updated_at=now,
20+
metadata={"key": "value"},
2021
)

workos/types/organizations/organization.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Optional, Sequence
1+
from dataclasses import field
2+
from typing import Optional, Sequence, Dict
23
from workos.types.organizations.organization_common import OrganizationCommon
34
from workos.types.organizations.organization_domain import OrganizationDomain
45

@@ -8,3 +9,4 @@ class Organization(OrganizationCommon):
89
domains: Sequence[OrganizationDomain]
910
stripe_customer_id: Optional[str] = None
1011
external_id: Optional[str] = None
12+
metadata: Dict[str, str] = field(default_factory=dict)

workos/types/user_management/user.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Literal, Optional
1+
from dataclasses import field
2+
from typing import Literal, Optional, Dict
23
from workos.types.workos_model import WorkOSModel
34

45

@@ -16,3 +17,4 @@ class User(WorkOSModel):
1617
created_at: str
1718
updated_at: str
1819
external_id: Optional[str] = None
20+
metadata: Dict[str, str] = field(default_factory=dict)

workos/user_management.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ def get_user(self, user_id: str) -> SyncOrAsync[User]:
139139
...
140140

141141
def get_user_by_external_id(self, external_id: str) -> SyncOrAsync[User]:
142-
"""Get the details of an existing user.
142+
"""Get the details of an existing user by external id.
143143
144144
Args:
145-
external_id (str): The user's external id
145+
external_id (str): User's external id
146146
Returns:
147147
User: User response from WorkOS.
148148
"""

0 commit comments

Comments
 (0)