Beispiel #1
0
        /// <summary>
        /// Patches a phone contact point with a subscription to a topic. Will create a new phone contact point if the phone contact point does not exist. Cannot be used to mark a phone contact point as inactive.
        /// </summary>
        private static void PatchPhoneContactPoint()
        {
            ContactName name = new ContactName()
            {
                FirstName = "John",
                LastName  = "Doe"
            };

            PhoneContactIdentity identity = new PhoneContactIdentity()
            {
                PhoneNumber = "+14256668888",                                   //The phone number should follow the E.164 standard
                Name        = name
            };

            PhoneContactPoint phoneContactPoint = new PhoneContactPoint()
            {
                Identity = identity,
                Country  = "US"                                                 //Use only ISO 2 char country codes. Any other string will result in HTTP 400
            };

            phoneContactPoint.TopicSettings.Add(new ContactPointTopicSetting
            {
                TopicId           = testTopicId,                                //Topic ID for which this permission was collected
                CultureName       = CultureInfo.CurrentCulture.ToString(),      //Specify a culture supported by the topic. E.g en-US, fr-FR, fr-CA etc. Communication with the user will be based on this culture;
                LastSourceSetDate = DateTime.UtcNow,                            //The actual time at which this permission was collected. Could be in the past..
                OriginalSource    = "SampleCPMProject",                         //Name of this application that collected the consent. Saved for auditing purposes.
                State             = ContactPointTopicSettingState.OptInExplicit //The permission
            });

            cpmClient.PatchPhoneContactPoint(phoneContactPoint).Wait();
            Console.WriteLine("Phone contact patch successfull");
        }
Beispiel #2
0
        public async Task PatchPhoneContactPoint(PhoneContactPoint contactToPatch)
        {
            var reqMessage = new HttpRequestMessage(new HttpMethod("PATCH"), "api/PhoneContacts");

            reqMessage.Content = new StringContent(JsonConvert.SerializeObject(contactToPatch, new StringEnumConverter()));
            reqMessage.Content.Headers.ContentType = new Headers.MediaTypeHeaderValue("application/json");

            await MakeRequestAndParseResponse <PhoneContactPoint>(reqMessage);
        }
Beispiel #3
0
        /// <summary>
        /// Patches a phone contact point with a subscription to a topic. Will create a new phone contact point if the phone contact point does not exist. Cannot be used to mark a phone contact point as inactive.
        /// </summary>
        /// <param name="phoneNumber">The phone number of the phone contact point eg. +1234567890</param>
        /// <param name="firstName">Optional, First Name. </param>
        /// <param name="middleName">Optional, Middle Name".</param>
        /// <param name="lastName">Optional, Last Name".</param>
        /// <param name="generationalSuffix">Optional, suffix eg. Sr".</param>
        /// <param name="countryName">the country of the phone contact point</param>
        /// <param name="topicId">the identifier of the topic</param>
        /// <param name="state">The state the subscription should be in eg. OptInExplicit</param>
        /// <returns></returns>
        private static async Task PatchPhoneContactPoint(string phoneNumber, string firstName, string middleName, string lastName, string generationalSuffix, string countryName, Guid topicId, ContactPointTopicSettingState state)
        {
            ContactName name = new ContactName()
            {
                FirstName          = firstName,
                MiddleName         = middleName,
                LastName           = lastName,
                GenerationalSuffix = generationalSuffix
            };

            PhoneContactIdentity identity = new PhoneContactIdentity()
            {
                PhoneNumber = phoneNumber,
                Name        = name
            };

            PhoneContactPoint phoneContactPoint = new PhoneContactPoint()
            {
                Identity = identity,
                Country  = countryName
            };

            phoneContactPoint.TopicSettings.Add(new ContactPointTopicSetting
            {
                TopicId           = topicId,
                CultureName       = CultureInfo.CurrentCulture.ToString(),
                LastSourceSetDate = DateTime.UtcNow,
                OriginalSource    = "SampleCPMProject",
                State             = state
            });
            using (HttpClient client = await CPMClientGenerator.CreateHttpClientAsync())
            {
                HttpResponseMessage response = await client.PatchAsync("api/PhoneContacts", phoneContactPoint);

                if (response.IsSuccessStatusCode)
                {
                    // By design, we do not return the request body after a successful phone contact point patch
                }
                else
                {
                    Console.WriteLine(await response.Content.ReadAsStringAsync());
                }
            }
        }