void OnCustomConsentGDPRCallback(string jsonSPGDPRConsent)
        {
            CmpDebugUtil.Log("OnCustomConsentGDPRCallback IOS_CALLBACK_RECEIVED: " + jsonSPGDPRConsent);
            GdprConsent unwrapped = null;

            try
            {
                unwrapped = JsonUnwrapper.UnwrapGdprConsent(jsonSPGDPRConsent);
            }
            catch (Exception ex)
            {
                Debug.LogError(
                    "Something went wrong while parsing the json data; null will be returned. \n Exception message: " +
                    ex.Message);
            }
            finally
            {
                if (unwrapped == null)
                {
                    onCustomConsentsGDPRSuccessAction?.Invoke(null);
                }
                else
                {
                    customGdprConsent = unwrapped;
                    onCustomConsentsGDPRSuccessAction?.Invoke(unwrapped);
                }
            }
        }
Exemple #2
0
        public static GdprConsent UnwrapGdprConsent(string json)
        {
            GdprConsentWrapper wrapped   = JsonSerializer.Deserialize <GdprConsentWrapper>(json);
            GdprConsent        unwrapped = UnwrapGdprConsent(wrapped);

            return(unwrapped);
        }
Exemple #3
0
        private static GdprConsent UnwrapGdprConsent(GdprConsentWrapper wrapped)
        {
            GdprConsent unwrapped = new GdprConsent
            {
                uuid      = wrapped.uuid,
                euconsent = wrapped.euconsent,
                TCData    = wrapped.TCData,
                grants    = new Dictionary <string, SpVendorGrant>()
            };

            foreach (KeyValuePair <string, SpVendorGrantWrapper> vendorGrantWrapper in wrapped.grants)
            {
                bool isGranted = ((JsonElement)vendorGrantWrapper.Value.vendorGrant).GetBoolean();
                Dictionary <string, bool> purposeGrants = new Dictionary <string, bool>();
                if (vendorGrantWrapper.Value != null)
                {
                    foreach (KeyValuePair <string, object> purpGrant in vendorGrantWrapper.Value.purposeGrants)
                    {
                        purposeGrants.Add(purpGrant.Key, ((JsonElement)purpGrant.Value).GetBoolean());
                    }
                }
                unwrapped.grants[vendorGrantWrapper.Key] = new SpVendorGrant(/*isGranted,*/ purposeGrants);
            }
            return(unwrapped);
        }
Exemple #4
0
        public async Task CanUpdateEntities(DataProviderType type)
        {
            if (!SetDataProviderType(type))
            {
                return;
            }

            var dataProvider = GetService <INopDataProvider>();

            var gdprConsent = new GdprConsent {
                DisplayOrder = 10, Message = "Test message 1"
            };
            await dataProvider.TruncateAsync <GdprConsent>();

            dataProvider.GetTable <GdprConsent>().Count().Should().Be(0);
            dataProvider.InsertEntity(gdprConsent);
            await dataProvider.UpdateEntitiesAsync(new []
            {
                new GdprConsent
                {
                    Id      = gdprConsent.Id,
                    Message = "Updated test tax category"
                }
            });

            var updatedGdprConsent = dataProvider.GetTable <GdprConsent>().FirstOrDefault(tc => tc.Id == gdprConsent.Id);
            await dataProvider.TruncateAsync <GdprConsent>();

            gdprConsent.Id.Should().BeGreaterThan(0);
            updatedGdprConsent?.Message.Should().NotBeEquivalentTo(gdprConsent.Message);
        }
Exemple #5
0
        public async Task CanBulkDeleteEntities(DataProviderType type)
        {
            if (!SetDataProviderType(type))
            {
                return;
            }

            var dataProvider = GetService <INopDataProvider>();

            var gdprConsent = new GdprConsent {
                DisplayOrder = 10, Message = "Test message 1"
            };
            await dataProvider.TruncateAsync <GdprConsent>();

            dataProvider.GetTable <GdprConsent>().Count().Should().Be(0);
            dataProvider.InsertEntity(gdprConsent);
            dataProvider.GetTable <GdprConsent>().Count().Should().Be(1);
            await dataProvider.BulkDeleteEntitiesAsync(new List <GdprConsent> {
                gdprConsent
            });

            dataProvider.GetTable <GdprConsent>().Count().Should().Be(0);
            dataProvider.InsertEntity(gdprConsent);
            dataProvider.GetTable <GdprConsent>().Count().Should().Be(1);
            await dataProvider.BulkDeleteEntitiesAsync <GdprConsent>(_ => true);

            dataProvider.GetTable <GdprConsent>().Count().Should().Be(0);
        }
Exemple #6
0
        private static SpGdprConsent UnwrapSpGdprConsent(SpGdprConsentWrapper wrappedGdpr)
        {
            // bool applies = ((JsonElement) wrappedGdpr.applies).GetBoolean();
            GdprConsent consent = UnwrapGdprConsent(wrappedGdpr.consents);

            return(new SpGdprConsent(consent));
        }
