Coverage for fingerprint_server_sdk / models / identification.py: 73%
37 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, Field, StrictBool, StrictInt, StrictStr
21from typing_extensions import Self
23from fingerprint_server_sdk.models.identification_confidence import IdentificationConfidence
26class Identification(BaseModel):
27 """
28 Identification
29 """
31 visitor_id: StrictStr = Field(
32 description="String of 20 characters that uniquely identifies the visitor's browser or mobile device."
33 )
34 confidence: Optional[IdentificationConfidence] = None
35 visitor_found: StrictBool = Field(
36 description='Attribute represents if a visitor had been identified before.'
37 )
38 first_seen_at: Optional[StrictInt] = Field(
39 default=None,
40 description='Unix epoch time milliseconds timestamp indicating the time at which this visitor ID was first seen. example: `1758069706642` - Corresponding to Wed Sep 17 2025 00:41:46 GMT+0000 ',
41 )
42 last_seen_at: Optional[StrictInt] = Field(
43 default=None,
44 description='Unix epoch time milliseconds timestamp indicating the time at which this visitor ID was last seen. example: `1758069706642` - Corresponding to Wed Sep 17 2025 00:41:46 GMT+0000 ',
45 )
46 __properties: ClassVar[list[str]] = [
47 'visitor_id',
48 'confidence',
49 'visitor_found',
50 'first_seen_at',
51 'last_seen_at',
52 ]
54 model_config = ConfigDict(
55 populate_by_name=True,
56 validate_assignment=True,
57 protected_namespaces=(),
58 )
60 def to_str(self) -> str:
61 """Returns the string representation of the model using alias"""
62 return pprint.pformat(self.model_dump(by_alias=True))
64 def to_json(self) -> str:
65 """Returns the JSON representation of the model using alias"""
66 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
67 return json.dumps(self.to_dict())
69 @classmethod
70 def from_json(cls, json_str: str) -> Optional[Self]:
71 """Create an instance of Identification from a JSON string"""
72 return cls.from_dict(json.loads(json_str))
74 def to_dict(self) -> dict[str, Any]:
75 """Return the dictionary representation of the model using alias.
77 This has the following differences from calling pydantic's
78 `self.model_dump(by_alias=True)`:
80 * `None` is only added to the output dict for nullable fields that
81 were set at model initialization. Other fields with value `None`
82 are ignored.
83 """
84 excluded_fields: set[str] = set([])
86 _dict = self.model_dump(
87 by_alias=True,
88 exclude=excluded_fields,
89 exclude_none=True,
90 )
91 # override the default output from pydantic by calling `to_dict()` of confidence
92 if self.confidence:
93 _dict['confidence'] = self.confidence.to_dict()
94 return _dict
96 @classmethod
97 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]:
98 """Create an instance of Identification from a dict"""
99 if obj is None:
100 return None
102 if not isinstance(obj, dict):
103 return cls.model_validate(obj)
105 _obj = cls.model_validate(
106 {
107 'visitor_id': obj.get('visitor_id'),
108 'confidence': IdentificationConfidence.from_dict(obj['confidence'])
109 if obj.get('confidence') is not None
110 else None,
111 'visitor_found': obj.get('visitor_found'),
112 'first_seen_at': obj.get('first_seen_at'),
113 'last_seen_at': obj.get('last_seen_at'),
114 }
115 )
116 return _obj