Skip to content

Commit

Permalink
fix: Add integration attributes to sdk (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
v-mamaya authored Jun 20, 2023
1 parent 0294dd3 commit 6772fc2
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/Batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
| **deleted_user_attributes** | **list[str]** | | [optional] |
| **user_identities** | [**UserIdentities**](UserIdentities.md) | | [optional] |
| **consentState** | [**ConsentState**](ConsentState.md) | | [optional] |
| **integration_attributes** | **dict(str, dict(str, str))** | | [optional] |
| **mpid** | **int** | | [optional] |
| **mp_deviceid** | **str** | | [optional] |

Expand Down
6 changes: 6 additions & 0 deletions example_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@

batch.consent_state = consent_state

batch.integration_attributes = {
"123": {
"someIntegrationAttribute": "value"
}
}

app_event = mparticle.AppEvent('Example', 'navigation')
app_event.timestamp_unixtime_ms = 1552596256103
app_event.custom_flags = {
Expand Down
26 changes: 25 additions & 1 deletion mparticle/models/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

class Batch(object):

def __init__(self, events=None, source_request_id=None, environment=None, ip=None, schema_version=None, device_info=None, application_info=None, user_attributes=None, deleted_user_attributes=None, user_identities=None, api_key=None, mpid=None, mp_deviceid=None, consent_state=None, context=None):
def __init__(self, events=None, source_request_id=None, environment=None, ip=None, schema_version=None, device_info=None, application_info=None, user_attributes=None, deleted_user_attributes=None, user_identities=None, api_key=None, mpid=None, mp_deviceid=None, consent_state=None, context=None, integration_attributes=None):
"""
Batch - a model defined in Swagger
Expand All @@ -84,6 +84,7 @@ def __init__(self, events=None, source_request_id=None, environment=None, ip=Non
'deleted_user_attributes': 'list[str]',
'user_identities': 'UserIdentities',
'consent_state': 'ConsentState',
'integration_attributes': 'dict(str, dict(str, str))',
'api_key': 'str',
'mpid': 'int',
'mp_deviceid': 'str',
Expand All @@ -102,6 +103,7 @@ def __init__(self, events=None, source_request_id=None, environment=None, ip=Non
'deleted_user_attributes': 'deleted_user_attributes',
'user_identities': 'user_identities',
'consent_state': 'consent_state',
'integration_attributes': 'integration_attributes',
'api_key': 'api_key',
'mpid': 'mpid',
'mp_deviceid': 'mp_deviceid',
Expand All @@ -118,6 +120,7 @@ def __init__(self, events=None, source_request_id=None, environment=None, ip=Non
self._application_info = application_info
self._user_attributes = user_attributes
self._consent_state = consent_state
self._integration_attributes = integration_attributes
self._deleted_user_attributes = deleted_user_attributes
self._user_identities = user_identities
self._mpid = mpid
Expand Down Expand Up @@ -486,6 +489,27 @@ def consent_state(self, consent_state):

self._consent_state = consent_state

@property
def integration_attributes(self):
"""Gets the integration_attributes of this Batch.
:return: The integration_attributes of this Batch.
:rtype: dict(str, dict(str, str))
"""
return self._integration_attributes

@integration_attributes.setter
def integration_attributes(self, integration_attributes):
"""Sets the integration_attributes of this Batch.
:param integration_attributes: The integration_attributes of this Batch.
:type: dict(str, dict(str, str))
"""

self._integration_attributes = integration_attributes

@property
def context(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup, find_packages

NAME = "mparticle"
VERSION = "0.16.0"
VERSION = "0.16.1"


# To install the library, run the following
Expand Down
14 changes: 14 additions & 0 deletions test/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,19 @@ def testBatchWithContext(self):
self.assertEqual("foo", batch_dict["context"]["data_plan"]["plan_id"])
self.assertEqual(5, batch_dict["context"]["data_plan"]["plan_version"])

def testBatchIntegrationAttributes(self):
"""
Test Batch Integration Attributes
"""
model = mparticle.models.batch.Batch()

batch_dict = model.to_dict()
for key in batch_dict:
self.assertEqual(None, batch_dict[key])

model.integration_attributes = { "123": { "someIntegrationAttribute": "value" } }
batch_dict = model.to_dict()
self.assertEqual({ "123": { "someIntegrationAttribute":"value" } }, batch_dict["integration_attributes"])

if __name__ == '__main__':
unittest.main()

0 comments on commit 6772fc2

Please sign in to comment.