-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path__init__.py
More file actions
34 lines (26 loc) · 903 Bytes
/
__init__.py
File metadata and controls
34 lines (26 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from typing import TypedDict, Dict
import logging
log = logging.getLogger("socketdev")
class Organization(TypedDict):
id: str
name: str
image: str
plan: str
slug: str
class OrganizationsResponse(TypedDict):
organizations: Dict[str, Organization]
# Add other fields from the response if needed
class Orgs:
def __init__(self, api):
self.api = api
def get(self, use_types: bool = False) -> OrganizationsResponse:
path = "organizations"
response = self.api.do_request(path=path)
if response.status_code == 200:
result = response.json()
if use_types:
return OrganizationsResponse(result)
return result
log.error(f"Error getting organizations: {response.status_code}")
log.error(response.text)
return {"organizations": {}}