private Response ChannelFindByWoeId(PlaceByWoeId request, int retry = 0)
 {
     try
     {
         return(Channel.FindByWoeId(request.WoeId, request.Locale,
                                    request.Start, request.Count, request.Offset,
                                    request.GetFlagsAsString(), request.GetGFlagsAsString(),
                                    request.AppId));
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
         {
             return(ChannelFindByWoeId(request, ++retry));
         }
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
         {
             return(ChannelFindByWoeId(request, ++retry));
         }
         throw;
     }
 }
        public void Yahoo_PlaceFinder_PlaceByWoeId_ShouldConstructWithWoeId()
        {
            var it = new PlaceByWoeId(1);

            it.ShouldNotBeNull();
            it.WoeId.ShouldEqual(1);
        }
 private static BossResponse OAuthFind(PlaceByWoeId request, string consumerKey, string consumerSecret, int retry = 0)
 {
     try
     {
         using (var oAuth = new OAuthClient())
         {
             var json          = oAuth.Get(request.GetUri(), consumerKey, consumerSecret);
             var bossContainer = JsonConvert.DeserializeObject <BossContainer>(json);
             if (bossContainer != null)
             {
                 return(bossContainer.BossResponse);
             }
             throw new InvalidOperationException("Unable to parse BOSS GEO Response. Raw JSON:\r\n" + json);
         }
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
         {
             return(OAuthFind(request, consumerKey, consumerSecret, ++retry));
         }
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
         {
             return(OAuthFind(request, consumerKey, consumerSecret, ++retry));
         }
         throw;
     }
 }
Exemple #4
0
        public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveFlags()
        {
            var request = new PlaceByWoeId(1);

            request.Flags.Add(Flag.Airport);
            request.Flags.ShouldContain(Flag.Airport);
        }
        public void Yahoo_PlaceFinder_PlaceByWoeId_ShouldConstructWithWoeId()
        {
            var it = new PlaceByWoeId(1);

            it.ShouldNotBeNull();
            it.WoeId.ShouldEqual(1);
        }
        public void Yahoo_PlaceFinder_PlaceByWoeId_ShouldAllowWoeIdToBeChanged_AfterConstruction()
        {
            var it = new PlaceByWoeId(1) { WoeId = 2 };

            it.ShouldNotBeNull();
            it.WoeId.ShouldEqual(2);
        }
        public ResultSet Find(PlaceByWoeId request, string consumerKey, string consumerSecret)
        {
            if (request == null) throw new ArgumentNullException("request");
            EnsureContractsAreSatisfied(request);

            var response = OAuthFind(request, consumerKey, consumerSecret);
            return response.PlaceFinder;
        }
Exemple #8
0
 public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveStart()
 {
     var request = new PlaceByWoeId(1)
     {
         Start = 9,
     };
     request.Start.ShouldEqual(9);
 }
Exemple #9
0
        public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveStart()
        {
            var request = new PlaceByWoeId(1)
            {
                Start = 9,
            };

            request.Start.ShouldEqual(9);
        }
        internal static Uri GetUri(this PlaceByWoeId request)
        {
            const string template = "woeid={woeid}";

            var urlBuilder = new StringBuilder(GetBaseUrl(request, template));

            urlBuilder.Replace("{woeid}", request.WoeId.ToString(CultureInfo.InvariantCulture));

            return(new Uri(urlBuilder.ToString()));
        }
        public void Yahoo_PlaceFinder_PlaceByWoeId_ShouldAllowWoeIdToBeChanged_AfterConstruction()
        {
            var it = new PlaceByWoeId(1)
            {
                WoeId = 2
            };

            it.ShouldNotBeNull();
            it.WoeId.ShouldEqual(2);
        }
Exemple #12
0
        public ResultSet Find(PlaceByWoeId request, string consumerKey, string consumerSecret)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            EnsureContractsAreSatisfied(request);

            var response = OAuthFind(request, consumerKey, consumerSecret);

            return(response.PlaceFinder);
        }
        public ResultSet Find(PlaceByWoeId request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            EnsureContractsAreSatisfied(request);

            var response = ChannelFindByWoeId(request);

            return(response.ResultSet);
        }
        public void Yahoo_PlaceFinder_PlaceFinderClient_FindByWoeId_ShouldReturn1Result_ForYahooExample()
        {
            using (var client = new PlaceFinderClient())
            {
                var request = new PlaceByWoeId(12797150);

                var results = client.Find(request, ConsumerKey, ConsumerSecret);
                results.ShouldNotBeNull();
                results.Results.ShouldNotBeNull();
                results.Count.ShouldEqual(1);
            }
        }
        public void Yahoo_PlaceFinder_PlaceFinderClient_FindByWoeId_ShouldReturn1Result_ForYahooExample()
        {
            using (var client = new PlaceFinderClient())
            {
                var request = new PlaceByWoeId(12797150);

                var results = client.Find(request);
                results.ShouldNotBeNull();
                results.Results.ShouldNotBeNull();
                results.Results.Count.ShouldEqual(1);
            }
        }
 private static BossResponse OAuthFind(PlaceByWoeId request, string consumerKey, string consumerSecret, int retry = 0)
 {
     try
     {
         using (var oAuth = new OAuthClient())
         {
             var json = oAuth.Get(request.GetUri(), consumerKey, consumerSecret);
             var bossContainer = JsonConvert.DeserializeObject<BossContainer>(json);
             if (bossContainer != null) return bossContainer.BossResponse;
             throw new InvalidOperationException("Unable to parse BOSS GEO Response. Raw JSON:\r\n" + json);
         }
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
             return OAuthFind(request, consumerKey, consumerSecret, ++retry);
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
             return OAuthFind(request, consumerKey, consumerSecret, ++retry);
         throw;
     }
 }
Exemple #17
0
 public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveFlags()
 {
     var request = new PlaceByWoeId(1);
     request.Flags.Add(Flag.Airport);
     request.Flags.ShouldContain(Flag.Airport);
 }