Skip to content

Commit 2b004ed

Browse files
Add get_organization method (#72)
* Add get_connection endpoint * Fix missing import and variable * Fix implementation * Revert unneeded changes Co-authored-by: Marshall Bowers <[email protected]>
1 parent 9853e88 commit 2b004ed

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/test_organizations.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ def test_list_organizations(self, mock_organizations, mock_request_method):
6969
assert response.status_code == 200
7070
assert len(response.response_dict["data"]) == 2
7171

72+
def test_get_organization(self, mock_organization, mock_request_method):
73+
mock_response = Response()
74+
mock_response.status_code = 200
75+
mock_response.response_dict = mock_organization
76+
mock_request_method("get", mock_response, 200)
77+
response = self.organizations.get_organization(organization="organization_id")
78+
assert response.status_code == 200
79+
assert response.response_dict == mock_organization
80+
7281
def test_create_organization(self, mock_organization, mock_request_method):
7382
organization = {"domains": ["example.com"], "name": "Test Organization"}
7483
mock_response = Response()

workos/organizations.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ def list_organizations(
4444
token=workos.api_key,
4545
)
4646

47+
def get_organization(self, organization):
48+
"""Gets details for a single Organization
49+
Args:
50+
organization (str): Organization's unique identifier
51+
Returns:
52+
dict: Organization response from WorkOS
53+
"""
54+
return self.request_helper.request(
55+
"organizations/{organization}".format(organization=organization),
56+
method=REQUEST_METHOD_GET,
57+
token=workos.api_key,
58+
)
59+
4760
def create_organization(self, organization):
4861
"""Create an organization
4962

0 commit comments

Comments
 (0)