Skip to content

Commit

Permalink
Add CCPA to ConsentState
Browse files Browse the repository at this point in the history
  • Loading branch information
alexs-mparticle authored Feb 21, 2020
1 parent ba70ade commit d6c2d30
Show file tree
Hide file tree
Showing 10 changed files with 367 additions and 7 deletions.
11 changes: 11 additions & 0 deletions docs/CCPAConsentState.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# mParticle.CCPAConsentState

## Properties

| Name | Type | Description | Notes |
| ------------------------- | ----------- | ----------- | ----- |
| **document** | **String** | | |
| **consented** | **Boolean** | | |
| **timestamp_unixtime_ms** | **Number** | | |
| **location** | **String** | | |
| **hardware_id** | **String** | | |
7 changes: 4 additions & 3 deletions docs/ConsentState.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Properties

| Name | Type | Description | Notes |
| ---- | ---- | ----------- | ----- |

| Name | Type | Description | Notes |
| --------- | ------------------ | ----------- | ----- |
| **gdpr ** | **dict(str, str)** | | |
| **ccpa ** | **dict(str, str)** | | |
13 changes: 10 additions & 3 deletions example_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
# arbitrary example allowing you to create a segment of users trial users
batch.user_attributes = {'Account type': 'trial', 'TrialEndDate': '2016-12-01'}

ccpa_consent_state = mparticle.CCPAConsentState()
ccpa_consent_state.document = 'document_agreement.v3'
ccpa_consent_state.consented = True
ccpa_consent_state.timestamp_unixtime_ms = calendar.timegm(time.gmtime())
ccpa_consent_state.location = 'mparticle.test/signup'
ccpa_consent_state.hardware_id = 'IDFA:a5d96n32-224a-3b11-1088-a202695bc710'

gdpr_consent_state = mparticle.GDPRConsentState()
gdpr_consent_state.document = 'document_agreement.v2'
gdpr_consent_state.consented = True
Expand All @@ -27,9 +34,9 @@
gdpr_consent_state.hardware_id = 'IDFA:a5d934n0-232f-4afc-2e9a-3832d95zc702'

consent_state = mparticle.ConsentState()
# Make sure this purpose matches your consent purpose in
# Setup > GDPR Settings
# https://docs.mparticle.com/guides/consent-management/#enabling-gdpr-consent-management
# Workspace Settings > Workspace > Regulations
# https://docs.mparticle.com/guides/consent-management/
consent_state.ccpa = {'data_sale_opt_out': ccpa_consent_state}
consent_state.gdpr = {'document_agreement': gdpr_consent_state}

batch.consent_state = consent_state
Expand Down
1 change: 1 addition & 0 deletions mparticle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .models.attribution_info import AttributionInfo
from .models.batch import Batch
from .models.breadcrumb_event import BreadcrumbEvent
from .models.ccpa_consent_state import CCPAConsentState
from .models.commerce_event import CommerceEvent
from .models.consent_state import ConsentState
from .models.crash_report_event import CrashReportEvent
Expand Down
1 change: 1 addition & 0 deletions mparticle/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from .attribution_info import AttributionInfo
from .batch import Batch
from .breadcrumb_event import BreadcrumbEvent
from .ccpa_consent_state import CCPAConsentState
from .commerce_event import CommerceEvent
from .consent_state import ConsentState
from .crash_report_event import CrashReportEvent
Expand Down
220 changes: 220 additions & 0 deletions mparticle/models/ccpa_consent_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
# coding: utf-8

