예제 #1
0
 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;
     }
 }
예제 #2
0
        public void Yahoo_PlaceFinder_PlaceByWoeId_ShouldConstructWithWoeId()
        {
            var it = new PlaceByWoeId(1);

            it.ShouldNotBeNull();
            it.WoeId.ShouldEqual(1);
        }
예제 #3
0
 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;
     }
 }
예제 #4
0
        public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveFlags()
        {
            var request = new PlaceByWoeId(1);

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

            it.ShouldNotBeNull();
            it.WoeId.ShouldEqual(1);
        }
예제 #6
0
        public void Yahoo_PlaceFinder_PlaceByWoeId_ShouldAllowWoeIdToBeChanged_AfterConstruction()
        {
            var it = new PlaceByWoeId(1) { WoeId = 2 };

            it.ShouldNotBeNull();
            it.WoeId.ShouldEqual(2);
        }
예제 #7
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;
        }
예제 #8
0
 public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveStart()
 {
     var request = new PlaceByWoeId(1)
     {
         Start = 9,
     };
     request.Start.ShouldEqual(9);
 }
예제 #9
0
        public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveStart()
        {
            var request = new PlaceByWoeId(1)
            {
                Start = 9,
            };

            request.Start.ShouldEqual(9);
        }
예제 #10
0
        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()));
        }
예제 #11
0
        public void Yahoo_PlaceFinder_PlaceByWoeId_ShouldAllowWoeIdToBeChanged_AfterConstruction()
        {
            var it = new PlaceByWoeId(1)
            {
                WoeId = 2
            };

            it.ShouldNotBeNull();
            it.WoeId.ShouldEqual(2);
        }
예제 #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);
        }
예제 #13
0
        public ResultSet Find(PlaceByWoeId request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            EnsureContractsAreSatisfied(request);

            var response = ChannelFindByWoeId(request);

            return(response.ResultSet);
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
 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;
     }
 }
예제 #17
0
 public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveFlags()
 {
     var request = new PlaceByWoeId(1);
     request.Flags.Add(Flag.Airport);
     request.Flags.ShouldContain(Flag.Airport);
 }