Exemple #1
0
        /// <summary>
        /// Subscribe to a particular topic.
        /// </summary>
        /// <param name="topic">The topic to subscribe to.</param>
        /// <param name="callback">The callback url.</param>
        /// <param name="verify">Either 'sync' or 'async'.</param>
        /// <param name="verifyToken">An optional token to be sent along with the verification.</param>
        /// <param name="leaseSeconds">The number of seconds the lease should be for.</param>
        /// <param name="woeIds">An array of WOE ids to listen to. Only applies if topic is 'geo'.</param>
        /// <param name="placeIds">An array of place ids to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="latitude">The latitude to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="longitude">The longitude to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="radius">The radius to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="radiusUnits">The raduis units to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="accuracy">The accuracy of the geo search to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="nsids">A list of Commons Institutes to subscribe to. Only applies if topic is 'commons'. If not present this argument defaults to all Flickr Commons institutions.</param>
        /// <param name="tags">A list of strings to be used for tag subscriptions. Photos with one or more of the tags listed will be included in the subscription. Only valid if the topic is 'tags'</param>
        public void PushSubscribe(string topic, string callback, string verify, string verifyToken, int leaseSeconds, int[] woeIds, string[] placeIds, double latitude, double longitude, int radius, RadiusUnit radiusUnits, GeoAccuracy accuracy, string[] nsids, string[] tags)
        {
            CheckRequiresAuthentication();

            if (String.IsNullOrEmpty(topic)) throw new ArgumentNullException("topic");
            if (String.IsNullOrEmpty(callback)) throw new ArgumentNullException("callback");
            if (String.IsNullOrEmpty(verify)) throw new ArgumentNullException("verify");

            if (topic == "tags" && (tags == null || tags.Length == 0)) throw new InvalidOperationException("Must specify at least one tag is using topic of 'tags'");

            var parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.push.subscribe");
            parameters.Add("topic", topic);
            parameters.Add("callback", callback);
            parameters.Add("verify", verify);
            if (!String.IsNullOrEmpty(verifyToken)) parameters.Add("verify_token", verifyToken);
            if (leaseSeconds > 0) parameters.Add("lease_seconds", leaseSeconds.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            if (woeIds != null && woeIds.Length > 0)
            {
                List<string> woeIdList = new List<string>();
                foreach (int i in woeIds) { woeIdList.Add(i.ToString(System.Globalization.NumberFormatInfo.InvariantInfo)); }
                parameters.Add("woe_ids", String.Join(",", woeIdList.ToArray()));
            }
            if (placeIds != null && placeIds.Length > 0) parameters.Add("place_ids", String.Join(",", placeIds));
            if (radiusUnits != RadiusUnit.None) parameters.Add("radius_units", radiusUnits.ToString("d"));

            GetResponseNoCache<NoResponse>(parameters);
        }
Exemple #2
0
        /// <summary>
        /// Subscribe to a particular topic.
        /// </summary>
        /// <param name="topic">The topic to subscribe to.</param>
        /// <param name="callback">The callback url.</param>
        /// <param name="verify">Either 'sync' or 'async'.</param>
        /// <param name="verifyToken">An optional token to be sent along with the verification.</param>
        /// <param name="leaseSeconds">The number of seconds the lease should be for.</param>
        /// <param name="woeIds">An array of WOE ids to listen to. Only applies if topic is 'geo'.</param>
        /// <param name="placeIds">An array of place ids to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="latitude">The latitude to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="longitude">The longitude to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="radius">The radius to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="radiusUnits">The raduis units to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="accuracy">The accuracy of the geo search to subscribe to. Only applies if topic is 'geo'.</param>
        /// <param name="nsids">A list of Commons Institutes to subscribe to.
        /// Only applies if topic is 'commons'. If not present this argument defaults to all Flickr Commons institutions.</param>
        /// <param name="tags">A list of strings to be used for tag subscriptions.
        /// Photos with one or more of the tags listed will be included in the subscription.
        /// Only valid if the topic is 'tags'</param>
        /// <param name="callbackAction"></param>
        public void PushSubscribeAsync(string topic, string callback, string verify, string verifyToken,
                                       int leaseSeconds, int[] woeIds, string[] placeIds, double latitude,
                                       double longitude, int radius, RadiusUnit radiusUnits, GeoAccuracy accuracy,
                                       string[] nsids, string[] tags, Action <FlickrResult <NoResponse> > callbackAction)
        {
            CheckRequiresAuthentication();

            if (string.IsNullOrEmpty(topic))
            {
                throw new ArgumentNullException("topic");
            }
            if (string.IsNullOrEmpty(callback))
            {
                throw new ArgumentNullException("callback");
            }
            if (string.IsNullOrEmpty(verify))
            {
                throw new ArgumentNullException("verify");
            }

            if (topic == "tags" && (tags == null || tags.Length == 0))
            {
                throw new InvalidOperationException("Must specify at least one tag is using topic of 'tags'");
            }

            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.push.subscribe");
            parameters.Add("topic", topic);
            parameters.Add("callback", callback);
            parameters.Add("verify", verify);
            if (!string.IsNullOrEmpty(verifyToken))
            {
                parameters.Add("verify_token", verifyToken);
            }
            if (leaseSeconds > 0)
            {
                parameters.Add("lease_seconds",
                               leaseSeconds.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
            }
            if (woeIds != null && woeIds.Length > 0)
            {
                var woeIdList = new List <string>();
                foreach (int i in woeIds)
                {
                    woeIdList.Add(i.ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
                }
                parameters.Add("woe_ids", string.Join(",", woeIdList.ToArray()));
            }
            if (placeIds != null && placeIds.Length > 0)
            {
                parameters.Add("place_ids", string.Join(",", placeIds));
            }
            if (radiusUnits != RadiusUnit.None)
            {
                parameters.Add("radius_units", radiusUnits.ToString("d"));
            }

            GetResponseAsync <NoResponse>(parameters, callbackAction);
        }
Exemple #3
0
        public async Task <string> ToUrlParamsString()
        {
            var urlParams = new Dictionary <string, string>();

            urlParams.Add("cityCode", CityCode);
            urlParams.Add("radius", Radius.ToString());
            urlParams.Add("radiusUnit", RadiusUnit.ToString());
            urlParams.Add("checkInDate", CheckInDate.ToString("yyyy-MM-dd"));
            urlParams.Add("checkOutDate", CheckOutDate.ToString("yyyy-MM-dd"));
            urlParams.Add("adults", Adults.ToString());
            urlParams.Add("includeClosed", IncludeClosed.ToString().ToLower());
            urlParams.Add("bestRateOnly", BestRateOnly.ToString().ToLower());
            urlParams.Add("sort", Sort.ToString().ToUpper());

            using (HttpContent content = new FormUrlEncodedContent(urlParams))
                return(await content.ReadAsStringAsync());
        }
 public GeoRadius(decimal value, RadiusUnit unit)
 {
     Value = value;
     Unit  = unit;
 }
 public void PushSubscribe(string topic, string callback, string verify, string verifyToken, int? leaseSeconds, IEnumerable<int> woeIds, IEnumerable<string> placeIds, double? lat, double? lon, int? radius, RadiusUnit radiusUnits, GeoAccuracy accuracy, IEnumerable<string> nsids, IEnumerable<string> tags)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.push.subscribe");
     dictionary.Add("topic", topic);
     dictionary.Add("callback", callback);
     dictionary.Add("verify", verify);
     if (verifyToken != null) dictionary.Add("verify_token", verifyToken);
     if (leaseSeconds != null) dictionary.Add("lease_seconds", leaseSeconds.ToString().ToLower());
     if (woeIds != null) dictionary.Add("woe_ids", woeIds == null ? String.Empty : String.Join(",", woeIds.Select(d => d.ToString(CultureInfo.InvariantCulture)).ToArray()));
     if (placeIds != null) dictionary.Add("place_ids", placeIds == null ? String.Empty : String.Join(",", placeIds.ToArray()));
     if (lat != null) dictionary.Add("lat", lat.ToString().ToLower());
     if (lon != null) dictionary.Add("lon", lon.ToString().ToLower());
     if (radius != null) dictionary.Add("radius", radius.ToString().ToLower());
     if (radiusUnits != RadiusUnit.None) dictionary.Add("radius_units", radiusUnits.ToString().ToLower());
     if (accuracy != GeoAccuracy.None) dictionary.Add("accuracy", accuracy.ToString("d"));
     if (nsids != null) dictionary.Add("nsids", nsids == null ? String.Empty : String.Join(",", nsids.ToArray()));
     if (tags != null) dictionary.Add("tags", tags == null ? String.Empty : String.Join(",", tags.ToArray()));
     GetResponse<NoResponse>(dictionary);
 }