11package personification
22
3- import (
4- "github.com/geniusrabbit/udetect"
5- )
6-
73type (
8- // UserInfo value
9- UserInfo struct {
10- User * udetect.User
11- Device * udetect.Device
12- Geo * udetect.Geo
13- }
14-
154 // PredictRequest ...
165 PredictRequest struct {}
176
@@ -25,89 +14,25 @@ type (
2514 PredictPriceResponse struct {}
2615)
2716
28- // UUID of the user
29- func (i * UserInfo ) UUID () string {
30- if i == nil || i .User == nil || isEmptyUUIDPtr (& i .User .UUID ) {
31- return ""
32- }
33- return i .User .UUID .String ()
34- }
35-
36- // SessionID of the user
37- func (i * UserInfo ) SessionID () string {
38- if i == nil || i .User == nil {
39- return ""
40- }
41- return i .User .SessionID
42- }
43-
44- // Fingerprint of the iser
45- func (i * UserInfo ) Fingerprint () string {
46- if i == nil || i .User == nil {
47- return ""
48- }
49- return i .User .FingerPrintID
50- }
51-
52- // Country info
53- func (i * UserInfo ) Country () * udetect.Geo {
54- if i == nil || i .Geo == nil {
55- return & udetect .GeoDefault
56- }
57- return i .Geo
58- }
59-
60- // Ages of the user
61- func (i * UserInfo ) Ages () (from , to int ) {
62- if i == nil || i .User == nil {
63- return 0 , 0
64- }
65- return i .User .AgeStart , i .User .AgeEnd
66- }
67-
68- // ETag of the user
69- func (i * UserInfo ) ETag () string {
70- if i == nil || i .User == nil {
71- return ""
72- }
73- return i .User .ETag
74- }
17+ // Properties accessor
18+ type Properties interface {
19+ // Get property by key
20+ Get (key string ) any
7521
76- // Keywords of the user
77- func (i * UserInfo ) Keywords () string {
78- if i == nil || i .User == nil {
79- return ""
80- }
81- return i .User .Keywords
82- }
22+ // GetString property by key
23+ GetString (key string ) string
8324
84- // MostPossibleSex of the user
85- func (i * UserInfo ) MostPossibleSex () int {
86- if i == nil || i .User == nil {
87- return 0
88- }
89- return i .User .MostPossibleSex ()
90- }
25+ // GetIntSlice property by key
26+ GetIntSlice (key string ) []int
9127
92- // DeviceInfo get method
93- func (i * UserInfo ) DeviceInfo () * udetect.Device {
94- if i == nil || i .Device == nil {
95- return & udetect .DeviceDefault
96- }
97- return i .Device
98- }
28+ // Set property
29+ Set (key string , prop any )
9930
100- // GeoInfo get method
101- func (i * UserInfo ) GeoInfo () * udetect.Geo {
102- if i == nil || i .Geo == nil {
103- return & udetect .GeoDefault
104- }
105- return i .Geo
106- }
31+ // Delete property by key
32+ Delete (key string )
10733
108- // GeoInfo get method
109- func (i * UserInfo ) CarrierInfo () * udetect.Carrier {
110- return i .GeoInfo ().Carrier
34+ // Synchronise properties
35+ Synchronise () error
11136}
11237
11338// Person information block
@@ -127,24 +52,3 @@ type Person interface {
12752 // PredictPrice what minimal
12853 PredictPrice (req * PredictPriceRequest ) (* PredictPriceResponse , error )
12954}
130-
131- // Properties accessor
132- type Properties interface {
133- // Get property by key
134- Get (key string ) any
135-
136- // GetString property by key
137- GetString (key string ) string
138-
139- // GetIntSlice property by key
140- GetIntSlice (key string ) []int
141-
142- // Set property
143- Set (key string , prop any )
144-
145- // Delete property by key
146- Delete (key string )
147-
148- // Synchronise properties
149- Synchronise () error
150- }
0 commit comments