diff --git a/package-lock.json b/package-lock.json index 54de58cc..5a8cb93f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,7 @@ "devDependencies": { "@seamapi/fake-seam-connect": "1.83.2", "@seamapi/nextlove-sdk-generator": "^1.18.1", - "@seamapi/types": "1.420.2", + "@seamapi/types": "1.423.2", "del": "^7.1.0", "prettier": "^3.2.5" } @@ -475,9 +475,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.420.2", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.420.2.tgz", - "integrity": "sha512-3W6YwDWIUsfwvEzzF6HuDNryqSqtywoGvi+zfLf9Js/wh88A3DKXYOmwamGWLus2L6vTp28F4aipcu5uNQndow==", + "version": "1.423.2", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.423.2.tgz", + "integrity": "sha512-EfMNHNE0k3Mp+AgjEDzzmnjsvOf7yrt9qG5ZZkjVqaTGsOAYTRjrRMLFz37s8My+evXn8i0Ry4wijhoXKhFviw==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index 44bf5e6e..58b3e369 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "devDependencies": { "@seamapi/fake-seam-connect": "1.83.2", "@seamapi/nextlove-sdk-generator": "^1.18.1", - "@seamapi/types": "1.420.2", + "@seamapi/types": "1.423.2", "del": "^7.1.0", "prettier": "^3.2.5" } diff --git a/seam/routes/__init__.py b/seam/routes/__init__.py index da6e739c..e2e65148 100644 --- a/seam/routes/__init__.py +++ b/seam/routes/__init__.py @@ -9,6 +9,7 @@ from .client_sessions import ClientSessions from .connect_webviews import ConnectWebviews from .connected_accounts import ConnectedAccounts +from .customers import Customers from .devices import Devices from .events import Events from .locks import Locks @@ -31,6 +32,7 @@ def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]): self.client_sessions = ClientSessions(client=client, defaults=defaults) self.connect_webviews = ConnectWebviews(client=client, defaults=defaults) self.connected_accounts = ConnectedAccounts(client=client, defaults=defaults) + self.customers = Customers(client=client, defaults=defaults) self.devices = Devices(client=client, defaults=defaults) self.events = Events(client=client, defaults=defaults) self.locks = Locks(client=client, defaults=defaults) diff --git a/seam/routes/customers.py b/seam/routes/customers.py new file mode 100644 index 00000000..638553c6 --- /dev/null +++ b/seam/routes/customers.py @@ -0,0 +1,88 @@ +from typing import Optional, Any, List, Dict, Union +from ..client import SeamHttpClient +from .models import AbstractCustomers, MagicLink + + +class Customers(AbstractCustomers): + def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]): + self.client = client + self.defaults = defaults + + def create_portal( + self, + *, + features: Optional[Dict[str, Any]] = None, + customer_data: Optional[Dict[str, Any]] = None + ) -> MagicLink: + json_payload = {} + + if features is not None: + json_payload["features"] = features + if customer_data is not None: + json_payload["customer_data"] = customer_data + + res = self.client.post("/customers/create_portal", json=json_payload) + + return MagicLink.from_dict(res["magic_link"]) + + def push_data( + self, + *, + customer_key: str, + access_grants: Optional[List[Dict[str, Any]]] = None, + bookings: Optional[List[Dict[str, Any]]] = None, + buildings: Optional[List[Dict[str, Any]]] = None, + common_areas: Optional[List[Dict[str, Any]]] = None, + facilities: Optional[List[Dict[str, Any]]] = None, + guests: Optional[List[Dict[str, Any]]] = None, + listings: Optional[List[Dict[str, Any]]] = None, + properties: Optional[List[Dict[str, Any]]] = None, + reservations: Optional[List[Dict[str, Any]]] = None, + residents: Optional[List[Dict[str, Any]]] = None, + rooms: Optional[List[Dict[str, Any]]] = None, + spaces: Optional[List[Dict[str, Any]]] = None, + tenants: Optional[List[Dict[str, Any]]] = None, + units: Optional[List[Dict[str, Any]]] = None, + user_identities: Optional[List[Dict[str, Any]]] = None, + users: Optional[List[Dict[str, Any]]] = None + ) -> None: + json_payload = {} + + if customer_key is not None: + json_payload["customer_key"] = customer_key + if access_grants is not None: + json_payload["access_grants"] = access_grants + if bookings is not None: + json_payload["bookings"] = bookings + if buildings is not None: + json_payload["buildings"] = buildings + if common_areas is not None: + json_payload["common_areas"] = common_areas + if facilities is not None: + json_payload["facilities"] = facilities + if guests is not None: + json_payload["guests"] = guests + if listings is not None: + json_payload["listings"] = listings + if properties is not None: + json_payload["properties"] = properties + if reservations is not None: + json_payload["reservations"] = reservations + if residents is not None: + json_payload["residents"] = residents + if rooms is not None: + json_payload["rooms"] = rooms + if spaces is not None: + json_payload["spaces"] = spaces + if tenants is not None: + json_payload["tenants"] = tenants + if units is not None: + json_payload["units"] = units + if user_identities is not None: + json_payload["user_identities"] = user_identities + if users is not None: + json_payload["users"] = users + + self.client.post("/customers/push_data", json=json_payload) + + return None diff --git a/seam/routes/models.py b/seam/routes/models.py index 7f8d4ff2..430d669a 100644 --- a/seam/routes/models.py +++ b/seam/routes/models.py @@ -983,39 +983,6 @@ def from_dict(d: Dict[str, Any]): ) -@dataclass -class PartnerResource: - custom_metadata: Dict[str, Any] - customer_key: str - description: str - email_address: str - ends_at: str - location_keys: List[str] - name: str - partner_resource_key: str - partner_resource_type: str - phone_number: str - starts_at: str - user_identity_key: str - - @staticmethod - def from_dict(d: Dict[str, Any]): - return PartnerResource( - custom_metadata=DeepAttrDict(d.get("custom_metadata", None)), - customer_key=d.get("customer_key", None), - description=d.get("description", None), - email_address=d.get("email_address", None), - ends_at=d.get("ends_at", None), - location_keys=d.get("location_keys", None), - name=d.get("name", None), - partner_resource_key=d.get("partner_resource_key", None), - partner_resource_type=d.get("partner_resource_type", None), - phone_number=d.get("phone_number", None), - starts_at=d.get("starts_at", None), - user_identity_key=d.get("user_identity_key", None), - ) - - @dataclass class Phone: created_at: str @@ -2146,6 +2113,42 @@ def update( raise NotImplementedError() +class AbstractCustomers(abc.ABC): + + @abc.abstractmethod + def create_portal( + self, + *, + features: Optional[Dict[str, Any]] = None, + customer_data: Optional[Dict[str, Any]] = None + ) -> MagicLink: + raise NotImplementedError() + + @abc.abstractmethod + def push_data( + self, + *, + customer_key: str, + access_grants: Optional[List[Dict[str, Any]]] = None, + bookings: Optional[List[Dict[str, Any]]] = None, + buildings: Optional[List[Dict[str, Any]]] = None, + common_areas: Optional[List[Dict[str, Any]]] = None, + facilities: Optional[List[Dict[str, Any]]] = None, + guests: Optional[List[Dict[str, Any]]] = None, + listings: Optional[List[Dict[str, Any]]] = None, + properties: Optional[List[Dict[str, Any]]] = None, + reservations: Optional[List[Dict[str, Any]]] = None, + residents: Optional[List[Dict[str, Any]]] = None, + rooms: Optional[List[Dict[str, Any]]] = None, + spaces: Optional[List[Dict[str, Any]]] = None, + tenants: Optional[List[Dict[str, Any]]] = None, + units: Optional[List[Dict[str, Any]]] = None, + user_identities: Optional[List[Dict[str, Any]]] = None, + users: Optional[List[Dict[str, Any]]] = None + ) -> None: + raise NotImplementedError() + + class AbstractDevicesSimulate(abc.ABC): @abc.abstractmethod @@ -3187,6 +3190,7 @@ class AbstractRoutes(abc.ABC): client_sessions: AbstractClientSessions connect_webviews: AbstractConnectWebviews connected_accounts: AbstractConnectedAccounts + customers: AbstractCustomers devices: AbstractDevices events: AbstractEvents locks: AbstractLocks