/** * Perform GET request to get price updates. * * @param marketplace the marketplace from which the products shall be exported Please see {@link ListMarketplaces } for choose available marketplace. * @param id product Id (optional), get an update only for the product with the specified internal product id (SKU). * @param format support Format.JSON and Format.CSV (optional, if don't set, default Format.JSON) * @param pformat_dec support Pformat_dec.INTEGER and Pformat_dec.FLOAT (optional, default Pformat_dec.INTEGER) * @param exportAll support ExportAll.TRUE and ExportAll.FALSE (optional, default Export.TRUE) * @param test support Test.TRUE and Test.FALSE (optional, defautl Test.FALSE) * @return response from monitor price server */ public void GetPriceUpdates(ref String response, String marketplace, String id = null, Format format = Format.JSON, Pformat_dec pformat_dec = Pformat_dec.INTEGER, ExportAll exportAll = ExportAll.TRUE, Test test = Test.FALSE) { CheckMarketplace(marketplace); String fullUrl = BASE_URL + apiKey + PATH_SEPAR + Action.GET_PRICE_UPDATES.ToString().ToLower() + QUERY_BEGIN + GetQuery(marketplace, "marketplace") + GetQuery(id, "id") + GetQuery(format) + GetQuery(pformat_dec) + GetQuery(exportAll) + GetQuery(test); DoRequest(ref response, Method.GET, fullUrl); }
/** * Perform GET request to get product offers.. * * @param marketplace the marketplace from which the products shall be exported Please see {@link ListMarketplaces } for choose available marketplace. * @param format support Format.JSON and Format.CSV (optional, if don't set, default Format.JSON * @param sortBy support SortBy.TOTAL_PRICE, SortBy.SHIPPING_COST, SortBy.RANKING and SortBy.PRICE (optional, default value SortBy.RANKING) * @param offerId return only the offers with the given index after sorting them. If no offeridx is given, it will return all offers * @param productsIds A (possibly comma- separated list of) product IDs whose data is to be exported. If this parameter is not specified, all products will be exported * @param pformat_dec support Pformat_dec.INTEGER and Pformat_dec.FLOAT (optional, default Pformat_dec.INTEGER) * @param exportAll support ExportAll.TRUE and ExportAll.FALSE (optional, default Export.TRUE) * @return response from monitor price server */ public void GetProductOffers(ref String response, String marketplace, Format format = Format.JSON, SortBy sortBy = SortBy.RANKING, int offerId = 0, List <String> productsIds = null, Pformat_dec pformat_dec = Pformat_dec.INTEGER, ExportAll exportAll = ExportAll.TRUE) { CheckMarketplace(marketplace); String products = ConvertListToString(productsIds); String fullUrl = BASE_URL + apiKey + PATH_SEPAR + Action.EXPORT.ToString().ToLower() + QUERY_BEGIN + GetQuery(marketplace, "marketplace") + GetQuery(format) + GetQuery(sortBy) + (offerId > 0 ? GetQuery(offerId, "offeridx") : "") + GetQuery(products, "ids") + GetQuery(pformat_dec) + GetQuery(exportAll); DoRequest(ref response, Method.GET, fullUrl); }
/// <summary> /// Initializes a new instance of the <see cref="ImageEditorViewModel" /> class. /// </summary> /// <param name="imageService">Service for image loading and manipulation.</param> public ImageEditorViewModel(IImageService imageService = null) { _imageService = imageService ?? Locator.Current.GetService <IImageService>(); IObservable <ImageHandle> selectionChanges = this.WhenAnyValue(x => x.SelectedImage).Publish().RefCount(); ImageExplorer = new ImageExplorerViewModel(_source.AsObservableCache()); ImagePreview = new ImagePreviewViewModel(selectionChanges); Settings = new ImageSettingsViewModel(selectionChanges); SelectFolder = new Interaction <string, string>(); LoadImage = ReactiveCommand.CreateFromObservable <string, ImageHandle>(x => _imageService.LoadImage(x)); ExportSelected = ReactiveCommand.CreateFromObservable(ExportSelectedImpl); ExportAll = ReactiveCommand.CreateFromObservable(ExportAllImpl); _calculatePreview = ReactiveCommand.CreateFromObservable <ImageHandle, ImageHandle>(x => _imageService.CalculatePreview(x)); var connection = _source.Connect(); this.WhenActivated(d => { // Dispose handles removed from the source collection connection .DisposeMany() .ObserveOn(RxApp.MainThreadScheduler) .Bind(out _images) .Subscribe() .DisposeWith(d); // Recaluclate image when quality changes connection.WhenPropertyChanged(x => x.ManipulationState.Quality, false) .Throttle(TimeSpan.FromMilliseconds(50)) .Select(x => x.Sender) .InvokeCommand(_calculatePreview) .DisposeWith(d); // Notify about successful export. ExportSelected .Do(name => this.Notify().PublishInfo($"Image export to {name}", "Export completed!", TimeSpan.FromSeconds(3))) .Subscribe() .DisposeWith(d); // Notify about successful export. ExportAll .Do(path => this.Notify().PublishInfo($"All images exported to {path}", "Export completed!", TimeSpan.FromSeconds(3))) .Subscribe() .DisposeWith(d); // Add loaded images to source LoadImage .ObserveOn(RxApp.TaskpoolScheduler) .Where(x => x != null) .SelectMany(x => _calculatePreview.Execute(x)) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(handle => _source.AddOrUpdate(handle)) .DisposeWith(d); // Show image loading error LoadImage.ThrownExceptions .OfType <ImageLoadingException>() .Subscribe(ex => this.Notify() .PublishError($"Sorry. \"{ex.FilePath}\" does not have a supported file format.", "Error", TimeSpan.FromSeconds(5))) .DisposeWith(d); // Pipe loadings to property Observable.CombineLatest( LoadImage.IsExecuting, ExportSelected.IsExecuting, ExportAll.IsExecuting, _calculatePreview.IsExecuting, (a, b, c, d) => a || b || c || d) .ObserveOn(RxApp.MainThreadScheduler) .ToPropertyEx(this, x => x.IsLoading) .DisposeWith(d); // React on close requests from explorer view this.WhenAnyObservable(x => x.ImageExplorer.DeletionRequests) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => _source.Remove(x)) .DisposeWith(d); // Select explorer item this.WhenAnyObservable(x => x.ImageExplorer.Selections) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => SelectedImage = x) .DisposeWith(d); }); }