Skip to content

Commit efa037c

Browse files
committed
Add role to OrganizationMembership class
1 parent e65ec1e commit efa037c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

tests/utils/fixtures/mock_organization_membership.py

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def __init__(self, id):
88
self.user_id = "user_12345"
99
self.organization_id = "org_67890"
1010
self.status = "active"
11+
self.role = { "slug": "member" },
1112
self.created_at = datetime.datetime.now()
1213
self.updated_at = datetime.datetime.now()
1314

@@ -16,6 +17,7 @@ def __init__(self, id):
1617
"user_id",
1718
"organization_id",
1819
"status",
20+
"role",
1921
"created_at",
2022
"updated_at",
2123
]

workos/resources/user_management.py

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class WorkOSOrganizationMembership(WorkOSBaseResource):
6969
"status",
7070
"created_at",
7171
"updated_at",
72+
"role",
7273
]
7374

7475

workos/user_management.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,21 @@ def delete_user(self, user_id):
201201
token=workos.api_key,
202202
)
203203

204-
def create_organization_membership(self, user_id, organization_id):
204+
def create_organization_membership(self, user_id, organization_id, role_slug):
205205
"""Create a new OrganizationMembership for the given Organization and User.
206206
207207
Args:
208208
user_id: The Unique ID of the User.
209209
organization_id: The Unique ID of the Organization to which the user belongs to.
210+
role_slug: The Unique Slug of the Role to which to grant to this membership.
211+
If no slug is passed in, the default role will be granted.(Optional)
210212
211213
Returns:
212214
dict: Created OrganizationMembership response from WorkOS.
213215
"""
214216
headers = {}
215217

216-
params = {"user_id": user_id, "organization_id": organization_id}
218+
params = {"user_id": user_id, "organization_id": organization_id, "role_slug": role_slug}
217219

218220
response = self.request_helper.request(
219221
ORGANIZATION_MEMBERSHIP_PATH,

0 commit comments

Comments
 (0)