diff --git a/package-lock.json b/package-lock.json index eef5619..9d4621a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "devDependencies": { "@seamapi/fake-seam-connect": "1.86.0", "@seamapi/nextlove-sdk-generator": "^1.19.10", - "@seamapi/types": "1.874.0", + "@seamapi/types": "1.878.0", "del": "^7.1.0", "prettier": "^3.2.5" } @@ -535,9 +535,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.874.0", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.874.0.tgz", - "integrity": "sha512-dx9B6ZONj/jeySZCrwAIxsHEwdy/jCKKVgQB3wVGsW+PPaSIdzMTmb5IrTFtFt1gxZ0E3R00Q8mfD3IehvcJLw==", + "version": "1.878.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.878.0.tgz", + "integrity": "sha512-FnOvLZiSW6DKo2XFi+nwv96Sh1Vd0MheJ/N1OvAgVSk8X2nW4XrJkmUB4IHEQHhYUAXTbCTOq5O8oUpIgwEJZw==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 9c4af94..51b8180 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "devDependencies": { "@seamapi/fake-seam-connect": "1.86.0", "@seamapi/nextlove-sdk-generator": "^1.19.10", - "@seamapi/types": "1.874.0", + "@seamapi/types": "1.878.0", "del": "^7.1.0", "prettier": "^3.2.5" } diff --git a/seam/routes/access_methods.py b/seam/routes/access_methods.py index 0d6524b..a006dd8 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, ActionAttempt, AccessMethod, Batch +from .models import AbstractAccessMethods, AccessMethod, ActionAttempt, Batch from .access_methods_unmanaged import AccessMethodsUnmanaged from ..modules.action_attempts import resolve_action_attempt @@ -15,6 +15,18 @@ def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]): def unmanaged(self) -> AccessMethodsUnmanaged: return self._unmanaged + def assign_card(self, *, access_method_id: str, card_number: str) -> AccessMethod: + json_payload = {} + + if access_method_id is not None: + json_payload["access_method_id"] = access_method_id + if card_number is not None: + json_payload["card_number"] = card_number + + res = self.client.post("/access_methods/assign_card", json=json_payload) + + return AccessMethod.from_dict(res["access_method"]) + def delete( self, *, @@ -121,3 +133,31 @@ def list( res = self.client.post("/access_methods/list", json=json_payload) return [AccessMethod.from_dict(item) for item in res["access_methods"]] + + def unlock_door( + self, + *, + access_method_id: str, + acs_entrance_id: str, + wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None + ) -> ActionAttempt: + json_payload = {} + + if access_method_id is not None: + json_payload["access_method_id"] = access_method_id + if acs_entrance_id is not None: + json_payload["acs_entrance_id"] = acs_entrance_id + + res = self.client.post("/access_methods/unlock_door", json=json_payload) + + wait_for_action_attempt = ( + self.defaults.get("wait_for_action_attempt") + if wait_for_action_attempt is None + else wait_for_action_attempt + ) + + return resolve_action_attempt( + client=self.client, + action_attempt=ActionAttempt.from_dict(res["action_attempt"]), + wait_for_action_attempt=wait_for_action_attempt, + ) diff --git a/seam/routes/models.py b/seam/routes/models.py index ed7df05..5cd0639 100644 --- a/seam/routes/models.py +++ b/seam/routes/models.py @@ -128,8 +128,10 @@ class AccessMethod: customization_profile_id: str display_name: str instant_key_url: str + is_assignment_required: bool is_encoding_required: bool is_issued: bool + is_ready_for_assignment: bool is_ready_for_encoding: bool issued_at: str mode: str @@ -147,8 +149,10 @@ def from_dict(d: Dict[str, Any]): customization_profile_id=d.get("customization_profile_id", None), display_name=d.get("display_name", None), instant_key_url=d.get("instant_key_url", None), + is_assignment_required=d.get("is_assignment_required", None), is_encoding_required=d.get("is_encoding_required", None), is_issued=d.get("is_issued", None), + is_ready_for_assignment=d.get("is_ready_for_assignment", None), is_ready_for_encoding=d.get("is_ready_for_encoding", None), issued_at=d.get("issued_at", None), mode=d.get("mode", None), @@ -3237,6 +3241,10 @@ class AbstractAccessMethods(abc.ABC): def unmanaged(self) -> AbstractAccessMethodsUnmanaged: raise NotImplementedError() + @abc.abstractmethod + def assign_card(self, *, access_method_id: str, card_number: str) -> AccessMethod: + raise NotImplementedError() + @abc.abstractmethod def delete( self, @@ -3284,6 +3292,16 @@ def list( ) -> List[AccessMethod]: raise NotImplementedError() + @abc.abstractmethod + def unlock_door( + self, + *, + access_method_id: str, + acs_entrance_id: str, + wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None + ) -> ActionAttempt: + raise NotImplementedError() + class AbstractConnectedAccounts(abc.ABC):