Coverage for fingerprint_server_sdk / models / velocity.py: 57%
51 statements
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-11 18:41 +0000
« prev ^ index » next coverage.py v7.13.4, created at 2026-03-11 18:41 +0000
1"""
2Server API
3Fingerprint Server API allows you to get, search, and update Events in a server environment. It can be used for data exports, decision-making, and data analysis scenarios.
4Server API is intended for server-side usage, it's not intended to be used from the client side, whether it's a browser or a mobile device.
6The version of the OpenAPI document: 4
7Contact: support@fingerprint.com
8Generated by OpenAPI Generator (https://openapi-generator.tech)
10Do not edit the class manually.
11""" # noqa: E501
13from __future__ import annotations
15import json
16import pprint
17import re # noqa: F401
18from typing import Any, ClassVar, Optional
20from pydantic import BaseModel, ConfigDict
21from typing_extensions import Self
23from fingerprint_server_sdk.models.velocity_data import VelocityData
26class Velocity(BaseModel):
27 """
28 Sums key data points for a specific `visitor_id`, `ip_address` and `linked_id` at three distinct time intervals: 5 minutes, 1 hour, and 24 hours as follows: - Number of distinct IP addresses associated to the visitor Id. - Number of distinct linked Ids associated with the visitor Id. - Number of distinct countries associated with the visitor Id. - Number of identification events associated with the visitor Id. - Number of identification events associated with the detected IP address. - Number of distinct IP addresses associated with the provided linked Id. - Number of distinct visitor Ids associated with the provided linked Id. The `24h` interval of `distinct_ip`, `distinct_linked_id`, `distinct_country`, `distinct_ip_by_linked_id` and `distinct_visitor_id_by_linked_id` will be omitted if the number of `events` for the visitor Id in the last 24 hours (`events.['24h']`) is higher than 20.000. All will not necessarily be returned in a response, some may be omitted if the associated event does not have the required data, such as a linked_id.
29 """
31 distinct_ip: Optional[VelocityData] = None
32 distinct_linked_id: Optional[VelocityData] = None
33 distinct_country: Optional[VelocityData] = None
34 events: Optional[VelocityData] = None
35 ip_events: Optional[VelocityData] = None
36 distinct_ip_by_linked_id: Optional[VelocityData] = None
37 distinct_visitor_id_by_linked_id: Optional[VelocityData] = None
38 __properties: ClassVar[list[str]] = [
39 'distinct_ip',
40 'distinct_linked_id',
41 'distinct_country',
42 'events',
43 'ip_events',
44 'distinct_ip_by_linked_id',
45 'distinct_visitor_id_by_linked_id',
46 ]
48 model_config = ConfigDict(
49 populate_by_name=True,
50 validate_assignment=True,
51 protected_namespaces=(),
52 )
54 def to_str(self) -> str:
55 """Returns the string representation of the model using alias"""
56 return pprint.pformat(self.model_dump(by_alias=True))
58 def to_json(self) -> str:
59 """Returns the JSON representation of the model using alias"""
60 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
61 return json.dumps(self.to_dict())
63 @classmethod
64 def from_json(cls, json_str: str) -> Optional[Self]:
65 """Create an instance of Velocity from a JSON string"""
66 return cls.from_dict(json.loads(json_str))
68 def to_dict(self) -> dict[str, Any]:
69 """Return the dictionary representation of the model using alias.
71 This has the following differences from calling pydantic's
72 `self.model_dump(by_alias=True)`:
74 * `None` is only added to the output dict for nullable fields that
75 were set at model initialization. Other fields with value `None`
76 are ignored.
77 """
78 excluded_fields: set[str] = set([])
80 _dict = self.model_dump(
81 by_alias=True,
82 exclude=excluded_fields,
83 exclude_none=True,
84 )
85 # override the default output from pydantic by calling `to_dict()` of distinct_ip
86 if self.distinct_ip:
87 _dict['distinct_ip'] = self.distinct_ip.to_dict()
88 # override the default output from pydantic by calling `to_dict()` of distinct_linked_id
89 if self.distinct_linked_id:
90 _dict['distinct_linked_id'] = self.distinct_linked_id.to_dict()
91 # override the default output from pydantic by calling `to_dict()` of distinct_country
92 if self.distinct_country:
93 _dict['distinct_country'] = self.distinct_country.to_dict()
94 # override the default output from pydantic by calling `to_dict()` of events
95 if self.events:
96 _dict['events'] = self.events.to_dict()
97 # override the default output from pydantic by calling `to_dict()` of ip_events
98 if self.ip_events:
99 _dict['ip_events'] = self.ip_events.to_dict()
100 # override the default output from pydantic by calling `to_dict()` of distinct_ip_by_linked_id
101 if self.distinct_ip_by_linked_id:
102 _dict['distinct_ip_by_linked_id'] = self.distinct_ip_by_linked_id.to_dict()
103 # override the default output from pydantic by calling `to_dict()` of distinct_visitor_id_by_linked_id
104 if self.distinct_visitor_id_by_linked_id:
105 _dict['distinct_visitor_id_by_linked_id'] = (
106 self.distinct_visitor_id_by_linked_id.to_dict()
107 )
108 return _dict
110 @classmethod
111 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
112 """Create an instance of Velocity from a dict"""
113 if obj is None:
114 return None
116 if not isinstance(obj, dict):
117 return cls.model_validate(obj)
119 _obj = cls.model_validate(
120 {
121 'distinct_ip': VelocityData.from_dict(obj['distinct_ip'])
122 if obj.get('distinct_ip') is not None
123 else None,
124 'distinct_linked_id': VelocityData.from_dict(obj['distinct_linked_id'])
125 if obj.get('distinct_linked_id') is not None
126 else None,
127 'distinct_country': VelocityData.from_dict(obj['distinct_country'])
128 if obj.get('distinct_country') is not None
129 else None,
130 'events': VelocityData.from_dict(obj['events'])
131 if obj.get('events') is not None
132 else None,
133 'ip_events': VelocityData.from_dict(obj['ip_events'])
134 if obj.get('ip_events') is not None
135 else None,
136 'distinct_ip_by_linked_id': VelocityData.from_dict(obj['distinct_ip_by_linked_id'])
137 if obj.get('distinct_ip_by_linked_id') is not None
138 else None,
139 'distinct_visitor_id_by_linked_id': VelocityData.from_dict(
140 obj['distinct_visitor_id_by_linked_id']
141 )
142 if obj.get('distinct_visitor_id_by_linked_id') is not None
143 else None,
144 }
145 )
146 return _obj