Exemple #7
0
        void transferCustomConsentToUnity(string spConsentsJson)
        {
            CmpDebugUtil.Log("transferCustomConsentToUnitySide c#-side custom consent ->" + spConsentsJson.ToString());
            SpCustomConsentAndroid parsed = null;

            try
            {
                parsed = JsonUnwrapper.UnwrapSpCustomConsentAndroid(spConsentsJson);
            }
            catch (Exception ex)
            {
                Debug.LogError("Something went wrong while parsing the json data; null will be returned. \n Exception message: " + ex.Message);
            }
            finally
            {
                if (parsed == null)
                {
                    callback?.Invoke(null);
                }
                else
                {
                    var spGdpr = JsonUnwrapper.UnwrapSpGdprConsentAndroid(parsed.gdpr);
                    customGdprConsent = spGdpr.consents;
                    callback?.Invoke(customGdprConsent);
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Delete a GDPR consent
        /// </summary>
        /// <param name="gdprConsent">GDPR consent</param>
        public virtual void DeleteConsent(GdprConsent gdprConsent)
        {
            if (gdprConsent == null)
            {
                throw new ArgumentNullException(nameof(gdprConsent));
            }

            _gdprConsentRepository.Delete(gdprConsent);

            //event notification
            _eventPublisher.EntityDeleted(gdprConsent);
        }
Exemple #9
0
        public async Task TestCrud()
        {
            var insertItem = new GdprConsent
            {
                Message = "Test message"
            };

            var updateItem = new GdprConsent
            {
                Message = "Update test message"
            };

            await TestCrud(insertItem, _gdprService.InsertConsentAsync, updateItem, _gdprService.UpdateConsentAsync, _gdprService.GetConsentByIdAsync, (item, other) => item.Message.Equals(other.Message), _gdprService.DeleteConsentAsync);
        }
Exemple #10
0
        protected virtual GdprConsentModel PrepareGdprConsentModel(GdprConsent consent, bool accepted)
        {
            if (consent == null)
            {
                throw  new ArgumentNullException(nameof(consent));
            }

            return(new GdprConsentModel
            {
                Id = consent.Id,
                Message = consent.Message,
                IsRequired = consent.IsRequired,
                RequiredMessage = !String.IsNullOrEmpty(consent.RequiredMessage) ? consent.RequiredMessage : $"'{consent.Message}' is required",
                Accepted = accepted
            });
        }
Exemple #11
0
        public async Task CanGetTableIdentAsync(DataProviderType type)
        {
            if (!SetDataProviderType(type))
            {
                return;
            }

            var dataProvider = GetService <INopDataProvider>();

            var gdprConsent = new GdprConsent {
                DisplayOrder = 10, Message = "Test message 1"
            };
            await dataProvider.TruncateAsync <GdprConsent>(true);

            dataProvider.GetTable <GdprConsent>().Count().Should().Be(0);
            var nextId = await dataProvider.GetTableIdentAsync <GdprConsent>();

            nextId.Should().Be(type == DataProviderType.Unknown ? 0 : 1);

            dataProvider.InsertEntity(gdprConsent);

            nextId = await dataProvider.GetTableIdentAsync <GdprConsent>();

            if (type == DataProviderType.SqlServer || type == DataProviderType.Unknown)
            {
                nextId.Should().Be(1);
            }
            else
            {
                nextId.Should().Be(2);
            }

            dataProvider.InsertEntity(gdprConsent);

            nextId = await dataProvider.GetTableIdentAsync <GdprConsent>();

            if (type == DataProviderType.SqlServer || type == DataProviderType.Unknown)
            {
                nextId.Should().Be(2);
            }
            else
            {
                nextId.Should().Be(3);
            }

            await dataProvider.TruncateAsync <GdprConsent>(true);
        }
        protected virtual GdprConsentModel PrepareGdprConsentModel(GdprConsent consent, bool accepted)
        {
            if (consent == null)
            {
                throw new ArgumentNullException(nameof(consent));
            }

            var requiredMessage = _localizationService.GetLocalized(consent, x => x.RequiredMessage);

            return(new GdprConsentModel
            {
                Id = consent.Id,
                Message = _localizationService.GetLocalized(consent, x => x.Message),
                IsRequired = consent.IsRequired,
                RequiredMessage = !string.IsNullOrEmpty(requiredMessage) ? requiredMessage : $"'{consent.Message}' is required",
                Accepted = accepted
            });
        }
    public static void BroadcastIOnConsentReadyIfNeeded()
    {
        if (!CmpCampaignPopupQueue.IsCampaignAvailable &&
            (CmpLocalizationMapper.IsGdprConsented || CmpLocalizationMapper.IsCcpaConsented) &&
            (CmpLocalizationMapper.ccpaUserConsent != null || CmpLocalizationMapper.gdprUserConsent != null))
        {
            SpGdprConsent gdpr = null;
            SpCcpaConsent ccpa = null;
            if (CmpLocalizationMapper.IsGdprConsented &&
                CmpLocalizationMapper.gdprUserConsent != null &&
                CmpLocalizationMapper.gdprUserConsent.grants != null)
            {
                var gdprConsent = new GdprConsent();
                gdprConsent.euconsent = CmpLocalizationMapper.gdprUserConsent.euconsent;
                gdprConsent.TCData    = CmpLocalizationMapper.gdprUserConsent.TCData;
                gdprConsent.uuid      = CmpLocalizationMapper.gdprUserConsent.uuid;
                gdprConsent.grants    = new Dictionary <string, SpVendorGrant>();
                foreach (var kv in CmpLocalizationMapper.gdprUserConsent.grants)
                {
                    gdprConsent.grants[kv.Key] = new SpVendorGrant(kv.Value.purposeGrants);
                }

                gdpr = new SpGdprConsent(gdprConsent);
                CmpLocalizationMapper.gdprUserConsent = null;
            }
            if (CmpLocalizationMapper.IsCcpaConsented &&
                CmpLocalizationMapper.ccpaUserConsent != null)
            {
                CcpaConsent ccpaConsent = new CcpaConsent(uuid: CmpLocalizationMapper.ccpaUserConsent.uuid,
                                                          status: CmpLocalizationMapper.ccpaUserConsent.status,
                                                          uspstring: CmpLocalizationMapper.ccpaUserConsent.uspstring,
                                                          rejectedVendors: CmpLocalizationMapper.ccpaUserConsent.rejectedVendors,
                                                          rejectedCategories: CmpLocalizationMapper.ccpaUserConsent.rejectedCategories);
                ccpa = new SpCcpaConsent(ccpaConsent);
                CmpLocalizationMapper.ccpaUserConsent = null;
            }
            ConsentMessenger.Broadcast <IOnConsentReady>(new SpConsents(gdpr, ccpa));
        }
    }
Exemple #14
0
        public static SpGdprConsent UnwrapSpGdprConsentAndroid(SpGdprConsentWrapperAndroid wrappedGdpr)
        {
            GdprConsent unwrapped = new GdprConsent
            {
                uuid      = wrappedGdpr.uuid,
                euconsent = wrappedGdpr.euconsent,
                TCData    = wrappedGdpr.tcData,
                grants    = new Dictionary <string, SpVendorGrant>()
            };

            foreach (KeyValuePair <string, Dictionary <string, object> > vendorGrantWrapper in wrappedGdpr.grants)
            {
                Dictionary <string, bool> purposeGrants = new Dictionary <string, bool>();
                if (vendorGrantWrapper.Value != null)
                {
                    foreach (KeyValuePair <string, object> purpGrant in vendorGrantWrapper.Value)
                    {
                        purposeGrants.Add(purpGrant.Key, ((JsonElement)purpGrant.Value).GetBoolean());
                    }
                }
                unwrapped.grants[vendorGrantWrapper.Key] = new SpVendorGrant(/*isGranted,*/ purposeGrants);
            }
            return(new SpGdprConsent(unwrapped));
        }
Exemple #15
0
 private void SuccessDelegate(GdprConsent customConsent)
 {
     Debug.Log($"I am your success callback!");
 }
Exemple #16
0
 //GDPR consents
 public static GdprConsentModel ToModel(this GdprConsent entity)
 {
     return(entity.MapTo <GdprConsent, GdprConsentModel>());
 }
Exemple #17
0
 public static GdprConsent ToEntity(this GdprConsentModel model, GdprConsent destination)
 {
     return(model.MapTo(destination));
 }
 /// <summary>
 /// Delete a GDPR consent
 /// </summary>
 /// <param name="gdprConsent">GDPR consent</param>
 public virtual void DeleteConsent(GdprConsent gdprConsent)
 {
     _gdprConsentRepository.Delete(gdprConsent);
 }
 /// <summary>
 /// Update the GDPR consent
 /// </summary>
 /// <param name="gdprConsent">GDPR consent</param>
 public virtual void UpdateConsent(GdprConsent gdprConsent)
 {
     _gdprConsentRepository.Update(gdprConsent);
 }
 /// <summary>
 /// Insert a GDPR consent
 /// </summary>
 /// <param name="gdprConsent">GDPR consent</param>
 public virtual void InsertConsent(GdprConsent gdprConsent)
 {
     _gdprConsentRepository.Insert(gdprConsent);
 }
Exemple #21
0
 /// <summary>
 /// Delete a GDPR consent
 /// </summary>
 /// <param name="gdprConsent">GDPR consent</param>
 public virtual async Task DeleteConsentAsync(GdprConsent gdprConsent)
 {
     await _gdprConsentRepository.DeleteAsync(gdprConsent);
 }
Exemple #22
0
 /// <summary>
 /// Insert a GDPR consent
 /// </summary>
 /// <param name="gdprConsent">GDPR consent</param>
 public virtual async Task InsertConsentAsync(GdprConsent gdprConsent)
 {
     await _gdprConsentRepository.InsertAsync(gdprConsent);
 }