Ejemplo n.º 1
0
        public void OmniConstruction()
        {
            var city        = new City();
            var omniReponse = new OmniResponse(city: city);

            Assert.AreEqual(omniReponse.City, city);
        }
Ejemplo n.º 2
0
        public void CanDeserializeOmniResponse(OmniResponse omni)
        {
            omni.SetLocales(new List <string> {
                "en"
            });

            Assert.AreEqual(76, omni.City.Confidence);
            Assert.AreEqual(9876, omni.City.GeoNameId);
            Assert.AreEqual("Minneapolis", omni.City.Name);

            Assert.AreEqual("NA", omni.Continent.Code);
            Assert.AreEqual(42, omni.Continent.GeoNameId);
            Assert.AreEqual("North America", omni.Continent.Name);

            Assert.AreEqual(99, omni.Country.Confidence);
            Assert.AreEqual(1, omni.Country.GeoNameId);
            Assert.AreEqual("US", omni.Country.IsoCode);
            Assert.AreEqual("United States of America", omni.Country.Name);

            Assert.AreEqual(1500, omni.Location.AccuracyRadius);
            Assert.AreEqual(44.979999999999997, omni.Location.Latitude);
            Assert.AreEqual(93.263599999999997, omni.Location.Longitude);
            Assert.AreEqual(765, omni.Location.MetroCode);
            Assert.AreEqual("America/Chicago", omni.Location.TimeZone);

            Assert.AreEqual(11, omni.MaxMind.QueriesRemaining);

            Assert.AreEqual("55401", omni.Postal.Code);
            Assert.AreEqual(33, omni.Postal.Confidence);

            Assert.AreEqual(2, omni.RegisteredCountry.GeoNameId);
            Assert.AreEqual("CA", omni.RegisteredCountry.IsoCode);
            Assert.AreEqual("Canada", omni.RegisteredCountry.Name);

            Assert.AreEqual(3, omni.RepresentedCountry.GeoNameId);
            Assert.AreEqual("GB", omni.RepresentedCountry.IsoCode);
            Assert.AreEqual("United Kingdom", omni.RepresentedCountry.Name);
            Assert.AreEqual("C<military>", omni.RepresentedCountry.Type);

            Assert.AreEqual(2, omni.Subdivisions.Count);
            omni.Subdivisions[0].Locales = new List <string> {
                "en"
            };
            Assert.AreEqual(88, omni.Subdivisions[0].Confidence);
            Assert.AreEqual(574635, omni.Subdivisions[0].GeoNameId);
            Assert.AreEqual("MN", omni.Subdivisions[0].IsoCode);
            Assert.AreEqual("Minnesota", omni.Subdivisions[0].Name);
            Assert.AreEqual("TT", omni.Subdivisions[1].IsoCode);

            Assert.AreEqual(1234, omni.Traits.AutonomousSystemNumber);
            Assert.AreEqual("AS Organization", omni.Traits.AutonomousSystemOrganization);
            Assert.AreEqual("example.com", omni.Traits.Domain);
            Assert.AreEqual("1.2.3.4", omni.Traits.IPAddress);
            Assert.AreEqual(true, omni.Traits.IsAnonymousProxy);
            Assert.AreEqual(true, omni.Traits.IsSatelliteProvider);
            Assert.AreEqual("Comcast", omni.Traits.Isp);
            Assert.AreEqual("Blorg", omni.Traits.Organization);
            Assert.AreEqual("college", omni.Traits.UserType);
        }
        private static async Task <string> AdvancedOmniAsync()
        {
            Console.WriteLine("-------------------------------");
            Console.WriteLine("Sending Advance OMNI message...");

            SendAdvancedOmniMessage omniClient = new SendAdvancedOmniMessage(BASIC_AUTH_CONFIGURATION);

            Destination destination = new Destination
            {
                To = new To
                {
                    PhoneNumber = TO
                }
            };

            SmsData smsData = new SmsData
            {
                Text     = "Artık Ulusal Dil Tanımlayıcısı ile Türkçe karakterli smslerinizi rahatlıkla iletebilirsiniz.",
                Language = new Language {
                    LanguageCode = "TR"
                },
                Transliteration = "TURKISH"
            };

            ViberData viberData = new ViberData
            {
                Text = "Luke, I'm your father!"
            };

            OmniAdvancedRequest request = new OmniAdvancedRequest
            {
                Destinations = new List <Destination>(1)
                {
                    destination
                },
                ScenarioKey = "6EDEA8BF17983A97C42BCA702F0A673D", // Your-Scenario-Key
                Sms         = smsData,
                Viber       = viberData
            };

            OmniResponse omniResponse = await omniClient.ExecuteAsync(request);

            Console.WriteLine("-------------------------------");
            Console.WriteLine("Bulk ID: " + omniResponse.BulkId);
            Console.WriteLine("-------------------------------");
            foreach (OmniResponseDetails sentMessageInfo in omniResponse.Messages)
            {
                Console.WriteLine("Message ID: " + sentMessageInfo.MessageId);
                Console.WriteLine("Message status: " + sentMessageInfo.Status.Name);
                Console.WriteLine("-------------------------------");
            }

            return(omniResponse.BulkId);
        }