class LocateV1Schema(BaseLocateSchema): carrier = colander.SchemaNode(colander.String(), missing=None) considerIp = colander.SchemaNode(colander.Boolean(), missing=True) homeMobileCountryCode = colander.SchemaNode(colander.Integer(), missing=None) homeMobileNetworkCode = colander.SchemaNode(colander.Integer(), missing=None) radioType = colander.SchemaNode( colander.String(), validator=colander.OneOf(RADIO_STRINGS), missing=colander.drop, ) bluetoothBeacons = BluetoothBeaconsSchema(missing=()) cellTowers = CellTowersSchema(missing=()) wifiAccessPoints = WifiAccessPointsSchema(missing=()) fallbacks = FallbackSchema(missing=None) def __init__(self, *args, **kw): super(LocateV1Schema, self).__init__(*args, **kw) self.fallback_defaults = self.get("fallbacks").deserialize({}) def deserialize(self, data): data = super(LocateV1Schema, self).deserialize(data) if data["fallbacks"] is None: data["fallbacks"] = dict(self.fallback_defaults) data["fallbacks"]["ipf"] = data["considerIp"] return data
class LocateV2Schema(BaseLocateSchema): carrier = InternalSchemaNode(colander.String(), missing=None) considerIp = InternalSchemaNode(colander.Boolean(), missing=True) homeMobileCountryCode = InternalSchemaNode(colander.Integer(), missing=None) homeMobileNetworkCode = InternalSchemaNode(colander.Integer(), missing=None) radioType = InternalSchemaNode(colander.String(), validator=colander.OneOf(RADIO_STRINGS), missing=colander.drop, internal_name='radio') cellTowers = CellTowersSchema(missing=(), internal_name='cell') wifiAccessPoints = WifiAccessPointsSchema(missing=(), internal_name='wifi') fallbacks = FallbackSchema(missing=None) def __init__(self, *args, **kw): super(LocateV2Schema, self).__init__(*args, **kw) self.fallback_defaults = self.get('fallbacks').deserialize({}) def deserialize(self, data): data = super(LocateV2Schema, self).deserialize(data) if data['fallbacks'] is None: data['fallbacks'] = dict(self.fallback_defaults) data['fallbacks']['ipf'] = data['considerIp'] return data
class LocateV1Schema(BaseLocateSchema): radio = InternalSchemaNode( colander.String(), validator=colander.OneOf(RADIO_STRINGS), missing=None) cell = CellsSchema(missing=()) wifi = WifisSchema(missing=()) fallbacks = FallbackSchema(missing=None)
class LocateV0Schema(BaseLocateSchema): radio = colander.SchemaNode(colander.String(), validator=colander.OneOf(RADIO_STRINGS), missing=None, to_name='radioType') blue = BluesSchema(missing=(), to_name='bluetoothBeacons') cell = CellsSchema(missing=(), to_name='cellTowers') wifi = WifisSchema(missing=(), to_name='wifiAccessPoints') fallbacks = FallbackSchema(missing=None)