Skip to content

Commit

Permalink
Merge pull request #72 from fingerprintjs/fix-raw-device-attributes-t…
Browse files Browse the repository at this point in the history
…ype-INTER-855

Deserialize `raw_device_attributes.data` to correct type `RawDeviceAttributesResult`
  • Loading branch information
ilfa authored Aug 21, 2024
2 parents 4f5bca5 + 743db13 commit ce246fe
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions fingerprint_pro_server_api_sdk/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ def __deserialize_model(data, klass):
"""

if not klass.swagger_types and not ApiClientDeserializer.__hasattr(klass, 'get_real_child_model'):
if hasattr(klass, '__parent_class__') and klass.__parent_class__ == 'dict':
return klass(**data)
return data

kwargs = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from fingerprint_pro_server_api_sdk.base_model import BaseModel


class RawDeviceAttributesResult(BaseModel):
class RawDeviceAttributesResult(dict):
"""
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.
Expand All @@ -36,7 +36,5 @@ class RawDeviceAttributesResult(BaseModel):
attribute_map = {
}

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

2 changes: 2 additions & 0 deletions template/api_client.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ class ApiClientDeserializer:
"""

if not klass.swagger_types and not ApiClientDeserializer.__hasattr(klass, 'get_real_child_model'):
if hasattr(klass, '__parent_class__') and klass.__parent_class__ == 'dict':
return klass(**data)
return data

kwargs = {}
Expand Down
10 changes: 8 additions & 2 deletions template/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from datetime import datetime
{{/vars}}


class {{classname}}(BaseModel):
class {{classname}}({{#parent}}{{parent}}{{/parent}}{{^parent}}BaseModel{{/parent}}):
"""{{#description}}
{{{.}}}

Expand Down Expand Up @@ -60,13 +60,19 @@ class {{classname}}(BaseModel):
}
{{/discriminator}}

{{#parent}}
__parent_class__ = '{{parent}}'
{{/parent}}
{{^parent}}
def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501
"""{{classname}} - a model defined in Swagger""" # noqa: E501
"""{{classname}} - a model defined in Swagger""" # noqa: E501{{#parent}}
super().__init__(){{/parent}}
{{#vars}}{{#@first}}
{{/@first}}
self._{{name}} = None
{{/vars}}
self.discriminator = {{#discriminator}}'{{discriminator}}'{{/discriminator}}{{^discriminator}}None{{/discriminator}}
{{/parent}}
{{#vars}}{{#@first}}
{{/@first}}
{{#required}}
Expand Down
6 changes: 4 additions & 2 deletions test/test_fingerprint_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from fingerprint_pro_server_api_sdk import (Configuration, TooManyRequestsResponse, ErrorVisits403,
ErrorCommon403Response, ErrorEvent404Response, ErrorVisitor400Response,
ErrorVisitor404Response, ErrorCommon429Response, EventUpdateRequest,
ErrorUpdateEvent400Response, ErrorUpdateEvent409Response)
ErrorUpdateEvent400Response, ErrorUpdateEvent409Response,
RawDeviceAttributesResult)
from fingerprint_pro_server_api_sdk.api.fingerprint_api import FingerprintApi # noqa: E501
from fingerprint_pro_server_api_sdk.rest import KnownApiException, ApiException
from urllib.parse import urlencode
Expand Down Expand Up @@ -195,7 +196,8 @@ def test_get_event_correct_data(self):
fields=[self.integration_info], headers=self.request_headers,
preload_content=True, timeout=None)

self.api.get_event(mock_file1)
event_response = self.api.get_event(mock_file1)
self.assertIsInstance(event_response.products.raw_device_attributes.data, RawDeviceAttributesResult)

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

0 comments on commit ce246fe

Please sign in to comment.