Add get_pumper() BFF metadata method with typed response

Add TandemSourceApi.get_pumper() for GET api/reports/bff/pumper/{pumperId},
the new device-list endpoint that replaces pumpeventmetadata. Adds
strictly-typed TypedDicts (BffPumper, BffPump, AvailableDataRange,
PumpSettingsEnvelope) derived from the captured account response; verified
they exactly cover the real JSON keys. pumps[].assignmentId is the UUID
device id for the pump-logs endpoint; settings.details (typed as dict for
now) will be modeled by PumpSettings in a later step. Nullable/absent
fields use total=False + Optional.
This commit is contained in:
James Woglom
2026-07-01 01:02:23 +00:00
parent f124b884b2
commit 8761e70b18
+63
View File
@@ -92,6 +92,61 @@ class JwtClaims(TypedDict, total=False):
email_verified: bool
class AvailableDataRange(TypedDict):
"""`availableDataRange` on a BffPump. start/end are ISO-8601 datetime
strings, or null for a pump that has never uploaded."""
start: Optional[str]
end: Optional[str]
class PumpSettingsEnvelope(TypedDict):
"""`settings` on a BffPump. `details` is the full pump settings blob,
parsed by tconnectsync.domain.tandemsource.pump_settings.PumpSettings."""
id: str
deviceAssignmentId: str
uploadedTimeStamp: str
settingsHash: str
uploadId: str
details: dict
class BffPump(TypedDict, total=False):
"""One element of BffPumper.pumps, from GET api/reports/bff/pumper/{pumperId}.
`assignmentId` is the pump's UUID device id used as the path segment for
the pump-logs endpoint (replaces the old numeric tconnectDeviceId).
Several fields (settings, *Date*, lastUploadClientType, glucoseUnit,
availableDataRange.start/end) are null or absent for never-uploaded or
retired pumps, hence total=False.
"""
algorithm: str
availableDataRange: AvailableDataRange
assignmentId: str
glucoseUnit: Optional[str]
lastUploadDate: Optional[str]
maxDateOfEvents: Optional[str]
modelNumber: str
modelName: str
partNumber: str
serialNumber: str
softwareVersion: str
lastUploadClientType: Optional[str]
settings: Optional[PumpSettingsEnvelope]
class BffPumper(TypedDict, total=False):
"""Response of GET api/reports/bff/pumper/{pumperId} (the BFF device list
that replaces pumpeventmetadata)."""
firstName: str
lastName: str
name: str
dateOfBirth: str
lowGlucoseThreshold: int
highGlucoseThreshold: int
country: str
pumps: List[BffPump]
class TandemSourceApi:
# Common URLs that are shared between regions
LOGIN_PAGE_URL = 'https://sso.tandemdiabetes.com/'
@@ -505,6 +560,14 @@ class TandemSourceApi:
def pump_event_metadata(self) -> List[PumpEventMetadata]:
return self.get('api/reports/reportsfacade/%s/pumpeventmetadata' % (self.pumperId), {})
def get_pumper(self) -> BffPumper:
"""Returns the pumper's profile plus the list of pumps on the account
(BffPumper.pumps) from the new BFF endpoint. Replaces
pump_event_metadata(): pumps[].assignmentId is the UUID device id used
by the pump-logs endpoint, and pumps[].settings.details carries the
pump settings blob."""
return self.get('api/reports/bff/pumper/%s' % (self.pumperId), {})
# Matches the Tandem Source web app's getLogIDList() (55 IDs) as observed in
# the live GET api/reports/bff/pump-logs request. Includes FSL3 ids 477/480/486.
DEFAULT_EVENT_IDS: List[int] = [229,5,28,4,26,99,279,3,16,59,21,55,20,280,64,65,66,61,33,371,171,369,460,172,370,461,372,480,399,256,213,406,477,394,212,404,214,405,486,447,313,60,14,6,90,230,140,12,11,53,13,63,203,307,191]