示例#1
0
        /// <summary>
        /// Alterar Produto - SKU
        /// </summary>
        /// <returns></returns>
        public ProductDetail UpdateProductSKU(string token, string id, string skuId, SkuUpdate sku)
        {
            try
            {
                _logger.LogInformation("Alterar SKU - Produto: Enviando requisição para a API");
                var response = _ProductApi.UpdateProductSKU(token, id, skuId, sku).Result;
                if (!response.IsSuccessStatusCode)
                {
                    var contentResult = response.Content.ReadAsStringAsync().Result;
                    _logger.LogError($"Alterar SKU - Produto: API retornou erro :( - {response.StatusCode}-{response.ReasonPhrase} -> {contentResult}");
                    if (((int)response.StatusCode) >= 400 && ((int)response.StatusCode) < 500)
                    {
                        return(null);
                    }
                }
                _logger.LogInformation("Alterar SKU - Produto: API retornou sucesso :)");

                var json = response.Content.ReadAsStringAsync().Result;
                return(Task.Factory.StartNew(() => JsonConvert.DeserializeObject <ProductDetail>(json)).Result);
            }
            catch (Exception)
            {
                _logger.LogError($"Alterar SKU - Produto: API retornou erro :(");
                return(null);
            }
        }
示例#2
0
        static void UpdateProductQty()
        {
            var magento = new Magento(baseUrl, Token);

            var update_this_sku = new SkuUpdate();

            var sku = new StockItem();

            sku.Qty       = 6396;
            sku.ItemId    = 1;
            sku.IsInStock = true;

            update_this_sku.StockItem = sku;

            var result = magento.UpdateProductQty(update_this_sku, "ProductOne");
        }
示例#3
0
        /// <summary>
        /// Alterar Produto - SKU
        /// </summary>
        /// <returns></returns>
        public async Task <HttpResponseMessage> UpdateProductSKUFreight(string token, string id, string skuId, SkuUpdate sku)
        {
            _client             = new HttpClient();
            _client.BaseAddress = AppSettings.Apis.ProductApi;
            _client.DefaultRequestHeaders.Accept.Clear();
            _client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            return(await new HttpClientHelper(_client)
                   .SetEndpoint($"products/{id}/sku/{skuId}/freight")
                   .AddHeader("Authorization", $"Bearer {token}")
                   .WithContentSerialized(sku)
                   .PutAsync());
        }