예제 #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 SetSMSSettingTest()
        {
            string siteId    = "1";
            string sipPeerId = "test";

            var SipPeerSmsFeature = new SipPeerSmsFeature
            {
                SipPeerSmsFeatureSettings = new SipPeerSmsFeatureSettings
                {
                    TollFree = true
                },
                SmppHosts = new SmppHost[]
                {
                    new SmppHost
                    {
                        HostName = "Host"
                    }
                }
            };

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

                Assert.IsNotNull(r.SipPeerSmsFeature);
                Assert.AreEqual(true, r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.TollFree);
                Assert.AreEqual(true, r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.ShortCode);
                Assert.AreEqual("DefaultOff", r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.A2pLongCode);
                Assert.AreEqual("SomeMessageClass", r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.A2pMessageClass);
                Assert.AreEqual("SomeCampaignId", r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.A2pCampaignId);
                Assert.AreEqual("SMPP", r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.Protocol);
                Assert.AreEqual(true, r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.Zone1);
                Assert.AreEqual(true, r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.Zone2);
                Assert.AreEqual(true, r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.Zone3);
                Assert.AreEqual(true, r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.Zone4);
                Assert.AreEqual(true, r.SipPeerSmsFeature.SipPeerSmsFeatureSettings.Zone5);

                Assert.AreEqual(2, r.SipPeerSmsFeature.SmppHosts.Length);
                Assert.AreEqual("RECEIVER_ONLY", r.SipPeerSmsFeature.SmppHosts[0].ConnectionType);
                Assert.AreEqual("54.10.88.146", r.SipPeerSmsFeature.SmppHosts[0].HostName);
                Assert.AreEqual(0, r.SipPeerSmsFeature.SmppHosts[0].Priority);
            }
        }