Coverage for fingerprint_server_sdk/models/identification.py: 73%

37 statements  

« prev     ^ index     » next       coverage.py v7.14.3, created at 2026-07-14 10:45 +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. 

5The API also supports collection of Automation Intelligence for requests to your server in edge, pre-origin, or middleware contexts. 

6 

7The version of the OpenAPI document: 4 

8Contact: support@fingerprint.com 

9Generated by OpenAPI Generator (https://openapi-generator.tech) 

10 

11Do not edit the class manually. 

12""" # noqa: E501 

13 

14from __future__ import annotations 

15 

16import json 

17import pprint 

18import re # noqa: F401 

19from typing import Any, ClassVar, Optional 

20 

21from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr 

22from typing_extensions import Self 

23 

24from fingerprint_server_sdk.models.identification_confidence import IdentificationConfidence 

25 

26 

27class Identification(BaseModel): 

28 """ 

29 Identification 

30 """ 

31 

32 visitor_id: StrictStr = Field( 

33 description="String of 20 characters that uniquely identifies the visitor's browser or mobile device." 

34 ) 

35 confidence: Optional[IdentificationConfidence] = None 

36 visitor_found: StrictBool = Field( 

37 description='Attribute represents if a visitor had been identified before.' 

38 ) 

39 first_seen_at: Optional[StrictInt] = Field( 

40 default=None, 

41 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 ', 

42 ) 

43 last_seen_at: Optional[StrictInt] = Field( 

44 default=None, 

45 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 ', 

46 ) 

47 __properties: ClassVar[list[str]] = [ 

48 'visitor_id', 

49 'confidence', 

50 'visitor_found', 

51 'first_seen_at', 

52 'last_seen_at', 

53 ] 

54 

55 model_config = ConfigDict( 

56 populate_by_name=True, 

57 validate_assignment=True, 

58 protected_namespaces=(), 

59 ) 

60 

61 def to_str(self) -> str: 

62 """Returns the string representation of the model using alias""" 

63 return pprint.pformat(self.model_dump(by_alias=True)) 

64 

65 def to_json(self) -> str: 

66 """Returns the JSON representation of the model using alias""" 

67 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 

68 return json.dumps(self.to_dict()) 

69 

70 @classmethod 

71 def from_json(cls, json_str: str) -> Optional[Self]: 

72 """Create an instance of Identification from a JSON string""" 

73 return cls.from_dict(json.loads(json_str)) 

74 

75 def to_dict(self) -> dict[str, Any]: 

76 """Return the dictionary representation of the model using alias. 

77 

78 This has the following differences from calling pydantic's 

79 `self.model_dump(by_alias=True)`: 

80 

81 * `None` is only added to the output dict for nullable fields that 

82 were set at model initialization. Other fields with value `None` 

83 are ignored. 

84 """ 

85 excluded_fields: set[str] = set([]) 

86 

87 _dict = self.model_dump( 

88 by_alias=True, 

89 exclude=excluded_fields, 

90 exclude_none=True, 

91 ) 

92 # override the default output from pydantic by calling `to_dict()` of confidence 

93 if self.confidence: 

94 _dict['confidence'] = self.confidence.to_dict() 

95 return _dict 

96 

97 @classmethod 

98 def from_dict(cls, obj: Optional[dict[str, Any]]) -> Optional[Self]: 

99 """Create an instance of Identification from a dict""" 

100 if obj is None: 

101 return None 

102 

103 if not isinstance(obj, dict): 

104 return cls.model_validate(obj) 

105 

106 _obj = cls.model_validate( 

107 { 

108 'visitor_id': obj.get('visitor_id'), 

109 'confidence': IdentificationConfidence.from_dict(obj['confidence']) 

110 if obj.get('confidence') is not None 

111 else None, 

112 'visitor_found': obj.get('visitor_found'), 

113 'first_seen_at': obj.get('first_seen_at'), 

114 'last_seen_at': obj.get('last_seen_at'), 

115 } 

116 ) 

117 return _obj