Ejemplo n.º 1
0
        /// <summary>
        /// Using the Site and SipPeer created in the createSiteAndSipPeer()
        /// this method will create a Messaging application and associate it with
        /// the newly created SipPeer (location).
        /// It will also add the SMS and MMS features toteh SipPeer (location)
        /// This makes it possible for the SipPeer (location) to be used by a Messaging Application
        /// </summary>
        /// <returns></returns>
        static async Task createMessageApplication()
        {
            var appMsg = await Application.Create(client, new Application
            {
                AppName        = "BandwidthMsgApplication",
                ServiceType    = "Messaging-V2",
                MsgCallbackUrl = "https://yourcallback.com"
            });

            Console.WriteLine($"Created Messaging Application with ID: {appMsg.Application.ApplicationId}");

            var featureSmsMsg = await SipPeer.CreateSMSSettings(client, site.Id, sipPeer.Id, new SipPeerSmsFeature
            {
                SipPeerSmsFeatureSettings = new SipPeerSmsFeatureSettings
                {
                    TollFree  = false,
                    ShortCode = false,
                    Protocol  = "HTTP",
                    Zone1     = true,
                    Zone2     = false,
                    Zone3     = false,
                    Zone4     = false,
                    Zone5     = false,
                },
                HttpSettings = new HttpSettings
                {
                }
            });

            Console.WriteLine("Updated SipPeer/Location with SMS Settings.");

            var featureMmsMsg = await SipPeer.CreateMMSSettings(client, site.Id, sipPeer.Id, new MmsFeature
            {
                MmsSettings = new MmsSettings
                {
                    Protocol = "HTTP"
                },
                Protocols = new Protocols
                {
                    HTTP = new HTTP {
                        HttpSettings = new HttpSettings
                        {
                        }
                    }
                }
            });

            Console.WriteLine("Updated SipPeer/Location with MMS Settings.");

            await SipPeer.UpdateApplicationSettings(client, site.Id, sipPeer.Id, new ApplicationsSettings
            {
                HttpMessagingV2AppId = appMsg.Application.ApplicationId
            });

            Console.WriteLine("Updated SipPeer/Location with Messaging Application");
        }
        public void SetMMSSettingTest()
        {
            string siteId    = "1";
            string sipPeerId = "test";

            var MmsFeature = new MmsFeature
            {
                Protocols = new Protocols
                {
                    MM4 = new MM4
                    {
                        Tls = "OFF"
                    }
                }
            };

            using (var server = new HttpServer(new[]
            {
                new RequestHandler
                {
                    EstimatedMethod = "POST",
                    EstimatedPathAndQuery = $"/v1.0/accounts/{Helper.AccountId}/sites/{siteId}/sippeers/{sipPeerId}/products/messaging/features/mms",
                    ContentToSend = new StringContent(TestXmlStrings.MmsFeatureResponse, Encoding.UTF8, "application/xml")
                }
            }))
            {
                var client = Helper.CreateClient();
                var r      = SipPeer.CreateMMSSettings(siteId, sipPeerId, MmsFeature).Result;
                if (server.Error != null)
                {
                    throw server.Error;
                }

                Assert.IsNotNull(r.MmsFeature);
                Assert.AreEqual("OFF", r.MmsFeature.Protocols.MM4.Tls);
                Assert.AreEqual(1, r.MmsFeature.Protocols.MM4.MmsMM4TermHosts.TermHosts.Length);
                Assert.AreEqual("206.107.248.58", r.MmsFeature.Protocols.MM4.MmsMM4TermHosts.TermHosts[0].HostName);

                Assert.AreEqual(2, r.MmsFeature.Protocols.MM4.MmsMM4OrigHosts.OrigHosts.Length);
                Assert.AreEqual("30.239.72.55", r.MmsFeature.Protocols.MM4.MmsMM4OrigHosts.OrigHosts[0].HostName);
                Assert.AreEqual(8726, r.MmsFeature.Protocols.MM4.MmsMM4OrigHosts.OrigHosts[0].Port);
                Assert.AreEqual(0, r.MmsFeature.Protocols.MM4.MmsMM4OrigHosts.OrigHosts[0].Priority);
            }
        }