private static ClassifierResult CreateClassifierResult(JObject result) { ClassifierResult classifierResult = Newtonsoft.Json.JsonConvert.DeserializeObject <ClassifierResult>(result.ToString()); switch (classifierResult.Type) { case PageType.Article: classifierResult.PageResult = ArticleApi.CreateArticle(result); break; case PageType.FrontPage: classifierResult.PageResult = FrontPageApi.CreateFrontPage(result); break; case PageType.Image: classifierResult.PageResult = ImageApi.CreateImages(result); break; case PageType.Product: classifierResult.PageResult = ProductApi.CreateProduct(result); break; } return(classifierResult); }
public void RunNewProduct(ShopifyNewProductImportContext context) { if (MonsterConfig.Settings.DisableShopifyPut) { _logService.Log(LogBuilder.ShopifyPutDisabled()); return; } var newVariants = CleanAndBuildVariantPayload(context.AcumaticaItemIds); var product = new ProductNew() { title = context.ProductTitle, vendor = context.ProductVendor, product_type = context.ProductType, variants = new List <ShopifyVariantNew>() }; var parent = new { product = product }; product.variants = newVariants; // POST new Product via Shopify API // var result = _productApi.CreateProduct(parent.SerializeToJson()); var resultProduct = result.DeserializeFromJson <ProductParent>(); var shopifyProductId = resultProduct.product.id; // Run ShopifyInventoryGet to pull into local cache // _shopifyInventoryGet.Run(shopifyProductId); var productRecord = _syncInventoryRepository.RetrieveProduct(shopifyProductId); // Execution Log entry // var log = LogBuilder.CreatedShopifyProduct(productRecord); _logService.Log(log); // Create Sync Records for the Variants that were created // foreach (var newVariant in newVariants) { var variantRecord = productRecord.ShopifyVariants.FirstOrDefault(x => x.ShopifySku == newVariant.sku); CreateSyncRecord(newVariant.sku, variantRecord); } // Update Inventory data // foreach (var itemId in context.AcumaticaItemIds) { RunInventoryUpdate(itemId); } }