"""
mParticle
mParticle Event API
OpenAPI spec version: 1.0.1
Contact: support@mparticle.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from pprint import pformat
from six import iteritems
import re


class CCPAConsentState(object):
def __init__(self, document=None, consented=None, timestamp_unixtime_ms=None, location=None, hardware_id=None):
"""
CCPAConsentState - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
:param dict attributeMap: The key is attribute name
and the value is json key in definition.
"""
self.swagger_types = {
'document': 'str',
'consented': 'bool',
'timestamp_unixtime_ms': 'int',
'location': 'str',
'hardware_id': 'str'
}

self.attribute_map = {
'document': 'document',
'consented': 'consented',
'timestamp_unixtime_ms': 'timestamp_unixtime_ms',
'location': 'location',
'hardware_id': 'hardware_id'
}

self.document = document
self.consented = consented
self.timestamp_unixtime_ms = timestamp_unixtime_ms
self.location = location
self.hardware_id = hardware_id

@property
def document(self):
"""
Gets the document of this CCPAConsentState
:return The document of this CCPAConsentState
:rtype str
"""
return self._document

@document.setter
def document(self, document):
"""
Sets the document of this CCPA Consent State.
:param document: The document of this CCPA Consent State.
:type: str
"""

self._document = document

@property
def consented(self):
"""
Gets the consented of this CCPAConsentState
:return The consented of this CCPAConsentState
:rtype str
"""
return self._consented

@consented.setter
def consented(self, consented):
"""
Sets the consented of this CCPA Consent State.
:param consented: The consented of this CCPA Consent State.
:type: str
"""

self._consented = consented

@property
def timestamp_unixtime_ms(self):
"""
Gets the timestamp_unixtime_ms of this CCPAConsentState
:return The timestamp_unixtime_ms of this CCPAConsentState
:rtype str
"""
return self._timestamp_unixtime_ms

@timestamp_unixtime_ms.setter
def timestamp_unixtime_ms(self, timestamp_unixtime_ms):
"""
Sets the timestamp_unixtime_ms of this CCPA Consent State.
:param timestamp_unixtime_ms: The timestamp_unixtime_ms of this CCPA Consent State.
:type: str
"""

self._timestamp_unixtime_ms = timestamp_unixtime_ms

@property
def location(self):
"""
Gets the location of this CCPAConsentState
:return The location of this CCPAConsentState
:rtype str
"""
return self._location

@location.setter
def location(self, location):
"""
Sets the location of this CCPA Consent State.
:param location: The location of this CCPA Consent State.
:type: str
"""

self._location = location

@property
def hardware_id(self):
"""
Gets the hardware_id of this CCPAConsentState
:return The hardware_id of this CCPAConsentState
:rtype str
"""
return self._hardware_id

@hardware_id.setter
def hardware_id(self, hardware_id):
"""
Sets the hardware_id of this CCPA Consent State.
:param hardware_id: The hardware_id of this CCPA Consent State.
:type: str
"""

self._hardware_id = hardware_id

def to_dict(self):
"""
Returns the model properties as a dict
"""
result = {}

for attr, _ in iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
elif isinstance(value, dict):
result[attr] = dict(map(
lambda item: (item[0], item[1].to_dict())
if hasattr(item[1], "to_dict") else item,
value.items()
))
else:
result[attr] = value

return result

def to_str(self):
"""
Returns the string representation of the model
"""
return pformat(self.to_dict())

def __repr__(self):
"""
For `print` and `pprint`
"""
return self.to_str()

def __eq__(self, other):
"""
Returns true if both objects are equal
"""
return self.__dict__ == other.__dict__

def __ne__(self, other):
"""
Returns true if both objects are not equal
"""
return not self == other
25 changes: 25 additions & 0 deletions mparticle/models/consent_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,40 @@ def __init__(self):
and the value is json key in definition.
"""
self.swagger_types = {
'ccpa': 'dict',
'gdpr': 'dict'
}

self.attribute_map = {
'ccpa': 'ccpa',
'gdpr': 'gdpr'
}

self.ccpa = dict()
self.gdpr = dict()

@property
def ccpa(self):
"""
Gets the ccpa of this CCPAConsentState
:return The ccpa of this CCPAConsentState
:rtype dict
"""
return self._ccpa

@ccpa.setter
def ccpa(self, ccpa):
"""
Sets the ccpa of this Consent State.
:param ccpa: The ccpa of this Consent State.
:type: dict
"""

self._ccpa = ccpa

@property
def gdpr(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.10.9"
VERSION = "0.10.10"


# To install the library, run the following
Expand Down
Loading

0 comments on commit d6c2d30

Please sign in to comment.