Пример #1
0
        public MessagingProfileServiceTest(MockHttpClientFixture mockHttpClientFixture)
            : base(mockHttpClientFixture)
        {
            this.service             = new MessagingProfileService();
            this.phoneNumbersService = new MessagingProfilePhoneNumbersService();

            this.createOptions = new NewMessagingProfile
            {
                Name               = "Summer Campaign",
                Enabled            = true,
                NumberPoolSettings = new NumberPoolSettings()
                {
                    Geomatch       = false,
                    LongCodeWeight = new decimal(0.62),
                    SkipUnhealthy  = true,
                    StickySender   = false,
                    TollFreeWeight = new decimal(25),
                },
                UrlShortenerSettings = new UrlShortenerSettings()
                {
                    Domain = "example.ex",
                    Prefix = "abc",
                    ReplaceBlackListOnly = true,
                    SendWebhooks         = false,
                },
                ResourceGroupId    = Guid.NewGuid(),
                WebhookApiVersion  = Telnyx.net.Entities.Enum.WebhookAPIVersion.V2,
                WebhookUrl         = "webhookurl.com",
                WebhookFailoverUrl = "failureurl.com",
            };
            this.updateOptions = new MessagingProfileUpdate
            {
                Name               = "Summer Campaign 2",
                Enabled            = false,
                NumberPoolSettings = new NumberPoolSettings()
                {
                    Geomatch       = false,
                    LongCodeWeight = new decimal(0.63),
                    SkipUnhealthy  = true,
                    StickySender   = false,
                    TollFreeWeight = new decimal(26),
                },
                UrlShortenerSettings = new UrlShortenerSettings()
                {
                    Domain = "example.px",
                    Prefix = "xyz",
                    ReplaceBlackListOnly = false,
                    SendWebhooks         = true,
                },
                WhitelistedDestinations = new List <string>()
                {
                    "US", "CA"
                },
                WebhookApiVersion  = Telnyx.net.Entities.Enum.WebhookAPIVersion.V2,
                WebhookUrl         = "webhookurlupdate.com",
                WebhookFailoverUrl = "failureurlupdate.com",
            };
            this.cancellationToken         = default(CancellationToken);
            this._mockServiceForListMethod = new MockMessagingProfilePhoneNumbersService();
        }
        /// <summary>
        /// Update messaging profile
        /// </summary>
        public void Update()
        {
            var updateOptions = new MessagingProfileUpdate
            {
                Name = "Summer Campaign",
                UrlShortenerSettings = new UrlShortenerSettings
                {
                    Domain = "yahoo.com",
                    ReplaceBlackListOnly = true,
                    SendWebhooks         = true,
                }
            };

            Console.WriteLine(JsonConvert.SerializeObject(updateOptions));

            try
            {
                var messagingProfile = this.service.Update(MessagingProfileId, updateOptions);
                Console.WriteLine(JsonConvert.SerializeObject(messagingProfile));
            }
            catch (TelnyxException ex)
            {
                Console.WriteLine("exception");
                Console.WriteLine(JsonConvert.SerializeObject(ex));
            }
        }
        public MessagingProfileServiceTest(MockHttpClientFixture mockHttpClientFixture)
            : base(mockHttpClientFixture)
        {
            this.service             = new MessagingProfileService();
            this.phoneNumbersService = new MessagingProfilePhoneNumbersService();

            this.createOptions = new NewMessagingProfile
            {
                Name = "Summer Campaign"
            };
            this.updateOptions = new MessagingProfileUpdate
            {
                Name = "Summer Campaign"
            };
            this.cancellationToken = default(CancellationToken);
        }
        /// <summary>
        /// Update messaging profile
        /// </summary>
        public void Update()
        {
            var updateOptions = new MessagingProfileUpdate
            {
                Name = "Summer Campaign"
            };

            Console.WriteLine(JsonConvert.SerializeObject(updateOptions));

            try
            {
                var messagingProfile = this.service.Update(MessagingProfileId, updateOptions);
                Console.WriteLine(JsonConvert.SerializeObject(messagingProfile));
            }
            catch (TelnyxException ex)
            {
                Console.WriteLine("exception");
                Console.WriteLine(JsonConvert.SerializeObject(ex));
            }
        }