示例#1
0
        private static void ValidateMarketplaceCompatibility(string reportType, IEnumerable <string> requestedMarketplacesIds = null)
        {
            if (requestedMarketplacesIds == null)
            {
                return;
            }

            var permittedMarketplacesIds = ReportsPermittedMarketplacesMapper.GetMarketplaces(reportType)?.Select(m => m.Id) ?? MwsMarketplaceGroup.AmazonGlobal().Select(m => m.Id);

            foreach (var requestedMarketplace in requestedMarketplacesIds)
            {
                if (!permittedMarketplacesIds.Contains(requestedMarketplace))
                {
                    throw new ArgumentException(
                              $@"The report request for type:'{reportType}', is only available to the following marketplaces:'{
								MwsMarketplace.GetMarketplaceCountryCodesAsCommaSeparatedString(permittedMarketplacesIds)
							}'.
The requested marketplace:'{
								MwsMarketplace.GetMarketplaceCountryCode(requestedMarketplace)
							}' is not supported by Amazon MWS for the specified report type"                            );
                }
            }
        }
示例#2
0
        private ReportOptions PopulateReportOptionsWithCustomValue(ReportOptions reportOptions, bool custom = false, IEnumerable <MwsMarketplace> requestedMarketplaces = null)
        {
            if (custom && requestedMarketplaces != null)
            {
                var acceptedMarketplaceIdsForCustomOption = new List <string>
                {
                    MwsMarketplace.Canada.Id,
                    MwsMarketplace.US.Id,
                    MwsMarketplace.UK.Id,
                    MwsMarketplace.India.Id
                };
                var nonAcceptedMarketplaceIds = requestedMarketplaces.Select(m => m.Id).Except(acceptedMarketplaceIdsForCustomOption).ToList();

                if (nonAcceptedMarketplaceIds.Any())
                {
                    throw new ArgumentException(
                              $"The 'Custom' option is not available for the following marketplace(s) : {MwsMarketplace.GetMarketplaceCountryCodesAsCommaSeparatedString(nonAcceptedMarketplaceIds)}");
                }
            }

            if (reportOptions == null)
            {
                reportOptions = new ReportOptions();
            }
            reportOptions.AddBooleanOption("custom", custom);

            return(reportOptions);
        }