Coverage for fingerprint_server_sdk/models/emoji.py: 79%

38 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, Union 

20 

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

22from typing_extensions import Self 

23 

24 

25class Emoji(BaseModel): 

26 """ 

27 Bounding box metrics describing how the emoji glyph renders. 

28 """ 

29 

30 font: Optional[StrictStr] = Field( 

31 default=None, description='Font family reported by the browser when drawing the emoji.' 

32 ) 

33 width: Optional[Union[StrictFloat, StrictInt]] = None 

34 height: Optional[Union[StrictFloat, StrictInt]] = None 

35 top: Optional[Union[StrictFloat, StrictInt]] = None 

36 bottom: Optional[Union[StrictFloat, StrictInt]] = None 

37 left: Optional[Union[StrictFloat, StrictInt]] = None 

38 right: Optional[Union[StrictFloat, StrictInt]] = None 

39 x: Optional[Union[StrictFloat, StrictInt]] = None 

40 y: Optional[Union[StrictFloat, StrictInt]] = None 

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

42 'font', 

43 'width', 

44 'height', 

45 'top', 

46 'bottom', 

47 'left', 

48 'right', 

49 'x', 

50 'y', 

51 ] 

52 

53 model_config = ConfigDict( 

54 populate_by_name=True, 

55 validate_assignment=True, 

56 protected_namespaces=(), 

57 ) 

58 

59 def to_str(self) -> str: 

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

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

62 

63 def to_json(self) -> str: 

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

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

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

67 

68 @classmethod 

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

70 """Create an instance of Emoji from a JSON string""" 

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

72 

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

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

75 

76 This has the following differences from calling pydantic's 

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

78 

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

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

81 are ignored. 

82 """ 

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

84 

85 _dict = self.model_dump( 

86 by_alias=True, 

87 exclude=excluded_fields, 

88 exclude_none=True, 

89 ) 

90 return _dict 

91 

92 @classmethod 

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

94 """Create an instance of Emoji from a dict""" 

95 if obj is None: 

96 return None 

97 

98 if not isinstance(obj, dict): 

99 return cls.model_validate(obj) 

100 

101 _obj = cls.model_validate( 

102 { 

103 'font': obj.get('font'), 

104 'width': obj.get('width'), 

105 'height': obj.get('height'), 

106 'top': obj.get('top'), 

107 'bottom': obj.get('bottom'), 

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

109 'right': obj.get('right'), 

110 'x': obj.get('x'), 

111 'y': obj.get('y'), 

112 } 

113 ) 

114 return _obj