public void ReviseInventoriesStatusAsync_EbayServiceWithFixedPriceProductsWithoutVariations_ProductsUpdated() { //------------ Arrange var ebayService = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //------------ Act var updateProductsAsyncTask1 = ebayService.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest> { new InventoryStatusRequest { ItemId = ExistingProducts.FixedPrice1WithoutVariations.ItemId, Quantity = ExistingProducts.FixedPrice1WithoutVariations.Quantity + this.QtyUpdateFor }, new InventoryStatusRequest { ItemId = ExistingProducts.FixedPrice2WithoutVariations.ItemId, Quantity = ExistingProducts.FixedPrice2WithoutVariations.Quantity + this.QtyUpdateFor }, }); updateProductsAsyncTask1.Wait(); var updateProductsAsyncTask2 = ebayService.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest> { ExistingProducts.FixedPrice1WithoutVariations, ExistingProducts.FixedPrice2WithoutVariations, }); updateProductsAsyncTask2.Wait(); //------------ Assert updateProductsAsyncTask1.Result.ToList().TrueForAll(x => x.Items.Count == 2); updateProductsAsyncTask2.Result.ToList().TrueForAll(x => x.Items.Count == 2); }
public void GetSaleRecordsNumbers_ResponseTooksTooLongTime_Exception() { //------------ Arrange var service = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); service.DelayForMethod["GetSaleRecordsNumbersAsync"] = 25500; var saleNumbers = new List <string>(); var existingSaleNumbersArray = ExistingOrdersIds.SaleNumers.ToArray(); for (var i = 0; i < 1000; i++) { saleNumbers.Add(existingSaleNumbersArray[i % existingSaleNumbersArray.Length]); } //------------ Act Action act = () => { var ordersIdsAsync = service.GetSaleRecordsNumbersAsync(saleNumbers.ToArray()); ordersIdsAsync.Wait(); }; //------------ Assert act.ShouldThrow <Exception>(); }
private async Task <Items> GetEbayInformations(string call) { EbayService service = new EbayService(); var output = await service.GetEbayCall(call); return(output); }
public void UpdateInventoryAsync_Update2itemsOneOfThemDoesNotExist_ExceptionOccured(UpdateInventoryAlgorithm updateInventoryAlgorithm) { //------------ Arrange var ebayService = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //------------ Act var updateInventoryRequestExistingItem = new UpdateInventoryRequest { ItemId = ExistingProducts.FixedPrice1WithoutVariations.ItemId, Sku = ExistingProducts.FixedPrice1WithoutVariations.Sku, Quantity = 0 }; var updateInventoryRequestNotExistingItem = new UpdateInventoryRequest { ItemId = 0000, Sku = ExistingProducts.FixedPrice1WithVariation1.Sku + "qwe", Quantity = 0 }; var updateProductsAsyncTask1 = ebayService.UpdateInventoryAsync(new List <UpdateInventoryRequest> { updateInventoryRequestNotExistingItem, updateInventoryRequestExistingItem, }, updateInventoryAlgorithm); var resp = Enumerable.Empty <UpdateInventoryResponse>(); Action act = () => { updateProductsAsyncTask1.Wait(); resp = updateProductsAsyncTask1.Result.ToList(); }; //------------ Assert act.ShouldThrow <Exception>(); }
public ActionResult Ebay(string username, string sid) { using (var repository = new TradelrRepository()) { var odb = repository.GetOAuthToken(sid, OAuthTokenType.EBAY); if (odb == null) { throw new Exception("Could not locate ebay token entry"); } try { var ebayservice = new EbayService(); var token = ebayservice.GetToken(odb.token_key); odb.token_key = token; odb.token_secret = ""; odb.guid = username; odb.authorised = true; odb.expires = ebayservice.TokenExpires; repository.Save(); // sync with ebay var ebay = new NetworksEbay(odb.MASTERsubdomain.id); new Thread(() => ebay.StartSynchronisation(false)).Start(); } catch (Exception ex) { Syslog.Write(ex); } return(Redirect(odb.MASTERsubdomain.ToHostName().ToDomainUrl("/dashboard/networks#ebay"))); } }
public void GetActiveProductsAsync_ServiceWithExistingProductsCancellationTokenCancelled_ReturnPartOfProductsOrEmptyCollectionImmidiatelly() { //------------ Arrange var ebayService = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigProduction()); var sw1 = Stopwatch.StartNew(); var inventoryStatTask1 = ebayService.GetActiveProductsAsync(CancellationToken.None); inventoryStatTask1.Wait(); var products1 = inventoryStatTask1.Result; sw1.Stop(); var cts = new CancellationTokenSource(( int )(sw1.ElapsedMilliseconds * 0.5)); var ct = cts.Token; //------------ Act var sw2 = Stopwatch.StartNew(); var inventoryStat1Task = ebayService.GetActiveProductsAsync(ct); inventoryStat1Task.Wait(); var products2 = inventoryStat1Task.Result; sw2.Stop(); //------------ Assert var products2List = products2 as IList <Item> ?? products2.ToList(); var products1List = products1 as IList <Item> ?? products1.ToList(); products2List.Count().Should().BeLessThan(products1List.Count(), "because on site there are items"); products2List.Count().Should().BeGreaterThan(0, "because on site there are items"); sw2.ElapsedMilliseconds.Should().BeLessThan(sw1.ElapsedMilliseconds, "because on site there are items"); Debug.WriteLine("products1 {0}, t:{1}", products1List.Count(), sw1.Elapsed.ToString()); Debug.WriteLine("products2 {0}, t:{1}", products2List.Count(), sw2.Elapsed.ToString()); }
static void Main(string[] args) { var ebayService = new EbayService(); var token = ConfigurationManager.AppSettings["UserAccount_SmartHub1.ApiToken"]; var isConnected = ebayService.IsConnected(token); Console.WriteLine("isConnected : " + isConnected); GetTokenStatus(ebayService, token); GetMemberMessage(ebayService, token, new DateTime(2017, 5, 1), DateTime.UtcNow, MessageTypeCodeType.All, MessageStatusTypeCodeType.Unanswered); }
public void GetOrdersAsync_ServiceWithExistingOrdersInSpecifiedTimeRange_HookupOrders() { //------------ Arrange var service = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //------------ Act var ordersTask = service.GetOrdersAsync(DateTime.Now.AddMonths(0).AddDays(-29), DateTime.Now.AddMonths(0)); ordersTask.Wait(); //------------ Assert ordersTask.Result.Count().Should().BeGreaterThan(0, "because on site there are orders"); }
public void GetOrdersIds_ServiceWithNotExistingOrders_HookupZeroOrdersIds() { //------------ Arrange var service = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //------------ Act var ordersIdsAsync = service.GetOrdersIdsAsync(NotExistingBecauseOfCombinedOrdersIds.OrdersIds.ToArray()); ordersIdsAsync.Wait(); //------------ Assert ordersIdsAsync.Result.Count().Should().Be(0); }
public void GetSaleRecordsNumbers_ServiceWithExistingOrders_HookupOrdersIds() { //------------ Arrange var service = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //------------ Act var ordersIdsAsync = service.GetSaleRecordsNumbersAsync(ExistingOrdersIds.SaleNumers.ToArray()); ordersIdsAsync.Wait(); //------------ Assert ordersIdsAsync.Result.Should().BeEquivalentTo(ExistingOrdersIds.SaleNumers.ToArray()); }
static void GetTokenStatus(EbayService service, string token) { var result = service.GetTokenStatus(token); if (result.HasError) { Console.WriteLine("GetTokenStatus : " + result.Error); } else { Console.WriteLine("GetTokenStatus : " + result.Result.ExpirationTime); } }
public void ReviseInventoriesStatusAsync_EbayServiceWithNonVariationFixedPriceItems_QuantityUpdatedForAll() { //A var ebayServiceLowLevel = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); var ebayService = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); var temp1 = ebayService.GetActiveProductsAsync(CancellationToken.None, true); temp1.Wait(); var activeProducts = temp1.Result.Where(x => !x.IsItemWithVariations()).ToList(); var activeProductWithoutVariations1 = activeProducts.Skip(0).First(); var activeProductWithoutVariations2 = activeProducts.Skip(1).First(); //A var updateProductsAsyncTask1 = ebayServiceLowLevel.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest> { new InventoryStatusRequest { ItemId = activeProductWithoutVariations1.ItemId.ToLongOrDefault(), Quantity = activeProductWithoutVariations1.Quantity + this.QtyUpdateFor }, new InventoryStatusRequest { ItemId = activeProductWithoutVariations2.ItemId.ToLongOrDefault(), Quantity = activeProductWithoutVariations2.Quantity + this.QtyUpdateFor }, }, new Guid().ToString()); updateProductsAsyncTask1.Wait(); var updateProductsAsyncTask2 = ebayServiceLowLevel.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest> { new InventoryStatusRequest { ItemId = activeProductWithoutVariations1.ItemId.ToLongOrDefault(), Quantity = activeProductWithoutVariations1.Quantity }, new InventoryStatusRequest { ItemId = activeProductWithoutVariations2.ItemId.ToLongOrDefault(), Quantity = activeProductWithoutVariations2.Quantity }, }, new Guid().ToString()); updateProductsAsyncTask2.Wait(); //A updateProductsAsyncTask1.Result.ToList().TrueForAll(x => x.Items.Count == 2).Should().Be(true); updateProductsAsyncTask2.Result.ToList().TrueForAll(x => x.Items.Count == 2).Should().Be(true); var item1Update1 = updateProductsAsyncTask1.Result.ToList().First().Items.Where(x => x.ItemId == activeProductWithoutVariations1.ItemId.ToLongOrDefault(false)).First(); var item1Update2 = updateProductsAsyncTask2.Result.ToList().First().Items.Where(x => x.ItemId == activeProductWithoutVariations1.ItemId.ToLongOrDefault(false)).First(); var item2Update1 = updateProductsAsyncTask1.Result.ToList().First().Items.Where(x => x.ItemId == activeProductWithoutVariations2.ItemId.ToLongOrDefault(false)).First(); var item2Update2 = updateProductsAsyncTask2.Result.ToList().First().Items.Where(x => x.ItemId == activeProductWithoutVariations2.ItemId.ToLongOrDefault(false)).First(); (item1Update1.Quantity - item1Update2.Quantity).Should().Be(this.QtyUpdateFor); (item2Update1.Quantity - item2Update2.Quantity).Should().Be(this.QtyUpdateFor); }
public void GetActiveProductsAsync_ServiceWithExistingProducts_HookupProducts() { //------------ Arrange var ebayService = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //------------ Act var inventoryStat1Task = ebayService.GetActiveProductsAsync(CancellationToken.None); inventoryStat1Task.Wait(); var products = inventoryStat1Task.Result; //------------ Assert products.Count().Should().BeGreaterThan(0, "because on site there are items"); }
static void GetMemberMessage(EbayService service, string token, DateTime from, DateTime to, MessageTypeCodeType messageTypeCodeType, MessageStatusTypeCodeType messageStatusTypeCode) { var result = service.GetMemberMessage(token, from, to, messageTypeCodeType, messageStatusTypeCode); if (result.HasError) { Console.WriteLine("GetMemberMessage : " + result.Error); } else { Console.WriteLine("GetMemberMessage : " + result.Result.Count()); } }
public ActionResult getToken() { var ebayservice = new EbayService(); var requesturl = ebayservice.GetRequestTokenUrl(); var oauthdb = new oauth_token { token_key = ebayservice.SessionID, token_secret = "", type = OAuthTokenType.EBAY.ToString(), subdomainid = subdomainid.Value, appid = sessionid.Value.ToString(), authorised = false }; repository.AddOAuthToken(oauthdb); // need to append ruparameter var parameters = new NameValueCollection { { "sid", ebayservice.SessionID } }; return(Redirect(string.Format(requesturl + "&ruparams={0}", parameters.ToQueryString(true).Substring(1)))); }
public async Task <JsonResult> GetEbay(string id) { EbayService service = new EbayService(serviceProvider, httpService); return(Json(await service.Get(id))); }
public Startup(IConfiguration configuration) { Configuration = configuration; EbayService.InitializeEbay(); }
public async Task <JsonResult> GetEbay() { EbayService service = new EbayService(serviceProvider, httpService); return(Json(await service.Get(User.Identity as ClaimsIdentity))); }
public void UpdateInventoryAsync_UpdateFixedPriceItemWithVariationsAndNonvariation_NoExceptionOccuredAndResponseNotEmpty(UpdateInventoryAlgorithm algorithm) { //------------ Arrange var ebayService = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); var temp1 = ebayService.GetActiveProductsAsync(CancellationToken.None, true); temp1.Wait(); var activeProducts = temp1.Result.ToList(); var activeProductWithVariations1 = activeProducts.First(x => x.IsItemWithVariations()); var activeProductWithoutVariations1 = activeProducts.First(x => !x.IsItemWithVariations()); //------------ Act //1 var updayeInventoryTask1 = ebayService.UpdateInventoryAsync(new List <UpdateInventoryRequest> { new UpdateInventoryRequest { ItemId = activeProductWithVariations1.ItemId.ToLongOrDefault(false), Sku = activeProductWithVariations1.GetSku().Sku, Quantity = 100500, ConditionID = activeProductWithVariations1.ConditionId, IsVariation = activeProductWithVariations1.IsItemWithVariations() }, new UpdateInventoryRequest { ItemId = activeProductWithoutVariations1.ItemId.ToLongOrDefault(false), Sku = activeProductWithoutVariations1.GetSku().Sku, Quantity = 100500, ConditionID = activeProductWithoutVariations1.ConditionId, IsVariation = activeProductWithoutVariations1.IsItemWithVariations() }, }, algorithm); updayeInventoryTask1.Wait(); var updateInventoryResponse1 = updayeInventoryTask1.Result.ToList(); //2 var temp2 = ebayService.GetActiveProductsAsync(CancellationToken.None, true); temp2.Wait(); activeProducts = temp2.Result.ToList(); var activeProductWithVariations2 = activeProducts.First(x => x.ItemId == activeProductWithVariations1.ItemId && x.GetSku().Sku == activeProductWithVariations1.GetSku().Sku); var activeProductWithoutVariations2 = activeProducts.First(x => x.ItemId == activeProductWithoutVariations1.ItemId && x.GetSku().Sku == activeProductWithoutVariations1.GetSku().Sku); var updateInventoryTask2 = ebayService.UpdateInventoryAsync(new List <UpdateInventoryRequest> { new UpdateInventoryRequest { ItemId = activeProductWithVariations2.ItemId.ToLongOrDefault(false), Sku = activeProductWithVariations2.GetSku().Sku, Quantity = 0, ConditionID = activeProductWithVariations2.ConditionId, IsVariation = activeProductWithVariations2.IsItemWithVariations() }, new UpdateInventoryRequest { ItemId = activeProductWithoutVariations2.ItemId.ToLongOrDefault(false), Sku = activeProductWithoutVariations2.GetSku().Sku, Quantity = 0, ConditionID = activeProductWithoutVariations2.ConditionId, IsVariation = activeProductWithoutVariations2.IsItemWithVariations() }, }, algorithm); updateInventoryTask2.Wait(); var updateInventoryResponse2 = updateInventoryTask2.Result.ToList(); //3 var temp3 = ebayService.GetActiveProductsAsync(CancellationToken.None, true); temp3.Wait(); activeProducts = temp3.Result.ToList(); var activeProductWithVariations3 = activeProducts.First(x => x.ItemId == activeProductWithVariations1.ItemId && x.GetSku().Sku == activeProductWithVariations1.GetSku().Sku); var activeProductWithoutVariations3 = activeProducts.First(x => x.ItemId == activeProductWithoutVariations1.ItemId && x.GetSku().Sku == activeProductWithoutVariations1.GetSku().Sku); //------------ Assert activeProductWithVariations3.GetQuantity().Quantity.Should().Be(0); activeProductWithoutVariations3.GetQuantity().Quantity.Should().Be(0); activeProductWithVariations2.GetQuantity().Quantity.Should().Be(100500); activeProductWithoutVariations2.GetQuantity().Quantity.Should().Be(100500); }