Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/s2python/websocket/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .pairing_client import AbstractPairingClient

__all__ = ["AbstractPairingClient"]
38 changes: 38 additions & 0 deletions src/s2python/websocket/pairing_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from abc import ABC, abstractmethod
from typing import Any, Dict, List


class AbstractPairingClient(ABC):
"""Abstract class for handling the /requestPairing endpoint."""

def request_pairing(self) -> Any:
"""Orchestrate the pairing request flow: build → execute → handle."""
request_data = self.build_pairing_request()
response_data = self.execute_pairing_request(request_data)
return self.handle_pairing_response(response_data)

@abstractmethod
def build_pairing_request(self) -> Dict:
"""
Build the payload for the PairingRequest schema.
Returns a dictionary with keys: token, publicKey, s2ClientNodeId,
s2ClientNodeDescription, supportedProtocols.
"""
pass

@abstractmethod
def execute_pairing_request(self, request_data: Dict) -> Dict:
"""
Execute the POST request to /requestPairing.
Implementations should send the request_data to the endpoint
and return the JSON response as a dictionary.
"""
pass

@abstractmethod
def handle_pairing_response(self, response_data: Dict) -> Any:
"""
Process the PairingResponse (e.g., extract server details).
The response_data contains keys: s2ServerNodeId, serverNodeDescription, requestConnectionUri.
"""
pass
Loading