public TrendYolProductResponse updateTrendyolProductPriceandStock(TrendYolProductPriceandStock trendyolProductPriceandStockRequest) { TrendYolProductPriceandStockItem productPriceandStockItem = new TrendYolProductPriceandStockItem(); productPriceandStockItem.barcode = "111111111"; productPriceandStockItem.listPrice = 100; productPriceandStockItem.salePrice = 90; productPriceandStockItem.quantity = 5; trendyolProductPriceandStockRequest.items = new List <TrendYolProductPriceandStockItem>(); trendyolProductPriceandStockRequest.items.Add(productPriceandStockItem); CreateAuthorization authorization = new CreateAuthorization(trendyolProductPriceandStockRequest.authorization.apiKey, trendyolProductPriceandStockRequest.authorization.apiSecret); var client = new RestClient(string.Format(TrendYolEndPoints.trendyolUpdateProductandStockEndpoint, trendyolProductPriceandStockRequest.authorization.SupplierID)); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Basic " + authorization.basicAuthorization); request.AddHeader("Content-Type", "application/json"); string jsondata = JsonConvert.SerializeObject(trendyolProductPriceandStockRequest.items); request.AddParameter("application/json", JsonConvert.SerializeObject(trendyolProductPriceandStockRequest), ParameterType.RequestBody); IRestResponse response = client.Execute(request); TrendYolProductResponse deserializedTrendYolResponse = JsonConvert.DeserializeObject <TrendYolProductResponse>(response.Content); return(deserializedTrendYolResponse); }
public TrendYolProductResponse sendTrendyolOneVariantProduct(TrendYolProduct trendyolProductRequest) { Item trendyolProduct = new Item(); trendyolProduct.barcode = "111111111"; trendyolProduct.title = "Deneme Ürünü"; trendyolProduct.productMainId = "1234BT"; trendyolProduct.brandId = 1791; trendyolProduct.categoryId = 411; trendyolProduct.quantity = 1; trendyolProduct.stockCode = "DNMURUN"; trendyolProduct.dimensionalWeight = 1; trendyolProduct.description = "Deneme Ürünü"; trendyolProduct.currencyType = "TRY"; trendyolProduct.listPrice = 100; trendyolProduct.salePrice = 98; trendyolProduct.cargoCompanyId = 10; Image image = new Image(); image.url = "https://n11scdn.akamaized.net/a1/org/ev-yasam/biblo/kucuk-urun-fotograf-cekme-oda-studyosu__1205962196402350.jpg"; trendyolProduct.images = new List <Image>(); trendyolProduct.images.Add(image); trendyolProduct.vatRate = 18; DTO.TrendYol.Attribute attribute = new DTO.TrendYol.Attribute(); attribute.attributeId = 338; attribute.attributeValueId = 6980; trendyolProduct.attributes = new List <DTO.TrendYol.Attribute>(); trendyolProduct.attributes.Add(attribute); TrendYolProduct product = new TrendYolProduct(); product.itemList = new DTO.TrendYol.Items(); product.itemList.items = new List <Item>(); product.itemList.items.Add(trendyolProduct); CreateAuthorization authorization = new CreateAuthorization(trendyolProductRequest.authorization.apiKey, trendyolProductRequest.authorization.apiSecret); var client = new RestClient(string.Format(TrendYolEndPoints.trendyolProductCreateEndPoint, trendyolProductRequest.authorization.SupplierID)); client.Timeout = -1; var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Basic " + authorization.basicAuthorization); request.AddHeader("Content-Type", "application/json"); string jsondata = JsonConvert.SerializeObject(product.itemList); jsondata = "{\"items\"" + jsondata.ToString() + "}"; request.AddParameter("application/json", JsonConvert.SerializeObject(product.itemList), ParameterType.RequestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); TrendYolProductResponse deserializedTrendTolResponse = JsonConvert.DeserializeObject <TrendYolProductResponse>(response.Content); return(deserializedTrendTolResponse); }