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);
                }
            }
        }
Exemplo n.º 2
0
        public static GdprConsent UnwrapGdprConsent(string json)
        {
            GdprConsentWrapper wrapped   = JsonSerializer.Deserialize <GdprConsentWrapper>(json);
            GdprConsent        unwrapped = UnwrapGdprConsent(wrapped);

            return(unwrapped);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
        private static SpGdprConsent UnwrapSpGdprConsent(SpGdprConsentWrapper wrappedGdpr)
        {
            // bool applies = ((JsonElement) wrappedGdpr.applies).GetBoolean();
            GdprConsent consent = UnwrapGdprConsent(wrappedGdpr.consents);

            return(new SpGdprConsent(consent));
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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
            });
        }
Exemplo n.º 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);
        }
Exemplo n.º 12
0
        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
            });
        }
Exemplo n.º 13
0
    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));
        }
    }
Exemplo n.º 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));
        }
Exemplo n.º 15
0
 private void SuccessDelegate(GdprConsent customConsent)
 {
     Debug.Log($"I am your success callback!");
 }
Exemplo n.º 16
0
 //GDPR consents
 public static GdprConsentModel ToModel(this GdprConsent entity)
 {
     return(entity.MapTo <GdprConsent, GdprConsentModel>());
 }
Exemplo n.º 17
0
 public static GdprConsent ToEntity(this GdprConsentModel model, GdprConsent destination)
 {
     return(model.MapTo(destination));
 }
Exemplo n.º 18
0
 /// <summary>
 /// Delete a GDPR consent
 /// </summary>
 /// <param name="gdprConsent">GDPR consent</param>
 public virtual void DeleteConsent(GdprConsent gdprConsent)
 {
     _gdprConsentRepository.Delete(gdprConsent);
 }
Exemplo n.º 19
0
 /// <summary>
 /// Update the GDPR consent
 /// </summary>
 /// <param name="gdprConsent">GDPR consent</param>
 public virtual void UpdateConsent(GdprConsent gdprConsent)
 {
     _gdprConsentRepository.Update(gdprConsent);
 }
Exemplo n.º 20
0
 /// <summary>
 /// Insert a GDPR consent
 /// </summary>
 /// <param name="gdprConsent">GDPR consent</param>
 public virtual void InsertConsent(GdprConsent gdprConsent)
 {
     _gdprConsentRepository.Insert(gdprConsent);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }