/// <summary>
        /// Gets the next up.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.ArgumentNullException">query</exception>
        protected Uri GetNextUpUrl(NextUpQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            var dict = new NameValueCollection {
            };

            if (query.Fields != null)
            {
                dict.Add("fields", query.Fields.Select(f => f.ToString()));
            }

            dict.Add("ParentId", query.ParentId);

            dict.AddIfNotNull("Limit", query.Limit);

            dict.AddIfNotNull("StartIndex", query.StartIndex);

            dict.AddIfNotNullOrEmpty("SeriesId", query.SeriesId);

            dict.Add("UserId", query.UserId.ToString("N", CultureInfo.InvariantCulture));

            dict.AddIfNotNull("EnableImages", query.EnableImages);
            if (query.EnableImageTypes != null)
            {
                dict.Add("EnableImageTypes", query.EnableImageTypes.Select(f => f.ToString()));
            }
            dict.AddIfNotNull("ImageTypeLimit", query.ImageTypeLimit);

            return(GetApiUrl(new Uri("Shows/NextUp", UriKind.Relative), dict));
        }
예제 #2
0
        public Task <Report> BankSummaryAsync(DateTime?from = null, DateTime?to = null)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("fromDate", from);
            parameters.AddIfNotNull("toDate", to);

            var endpoint = AddParameters(parameters);

            return(endpoint.FindAsync(NamedReportType.BankSummary.ToString()));
        }
예제 #3
0
        private NameValueCollection GetAgedParameters(Guid contact, DateTime?date, DateTime?from, DateTime?to)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("contactID", contact);
            parameters.AddIfNotNull("date", date);
            parameters.AddIfNotNull("fromDate", from);
            parameters.AddIfNotNull("toDate", to);

            return(parameters);
        }
        /// <summary>
        /// Gets the item by name list URL.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="query">The query.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.ArgumentNullException">query</exception>
        protected Uri GetItemByNameListUrl(string type, ItemsByNameQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            var dict = new NameValueCollection {
            };

            dict.AddIfNotNullOrEmpty("ParentId", query.ParentId);

            dict.Add("UserId", query.UserId);
            dict.AddIfNotNull("StartIndex", query.StartIndex);

            dict.AddIfNotNull("Limit", query.Limit);

            dict.AddIfNotNull("SortBy", query.SortBy);

            if (query.SortOrder.HasValue)
            {
                dict["sortOrder"] = query.SortOrder.ToString();
            }

            dict.AddIfNotNull("IsPlayed", query.IsPlayed);

            if (query.Fields != null)
            {
                dict.Add("fields", query.Fields.Select(f => f.ToString()));
            }

            if (query.Filters != null)
            {
                dict.Add("Filters", query.Filters.Select(f => f.ToString()));
            }

            if (query.ImageTypes != null)
            {
                dict.Add("ImageTypes", query.ImageTypes.Select(f => f.ToString()));
            }

            dict.Add("recursive", query.Recursive);

            dict.AddIfNotNull("MediaTypes", query.MediaTypes);
            dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes);
            dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes);

            dict.AddIfNotNullOrEmpty("NameLessThan", query.NameLessThan);
            dict.AddIfNotNullOrEmpty("NameStartsWithOrGreater", query.NameStartsWithOrGreater);

            dict.AddIfNotNull("EnableImages", query.EnableImages);
            if (query.EnableImageTypes != null)
            {
                dict.Add("EnableImageTypes", query.EnableImageTypes.Select(f => f.ToString()));
            }
            dict.AddIfNotNull("ImageTypeLimit", query.ImageTypeLimit);

            return(GetApiUrl(new Uri(type, UriKind.Relative), dict));
        }
예제 #5
0
        public Task <Report> TrailBalanceAsync(DateTime?date = null, bool?paymentsOnly = null)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("date", date);
            parameters.AddIfNotNull("paymentsOnly", paymentsOnly);

            var endpoint = AddParameters(parameters);

            return(endpoint.FindAsync(NamedReportType.TrialBalance.ToString()));
        }
예제 #6
0
        public Task <Report> BudgetSummaryAsync(DateTime?date = null, int?periods = null, BudgetSummaryTimeframeType?timeFrame = null)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("date", date);
            parameters.AddIfNotNull("periods", periods);
            parameters.AddIfNotNull("timeframe", (int?)timeFrame);

            var endpoint = AddParameters(parameters);

            return(endpoint.FindAsync(NamedReportType.BudgetSummary.ToString()));
        }
예제 #7
0
        public void AddIfNotNull_Should_Add_Key_Value_Pair_To_Dictionary_If_Value_Is_Not_Null(string key, string value)
        {
            // Arrange
            var expectedDictLength = TestNameValueCollection.Count + 1;

            // Act
            TestNameValueCollection.AddIfNotNull(key, value);

            // Assert
            Assert.That(TestNameValueCollection.Count == expectedDictLength);
            Assert.That(TestNameValueCollection[key] == value);
        }
예제 #8
0
        public Task <Report> BankStatementAsync(Guid account, DateTime?from = null, DateTime?to = null)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("bankAccountID", account);
            parameters.AddIfNotNull("fromDate", from);
            parameters.AddIfNotNull("toDate", to);

            var endpoint = AddParameters(parameters);

            return(endpoint.FindAsync(NamedReportType.BankStatement.ToString()));
        }
        /// <summary>
        /// Gets the instant mix URL.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="type">The type.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.ArgumentNullException">
        /// query
        /// or
        /// type
        /// </exception>
        protected Uri GetInstantMixUrl(SimilarItemsQuery query, string type)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }
            if (string.IsNullOrEmpty(type))
            {
                throw new ArgumentNullException("type");
            }

            var dict = new NameValueCollection {
            };

            dict.AddIfNotNull("Limit", query.Limit);
            dict.AddIfNotNullOrEmpty("UserId", query.UserId);

            if (query.Fields != null)
            {
                dict.Add("fields", query.Fields.Select(f => f.ToString()));
            }

            if (string.IsNullOrEmpty(query.Id))
            {
                throw new ArgumentNullException("query");
            }

            return(GetApiUrl(new Uri(type + "/" + query.Id + "/InstantMix", UriKind.Relative), dict));
        }
예제 #10
0
        public Task <Report> ExecutiveSummaryAsync(DateTime?date = null)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("date", date);

            var endpoint = AddParameters(parameters);

            return(endpoint.FindAsync(NamedReportType.ExecutiveSummary.ToString()));
        }
예제 #11
0
        public Task <Report> TenNinetyNineAsync(DateTime?year)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("reportYear", year?.Year);

            var endpoint = AddParameters(parameters);

            return(endpoint.FindAsync(NamedReportType.TenNinetyNine.ToString()));
        }
        public async Task <Attachment> AddOrReplaceAsync(Attachment attachment, AttachmentEndpointType type, Guid parent, bool includeOnline = false)
        {
            var mimeType = MimeTypes.GetMimeType(attachment.FileName);

            var url = $"{_endpointBase}/{type}/{parent:D}/Attachments/{attachment.FileName}";

            var parameters = new NameValueCollection();

            if (SupportsOnline(type) && includeOnline)
            {
                parameters.AddIfNotNull("IncludeOnline", true);
            }

            var result = await Client.PostAsync <Attachment, AttachmentsResponse>(url, attachment.Content, mimeType, parameters).ConfigureAwait(false);

            return(result.FirstOrDefault());
        }
예제 #13
0
        public async Task <Attachment> AddOrReplaceAsync(Attachment attachment, AttachmentEndpointType type, Guid parent, bool includeOnline = false)
        {
            var mimeType = MimeTypes.GetMimeType(attachment.FileName);

            var url = string.Format("/api.xro/2.0/{0}/{1}/Attachments/{2}", type, parent.ToString("D"), attachment.FileName);

            var parameters = new NameValueCollection();

            if (SupportsOnline(type) && includeOnline)
            {
                parameters.AddIfNotNull("IncludeOnline", true);
            }

            var result = await Client.PostAsync <Attachment, AttachmentsResponse>(url, attachment.Content, mimeType, parameters);

            return(result.FirstOrDefault());
        }
예제 #14
0
        public Task <Report> BalanceSheetAsync(DateTime date, Guid?tracking1 = null, Guid?tracking2     = null,
                                               bool standardLayout           = false, bool?paymentsOnly = null, string timeframe = null, int?periods = null)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("date", date);
            parameters.AddIfNotNull("trackingOptionID1", tracking1);
            parameters.AddIfNotNull("trackingOptionID2", tracking2);
            parameters.AddIfNotNull("standardLayout", standardLayout);
            parameters.AddIfNotNull("paymentsOnly", paymentsOnly);
            parameters.AddIfNotNull("timeframe", timeframe);
            parameters.AddIfNotNull("periods", periods);

            var endpoint = AddParameters(parameters);

            return(endpoint.FindAsync(NamedReportType.BalanceSheet.ToString()));
        }
        /// <summary>
        /// Gets the image URL.
        /// </summary>
        /// <param name="baseUrl">The base URL.</param>
        /// <param name="options">The options.</param>
        /// <param name="queryParams">The query params.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.ArgumentNullException">options</exception>
        private Uri GetImageUrl(Uri baseUrl, ImageOptions options, NameValueCollection queryParams)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            if (queryParams == null)
            {
                throw new ArgumentNullException("queryParams");
            }

            if (options.ImageIndex.HasValue)
            {
                baseUrl = new Uri(baseUrl, "/" + options.ImageIndex.Value);
            }

            queryParams.AddIfNotNull("Width", options.Width);
            queryParams.AddIfNotNull("Height", options.Height);
            queryParams.AddIfNotNull("MaxWidth", options.MaxWidth);
            queryParams.AddIfNotNull("MaxHeight", options.MaxHeight);
            queryParams.AddIfNotNull("Quality", options.Quality ?? ImageQuality);

            queryParams.AddIfNotNullOrEmpty("Tag", options.Tag);

            queryParams.AddIfNotNull("CropWhitespace", options.CropWhitespace);
            queryParams.Add("EnableImageEnhancers", options.EnableImageEnhancers);

            if (options.Format.HasValue)
            {
                queryParams.Add("Format", options.Format.ToString());
            }

            if (options.AddPlayedIndicator)
            {
                queryParams.Add("AddPlayedIndicator", true);
            }
            queryParams.AddIfNotNull("PercentPlayed", options.PercentPlayed);
            queryParams.AddIfNotNullOrEmpty("BackgroundColor", options.BackgroundColor);

            return(GetApiUrl(baseUrl, queryParams));
        }
        /// <summary>
        /// Creates a url to return a list of items
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.ArgumentNullException">query</exception>
        protected Uri GetItemListUrl(ItemQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            var dict = new NameValueCollection {
            };

            dict.AddIfNotNullOrEmpty("ParentId", query.ParentId);

            dict.AddIfNotNull("StartIndex", query.StartIndex);

            dict.AddIfNotNull("Limit", query.Limit);

            dict.AddIfNotNull("SortBy", query.SortBy);

            if (!query.EnableTotalRecordCount)
            {
                dict.Add("EnableTotalRecordCount", query.EnableTotalRecordCount);
            }

            if (query.SortOrder.HasValue)
            {
                dict["sortOrder"] = query.SortOrder.ToString();
            }

            if (query.SeriesStatuses != null)
            {
                dict.Add("SeriesStatuses", query.SeriesStatuses.Select(f => f.ToString()));
            }

            if (query.Fields != null)
            {
                dict.Add("fields", query.Fields.Select(f => f.ToString()));
            }
            if (query.Filters != null)
            {
                dict.Add("Filters", query.Filters.Select(f => f.ToString()));
            }
            if (query.ImageTypes != null)
            {
                dict.Add("ImageTypes", query.ImageTypes.Select(f => f.ToString()));
            }

            dict.AddIfNotNull("Is3D", query.Is3D);
            if (query.VideoTypes != null)
            {
                dict.Add("VideoTypes", query.VideoTypes.Select(f => f.ToString()));
            }
            if (query.AirDays != null)
            {
                dict.Add("AirDays", query.AirDays.Select(f => f.ToString()));
            }

            dict.AddIfNotNullOrEmpty("MinOfficialRating", query.MinOfficialRating);
            dict.AddIfNotNullOrEmpty("MaxOfficialRating", query.MaxOfficialRating);

            dict.Add("recursive", query.Recursive);

            dict.AddIfNotNull("MinIndexNumber", query.MinIndexNumber);

            dict.AddIfNotNull("EnableImages", query.EnableImages);
            if (query.EnableImageTypes != null)
            {
                dict.Add("EnableImageTypes", query.EnableImageTypes.Select(f => f.ToString()));
            }
            dict.AddIfNotNull("ImageTypeLimit", query.ImageTypeLimit);
            dict.AddIfNotNull("CollapseBoxSetItems", query.CollapseBoxSetItems);
            dict.AddIfNotNull("MediaTypes", query.MediaTypes);
            dict.AddIfNotNull("Genres", query.Genres, "|");
            dict.AddIfNotNull("Ids", query.Ids);
            dict.AddIfNotNull("StudioIds", query.StudioIds, "|");
            dict.AddIfNotNull("ExcludeItemTypes", query.ExcludeItemTypes);
            dict.AddIfNotNull("IncludeItemTypes", query.IncludeItemTypes);
            dict.AddIfNotNull("ArtistIds", query.ArtistIds);

            dict.AddIfNotNull("IsPlayed", query.IsPlayed);
            dict.AddIfNotNull("IsInBoxSet", query.IsInBoxSet);

            dict.AddIfNotNull("PersonIds", query.PersonIds);
            dict.AddIfNotNull("PersonTypes", query.PersonTypes);

            dict.AddIfNotNull("Years", query.Years);

            dict.AddIfNotNull("ParentIndexNumber", query.ParentIndexNumber);
            dict.AddIfNotNull("IsHD", query.IsHD);
            dict.AddIfNotNull("HasParentalRating", query.HasParentalRating);

            dict.AddIfNotNullOrEmpty("SearchTerm", query.SearchTerm);

            dict.AddIfNotNull("MinCriticRating", query.MinCriticRating);
            dict.AddIfNotNull("MinCommunityRating", query.MinCommunityRating);

            dict.AddIfNotNull("MinPlayers", query.MinPlayers);
            dict.AddIfNotNull("MaxPlayers", query.MaxPlayers);
            dict.AddIfNotNullOrEmpty("NameStartsWithOrGreater", query.NameStartsWithOrGreater);
            dict.AddIfNotNullOrEmpty("AlbumArtistStartsWithOrGreater", query.AlbumArtistStartsWithOrGreater);

            if (query.LocationTypes != null && query.LocationTypes.Length > 0)
            {
                dict.Add("LocationTypes", query.LocationTypes.Select(f => f.ToString()));
            }
            if (query.ExcludeLocationTypes != null && query.ExcludeLocationTypes.Length > 0)
            {
                dict.Add("ExcludeLocationTypes", query.ExcludeLocationTypes.Select(f => f.ToString()));
            }

            dict.AddIfNotNull("IsMissing", query.IsMissing);
            dict.AddIfNotNull("IsUnaired", query.IsUnaired);
            dict.AddIfNotNull("IsVirtualUnaired", query.IsVirtualUnaired);

            dict.AddIfNotNull("AiredDuringSeason", query.AiredDuringSeason);

            return(GetApiUrl(new Uri("Users/" + query.UserId + "/Items", UriKind.Relative), dict));
        }
