Ejemplo n.º 1
0
        public override IDictionary <string, object> GetUriPathParameters()
        {
            var uriParams = new Dictionary <string, object>();

            var isTypeSetAndValid = Type != null && Type != TraktRatingsItemType.Unspecified;

            if (isTypeSetAndValid)
            {
                uriParams.Add("type", Type.UriName);
            }

            if (RatingFilter != null && isTypeSetAndValid)
            {
                var ratingsMin = RatingFilter.Min();
                var ratingsMax = RatingFilter.Max();

                var isRatingsSetAndValid = RatingFilter.Length > 0 && RatingFilter.Length <= 10 && ratingsMin >= 1 && ratingsMax <= 10;

                if (isRatingsSetAndValid)
                {
                    uriParams.Add("rating", string.Join(",", RatingFilter));
                }
            }

            if (ExtendedInfo != null && ExtendedInfo.HasAnySet)
            {
                uriParams.Add("extended", ExtendedInfo.ToString());
            }

            return(uriParams);
        }
Ejemplo n.º 2
0
        public override IDictionary <string, object> GetUriPathParameters()
        {
            var uriParams = base.GetUriPathParameters();

            uriParams.Add("username", Username);

            var isTypeSetAndValid = Type != null && Type != TraktRatingsItemType.Unspecified;

            if (isTypeSetAndValid)
            {
                uriParams.Add("type", Type.UriName);
            }

            if (RatingFilter != null && isTypeSetAndValid)
            {
                var ratingMin = RatingFilter.Min();
                var ratingMax = RatingFilter.Max();

                var isRatingsSetAndValid = RatingFilter.Length > 0 && RatingFilter.Length <= 10 && ratingMin >= 1 && ratingMax <= 10;

                if (isRatingsSetAndValid)
                {
                    uriParams.Add("rating", string.Join(",", RatingFilter));
                }
            }

            if (Page.HasValue)
            {
                uriParams.Add("page", Page.Value.ToString());
            }

            if (Limit.HasValue)
            {
                uriParams.Add("limit", Limit.Value.ToString());
            }

            return(uriParams);
        }