public void SubscribeTo(string email, long id, GDPRLegalBasis legalBasis, string explanation, OptState optState = OptState.OPT_IN)
        {
            SubscriptionTypeHubSpotModel singleSub = GetSubscription(id);
            SubscriptionSubscribeHubSpotModel subRequest = new SubscriptionSubscribeHubSpotModel();

            if (singleSub == null)
                throw new KeyNotFoundException("The SubscriptionType ID provided does not exist in the SubscriptionType list");

            subRequest.SubscriptionStatuses.Add(new SubscriptionStatusDetailHubSpotModel(singleSub.Id, true, optState, legalBasis, explanation));

            SendSubscriptionRequest(GetRoute(email), subRequest);
        }        
        public async Task SubscribeAllAsync(string email, GDPRLegalBasis legalBasis, string explanation, OptState optState = OptState.OPT_IN, CancellationToken cancellationToken = default)
        {
            List <SubscriptionStatusDetailHubSpotModel> subs       = new List <SubscriptionStatusDetailHubSpotModel>();
            SubscriptionSubscribeHubSpotModel           subRequest = new SubscriptionSubscribeHubSpotModel();

            (await GetSubscriptionTypesAsync(cancellationToken)).Types.ForEach(sub =>
            {
                subs.Add(new SubscriptionStatusDetailHubSpotModel(sub.Id, true, optState, legalBasis, explanation));
            });

            subRequest.SubscriptionStatuses.AddRange(subs);

            await SendSubscriptionRequestAsync(GetRoute(email), subRequest, cancellationToken);
        }
        public void SubscribeAll(string email, GDPRLegalBasis legalBasis, string explanation, OptState optState = OptState.OPT_IN)
        {
            List<SubscriptionStatusDetailHubSpotModel> subs = new List<SubscriptionStatusDetailHubSpotModel>();
            SubscriptionSubscribeHubSpotModel subRequest = new SubscriptionSubscribeHubSpotModel();

            GetSubscriptionTypes().Types.ForEach(sub =>
            {
                subs.Add(new SubscriptionStatusDetailHubSpotModel(sub.Id, true, optState, legalBasis, explanation));
            });

            subRequest.SubscriptionStatuses.AddRange(subs);

            SendSubscriptionRequest(GetRoute(email), subRequest);
        }
        public async Task SubscribeToAsync(string email, long id, GDPRLegalBasis legalBasis, string explanation, OptState optState = OptState.OPT_IN, CancellationToken cancellationToken = default)
        {
            SubscriptionTypeHubSpotModel singleSub = await GetSubscriptionAsync(id, cancellationToken);

            SubscriptionSubscribeHubSpotModel subRequest = new SubscriptionSubscribeHubSpotModel();

            if (singleSub == null)
            {
                throw new KeyNotFoundException("The SubscriptionType ID provided does not exist in the SubscriptionType list");
            }

            subRequest.SubscriptionStatuses.Add(new SubscriptionStatusDetailHubSpotModel(singleSub.Id, true, optState, legalBasis, explanation));

            await SendSubscriptionRequestAsync(GetRoute(email), subRequest, cancellationToken);
        }
Exemplo n.º 5
0
 public static string GetBasis(GDPRLegalBasis legalBasisKey)
 => LegalBases[legalBasisKey];
 public SubscriptionSubscribeHubSpotModel(GDPRLegalBasis legalBasis, string explanation) : this()
 {
     PortalSubscriptionLegalBasis            = GDPRLegalBases.GetBasis(legalBasis);
     PortalSubscriptionLegalBasisExplanation = explanation;
 }
Exemplo n.º 7
0
 /// <summary>
 /// Used when GDPR compliance is enabled on portal
 /// </summary>
 /// <param name="id">The target subscription's ID</param>
 /// <param name="subscribed">Whether or not the contact is subscribing (if false, they are unsubscribing)</param>
 /// <param name="optState">The OptState of the contact for this subscription</param>
 /// <param name="legalBasis">The legal basis on which the contact can be added to this subscription</param>
 /// <param name="explanation">A brief explanation of why they should be subscribed</param>
 public SubscriptionStatusDetailHubSpotModel(long id, bool subscribed, OptState optState, GDPRLegalBasis legalBasis, string explanation) : this(id, subscribed, optState)
 {
     LegalBasis            = GDPRLegalBases.GetBasis(legalBasis);
     LegalBasisExplanation = explanation;
 }