예제 #17
0
        public Task <Report> ProfitAndLossAsync(DateTime?date, DateTime?from = null, DateTime?to         = null,
                                                Guid?trackingCategory        = null, Guid?trackingOption = null, Guid?trackingCategory2 = null,
                                                Guid?trackingOption2         = null, bool?standardLayout = null, bool?paymentsOnly      = null, string timeframe = null, int?periods = null)
        {
            var parameters = new NameValueCollection();

            parameters.AddIfNotNull("date", date);
            parameters.AddIfNotNull("fromDate", from);
            parameters.AddIfNotNull("toDate", to);
            parameters.AddIfNotNull("trackingCategoryID", trackingCategory);
            parameters.AddIfNotNull("trackingOptionID", trackingOption);
            parameters.AddIfNotNull("trackingCategoryID2", trackingCategory2);
            parameters.AddIfNotNull("trackingOptionID2", trackingOption2);
            parameters.AddIfNotNull("standardLayout", standardLayout);
            parameters.AddIfNotNull("paymentsOnly", paymentsOnly);
            parameters.AddIfNotNull("timeframe", timeframe);
            parameters.AddIfNotNull("periods", periods);

            var endpoint = AddParameters(parameters);

            return(endpoint.FindAsync(NamedReportType.ProfitAndLoss.ToString()));
        }