Skip to content

Commit 5b7a6f9

Browse files
authored
Merge pull request #71 from fingerprintjs/fix-raw-device-attributes-type-INTER-855
Deserialize `raw_device_attributes.data` to correct type `RawDeviceAttributesResult`
2 parents 4f5bca5 + 743db13 commit 5b7a6f9

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

fingerprint_pro_server_api_sdk/api_client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ def __deserialize_model(data, klass):
588588
"""
589589

590590
if not klass.swagger_types and not ApiClientDeserializer.__hasattr(klass, 'get_real_child_model'):
591+
if hasattr(klass, '__parent_class__') and klass.__parent_class__ == 'dict':
592+
return klass(**data)
591593
return data
592594

593595
kwargs = {}

fingerprint_pro_server_api_sdk/models/raw_device_attributes_result.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from fingerprint_pro_server_api_sdk.base_model import BaseModel
1616

1717

18-
class RawDeviceAttributesResult(BaseModel):
18+
class RawDeviceAttributesResult(dict):
1919
"""
2020
It includes 35+ raw browser identification attributes to provide Fingerprint users with even more information than our standard visitor ID provides. This enables Fingerprint users to not have to run our open-source product in conjunction with Fingerprint Pro Plus and Enterprise to get those additional attributes. Warning: The raw signals data can change at any moment as we improve the product. We cannot guarantee the internal shape of raw device attributes to be stable, so typical semantic versioning rules do not apply here. Use this data with caution without assuming a specific structure beyond the generic type provided here.
2121
@@ -36,7 +36,5 @@ class RawDeviceAttributesResult(BaseModel):
3636
attribute_map = {
3737
}
3838

39-
def __init__(self): # noqa: E501
40-
"""RawDeviceAttributesResult - a model defined in Swagger""" # noqa: E501
41-
self.discriminator = None
39+
__parent_class__ = 'dict'
4240

template/api_client.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,8 @@ class ApiClientDeserializer:
580580
"""
581581

582582
if not klass.swagger_types and not ApiClientDeserializer.__hasattr(klass, 'get_real_child_model'):
583+
if hasattr(klass, '__parent_class__') and klass.__parent_class__ == 'dict':
584+
return klass(**data)
583585
return data
584586

585587
kwargs = {}

template/model.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ from datetime import datetime
1717
{{/vars}}
1818

1919

20-
class {{classname}}(BaseModel):
20+
class {{classname}}({{#parent}}{{parent}}{{/parent}}{{^parent}}BaseModel{{/parent}}):
2121
"""{{#description}}
2222
{{{.}}}
2323

@@ -60,13 +60,19 @@ class {{classname}}(BaseModel):
6060
}
6161
{{/discriminator}}
6262

63+
{{#parent}}
64+
__parent_class__ = '{{parent}}'
65+
{{/parent}}
66+
{{^parent}}
6367
def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
64-
"""{{classname}} - a model defined in Swagger""" # noqa: E501
68+
"""{{classname}} - a model defined in Swagger""" # noqa: E501{{#parent}}
69+
super().__init__(){{/parent}}
6570
{{#vars}}{{#@first}}
6671
{{/@first}}
6772
self._{{name}} = None
6873
{{/vars}}
6974
self.discriminator = {{#discriminator}}'{{discriminator}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}}
75+
{{/parent}}
7076
{{#vars}}{{#@first}}
7177
{{/@first}}
7278
{{#required}}

test/test_fingerprint_api.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
from fingerprint_pro_server_api_sdk import (Configuration, TooManyRequestsResponse, ErrorVisits403,
1919
ErrorCommon403Response, ErrorEvent404Response, ErrorVisitor400Response,
2020
ErrorVisitor404Response, ErrorCommon429Response, EventUpdateRequest,
21-
ErrorUpdateEvent400Response, ErrorUpdateEvent409Response)
21+
ErrorUpdateEvent400Response, ErrorUpdateEvent409Response,
22+
RawDeviceAttributesResult)
2223
from fingerprint_pro_server_api_sdk.api.fingerprint_api import FingerprintApi # noqa: E501
2324
from fingerprint_pro_server_api_sdk.rest import KnownApiException, ApiException
2425
from urllib.parse import urlencode
@@ -195,7 +196,8 @@ def test_get_event_correct_data(self):
195196
fields=[self.integration_info], headers=self.request_headers,
196197
preload_content=True, timeout=None)
197198

198-
self.api.get_event(mock_file1)
199+
event_response = self.api.get_event(mock_file1)
200+
self.assertIsInstance(event_response.products.raw_device_attributes.data, RawDeviceAttributesResult)
199201

200202
def test_get_event_errors_200(self):
201203
"""Test checks correct code run result in scenario of arrors in BotD or identification API"""

0 commit comments

Comments
 (0)