diff --git a/package-lock.json b/package-lock.json index fdd857f..a24e30c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "devDependencies": { "@seamapi/fake-seam-connect": "1.83.1", "@seamapi/nextlove-sdk-generator": "^1.18.1", - "@seamapi/types": "1.410.1", + "@seamapi/types": "1.411.1", "del": "^7.1.0", "prettier": "^3.2.5" } @@ -475,9 +475,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.410.1", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.410.1.tgz", - "integrity": "sha512-PmPBVbx2B7sRirjJYMx4DMoHWJwZT0cZTkM0NioUa6AfCzcRUi3uT1ZG/efy2SeTTSm1NqMf90mNoQ8EaNrdjQ==", + "version": "1.411.1", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.411.1.tgz", + "integrity": "sha512-ZXQ2JjNoKs094/NHx6wVigNbfdQtHa6aCrOiIDBPiW/IfGuEW8cG+eojI1EmODdG/zD0OCZnkqCrcdFy9YcY0Q==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 6dceb45..c6ae28f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "devDependencies": { "@seamapi/fake-seam-connect": "1.83.1", "@seamapi/nextlove-sdk-generator": "^1.18.1", - "@seamapi/types": "1.410.1", + "@seamapi/types": "1.411.1", "del": "^7.1.0", "prettier": "^3.2.5" } diff --git a/seam/routes/access_grants.py b/seam/routes/access_grants.py index 58c874b..ecb1fe0 100644 --- a/seam/routes/access_grants.py +++ b/seam/routes/access_grants.py @@ -1,6 +1,6 @@ from typing import Optional, Any, List, Dict, Union from ..client import SeamHttpClient -from .models import AbstractAccessGrants +from .models import AbstractAccessGrants, AccessGrant class AccessGrants(AbstractAccessGrants): @@ -21,7 +21,7 @@ def create( location_ids: Optional[List[str]] = None, space_ids: Optional[List[str]] = None, starts_at: Optional[str] = None - ) -> None: + ) -> AccessGrant: json_payload = {} if requested_access_methods is not None: @@ -45,9 +45,9 @@ def create( if starts_at is not None: json_payload["starts_at"] = starts_at - self.client.post("/access_grants/create", json=json_payload) + res = self.client.post("/access_grants/create", json=json_payload) - return None + return AccessGrant.from_dict(res["access_grant"]) def delete(self, *, access_grant_id: str) -> None: json_payload = {} @@ -59,15 +59,15 @@ def delete(self, *, access_grant_id: str) -> None: return None - def get(self, *, access_grant_id: str) -> None: + def get(self, *, access_grant_id: str) -> AccessGrant: json_payload = {} if access_grant_id is not None: json_payload["access_grant_id"] = access_grant_id - self.client.post("/access_grants/get", json=json_payload) + res = self.client.post("/access_grants/get", json=json_payload) - return None + return AccessGrant.from_dict(res["access_grant"]) def list( self, @@ -77,7 +77,7 @@ def list( location_id: Optional[str] = None, space_id: Optional[str] = None, user_identity_id: Optional[str] = None - ) -> None: + ) -> List[AccessGrant]: json_payload = {} if acs_entrance_id is not None: @@ -91,6 +91,6 @@ def list( if user_identity_id is not None: json_payload["user_identity_id"] = user_identity_id - self.client.post("/access_grants/list", json=json_payload) + res = self.client.post("/access_grants/list", json=json_payload) - return None + return [AccessGrant.from_dict(item) for item in res["access_grants"]] diff --git a/seam/routes/access_methods.py b/seam/routes/access_methods.py index d7336ed..0bd6115 100644 --- a/seam/routes/access_methods.py +++ b/seam/routes/access_methods.py @@ -1,6 +1,6 @@ from typing import Optional, Any, List, Dict, Union from ..client import SeamHttpClient -from .models import AbstractAccessMethods +from .models import AbstractAccessMethods, AccessMethod class AccessMethods(AbstractAccessMethods): @@ -18,22 +18,22 @@ def delete(self, *, access_method_id: str) -> None: return None - def get(self, *, access_method_id: str) -> None: + def get(self, *, access_method_id: str) -> AccessMethod: json_payload = {} if access_method_id is not None: json_payload["access_method_id"] = access_method_id - self.client.post("/access_methods/get", json=json_payload) + res = self.client.post("/access_methods/get", json=json_payload) - return None + return AccessMethod.from_dict(res["access_method"]) - def list(self, *, access_grant_id: str) -> None: + def list(self, *, access_grant_id: str) -> List[AccessMethod]: json_payload = {} if access_grant_id is not None: json_payload["access_grant_id"] = access_grant_id - self.client.post("/access_methods/list", json=json_payload) + res = self.client.post("/access_methods/list", json=json_payload) - return None + return [AccessMethod.from_dict(item) for item in res["access_methods"]] diff --git a/seam/routes/models.py b/seam/routes/models.py index 850f1b8..d5b393a 100644 --- a/seam/routes/models.py +++ b/seam/routes/models.py @@ -62,6 +62,58 @@ def from_dict(d: Dict[str, Any]): ) +@dataclass +class AccessGrant: + access_grant_id: str + access_method_ids: List[str] + created_at: str + display_name: str + location_ids: List[str] + requested_access_methods: List[Dict[str, Any]] + space_ids: List[str] + user_identity_id: str + workspace_id: str + + @staticmethod + def from_dict(d: Dict[str, Any]): + return AccessGrant( + access_grant_id=d.get("access_grant_id", None), + access_method_ids=d.get("access_method_ids", None), + created_at=d.get("created_at", None), + display_name=d.get("display_name", None), + location_ids=d.get("location_ids", None), + requested_access_methods=d.get("requested_access_methods", None), + space_ids=d.get("space_ids", None), + user_identity_id=d.get("user_identity_id", None), + workspace_id=d.get("workspace_id", None), + ) + + +@dataclass +class AccessMethod: + access_method_id: str + created_at: str + display_name: str + instant_key_url: str + is_card_encoding_required: bool + issued_at: str + mode: str + workspace_id: str + + @staticmethod + def from_dict(d: Dict[str, Any]): + return AccessMethod( + access_method_id=d.get("access_method_id", None), + created_at=d.get("created_at", None), + display_name=d.get("display_name", None), + instant_key_url=d.get("instant_key_url", None), + is_card_encoding_required=d.get("is_card_encoding_required", None), + issued_at=d.get("issued_at", None), + mode=d.get("mode", None), + workspace_id=d.get("workspace_id", None), + ) + + @dataclass class AcsAccessGroup: access_group_type: str @@ -1333,7 +1385,7 @@ def create( location_ids: Optional[List[str]] = None, space_ids: Optional[List[str]] = None, starts_at: Optional[str] = None - ) -> None: + ) -> AccessGrant: raise NotImplementedError() @abc.abstractmethod @@ -1341,7 +1393,7 @@ def delete(self, *, access_grant_id: str) -> None: raise NotImplementedError() @abc.abstractmethod - def get(self, *, access_grant_id: str) -> None: + def get(self, *, access_grant_id: str) -> AccessGrant: raise NotImplementedError() @abc.abstractmethod @@ -1353,7 +1405,7 @@ def list( location_id: Optional[str] = None, space_id: Optional[str] = None, user_identity_id: Optional[str] = None - ) -> None: + ) -> List[AccessGrant]: raise NotImplementedError() @@ -1364,11 +1416,11 @@ def delete(self, *, access_method_id: str) -> None: raise NotImplementedError() @abc.abstractmethod - def get(self, *, access_method_id: str) -> None: + def get(self, *, access_method_id: str) -> AccessMethod: raise NotImplementedError() @abc.abstractmethod - def list(self, *, access_grant_id: str) -> None: + def list(self, *, access_grant_id: str) -> List[AccessMethod]: raise NotImplementedError()