public async Task UpdatePrice() { System.IO.Stream stream = GetRequestStub("V3.requestStub.priceBulkUpdate"); ItemPriceResponse result = await priceApi.UpdatePrice(stream); Assert.IsType <ItemPriceResponse>(result); Assert.NotEmpty(result.Message); Assert.NotEmpty(result.Sku); }
public async Task UpdatePrice() { ItemPriceResponse result = await priceApi.UpdatePrice("test", "USD", 400.0); Assert.IsType <ItemPriceResponse>(result); Assert.NotEmpty(result.Amount); Assert.NotEmpty(result.Message); Assert.NotEmpty(result.Sku); }
public async Task UpdateSinglePromotion() { System.IO.Stream stream = GetRequestStub("V3.requestStub.updatePromotion"); ItemPriceResponse result = await promotionApi.UpdatePromotionPrice(stream); Assert.IsType <ItemPriceResponse>(result); Assert.True(result.Mart.Length > 0); Assert.True(result.Sku.Length > 0); Assert.True(result.Message.Length > 0); }
public async Task CanUpdatePriceForSpecificItem() { var amount = 99990.0; var currency = "USD"; var sku = "NETSDK_TEST"; ItemPriceResponse result = await priceApi.UpdatePrice(sku, currency, amount); Assert.IsType <ItemPriceResponse>(result); Assert.Equal(sku, result.Sku); }
public async Task CanUpdatePriceForSpecificSku() { var sku = "NETSDK_TEST"; using (Stream stream = GetRequestContentForPriceUpdate(sku, 400.00, "USD")) { ItemPriceResponse result = await priceApi.UpdatePrice(stream); Assert.IsType <ItemPriceResponse>(result); Assert.True(result.Sku == sku); } }
public async Task <ItemPriceResponse> UpdatePromotionPrice(Stream stream) { // to avoid deadlock if this method is executed synchronously await new ContextRemover(); Base.Http.Request request = CreateRequest(); request.EndpointUri = "/v3/price?promo=true"; var payload = new StreamReader(stream).ReadToEnd(); request.HttpRequest.Content = new StringContent(payload); //set the headers to avoid broken responses because of encodding=utf-8 request.HttpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(request.GetContentType()); Base.Http.IResponse response = await client.PutAsync(request); ItemPriceResponse result = await ProcessResponse <ItemPriceResponse>(response); return(result); }
public async Task <ItemPriceResponse> UpdatePrice(string sku, string currency, double price) { // to avoid deadlock if this method is executed synchronously await new ContextRemover(); Base.Http.Request request = CreateRequest(); request.EndpointUri = "/v2/prices"; request.QueryParams.Add("sku", sku); request.QueryParams.Add("currency", currency); request.QueryParams.Add("price", price.ToString()); request.HttpRequest.Content = new StringContent(""); request.HttpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(request.GetContentType()); Base.Http.IResponse response = await client.PutAsync(request); ItemPriceResponse result = await ProcessResponse <ItemPriceResponse>(response); return(result); }
public async Task GetPromotionForSingleSku() { ItemResponses oneItemList = await itemApi.GetAllItems(1, 10); var sku = oneItemList.ItemResponse[0].Sku; ServiceResponse result = await promotionApi.GetPromotionPrice(sku); Assert.IsType <ServiceResponse>(result); Assert.True(result.Status.Equals(Status.OK)); var textWriter = new StringWriter(); xmlSerializer.Serialize(textWriter, result); var str = textWriter.ToString(); var payload = GetPayloadForDelete(str, sku); Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(payload)); ItemPriceResponse result1 = await promotionApi.UpdatePromotionPrice(stream); Assert.IsType <ItemPriceResponse>(result1); }
public async Task <ItemPriceResponse> UpdatePrice(Stream stream) { // to avoid deadlock if this method is executed synchronously await new ContextRemover(); Base.Http.Request request = CreateRequest(); request.EndpointUri = "/v3/price"; var payload = new StreamReader(stream).ReadToEnd(); request.HttpRequest.Content = new StringContent(payload); // have to explicitly set this header for content, otherwise it also has encodding=utf-8 // and it breaks response from API request.HttpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse(request.GetContentType()); Base.Http.IResponse response = await client.PutAsync(request); ItemPriceResponse result = await ProcessResponse <ItemPriceResponse>(response); return(result); }
public async Task CanUpdatePromotionForSpecificSku() { ItemResponses oneItemList = await itemApi.GetAllItems(1, 20); var sku = oneItemList.ItemResponse[0].Sku; //Delete the current promotions if there is any //var result = await promotionApi.GetPromotionPrice(sku); //Assert.IsType<ServiceResponse>(result); //StringWriter textWriter = new StringWriter(); //xmlSerializer.Serialize(textWriter, result); //var str = textWriter.ToString(); //var payload = GetPayloadForDelete(str, sku); using (Stream stream = GetRequestContentForPromotionUpdate(sku, "REDUCED", "DELETE")) { ItemPriceResponse result = await promotionApi.UpdatePromotionPrice(stream); Assert.IsType <ItemPriceResponse>(result); Assert.True(result.Mart.Length > 0); Assert.True(result.Sku == sku); Assert.True(result.Message.Length > 0); } }