def from_dict(obj: Any) -> 'Extra': assert isinstance(obj, dict) total_items = from_int(obj.get("totalItems")) page = from_int(obj.get("page")) page_size = from_int(obj.get("pageSize")) price_ranges = from_list(PriceRange.from_dict, obj.get("priceRanges")) return Extra(total_items, page, page_size, price_ranges)
def to_dict(self) -> dict: result: dict = {} result["id"] = from_int(self.id) result["code"] = from_str(self.code) result["name"] = from_str(self.name) result["level"] = from_int(self.level) result["parentId"] = from_int(self.parent_id) return result
def to_dict(self) -> dict: result: dict = {} result["totalItems"] = from_int(self.total_items) result["page"] = from_int(self.page) result["pageSize"] = from_int(self.page_size) result["priceRanges"] = from_list(lambda x: to_class(PriceRange, x), self.price_ranges) return result
def from_dict(obj: Any) -> 'Category': assert isinstance(obj, dict) id = from_int(obj.get("id")) code = from_str(obj.get("code")) name = from_str(obj.get("name")) level = from_int(obj.get("level")) parent_id = from_int(obj.get("parentId")) return Category(id, code, name, level, parent_id)
def to_dict(self) -> dict: result: dict = {} result["channel"] = to_enum(Channel, self.channel) result["terminal"] = to_enum(Terminal, self.terminal) result["finalPrice"] = from_int(self.final_price) result["promotionPrice"] = from_none(self.promotion_price) result["bestPrice"] = from_int(self.best_price) result["flashSalePrice"] = from_none(self.flash_sale_price) return result
def to_dict(self) -> dict: result: dict = {} result["sku"] = from_str(self.sku) result["quantity"] = from_int(self.quantity) result["priority"] = from_int(self.priority) result["name"] = from_str(self.name) result["displayName"] = from_none(self.display_name) result["url"] = from_none(self.url) result["imageUrl"] = from_none(self.image_url) return result
def from_dict(obj: Any) -> 'BundleProduct': assert isinstance(obj, dict) sku = from_str(obj.get("sku")) quantity = from_int(obj.get("quantity")) priority = from_int(obj.get("priority")) name = from_str(obj.get("name")) display_name = from_none(obj.get("displayName")) url = from_none(obj.get("url")) image_url = from_none(obj.get("imageUrl")) return BundleProduct(sku, quantity, priority, name, display_name, url, image_url)
def to_dict(self) -> dict: result: dict = {} result["sku"] = from_str(self.sku) result["name"] = from_str(self.name) result["url"] = from_str(self.url) result["seller"] = to_class(Seller, self.seller) result["brand"] = to_class(Brand, self.brand) result["status"] = to_class(Status, self.status) result["objective"] = to_class(Brand, self.objective) result["productType"] = to_class(Brand, self.product_type) result["images"] = from_list(lambda x: to_class(Image, x), self.images) result["price"] = to_class(Price, self.price) result["productLine"] = to_class(Brand, self.product_line) result["stocks"] = from_list(lambda x: x, self.stocks) result["totalAvailableByStores"] = from_list( lambda x: to_class(TotalAvailableByStore, x), self.total_available_by_stores) result["totalAvailable"] = from_int(self.total_available) result["isBundle"] = from_bool(self.is_bundle) result["bundleProducts"] = from_union([ from_none, lambda x: from_list(lambda x: to_class(BundleProduct, x), x) ], self.bundle_products) result["parentBundles"] = from_union([ lambda x: from_list(lambda x: to_class(ParentBundle, x), x), from_none ], self.parent_bundles) result["totalAvailableByStocks"] = from_list( lambda x: to_class(TotalAvailableByStock, x), self.total_available_by_stocks) result["serialGenerated"] = from_bool(self.serial_generated) result["serialManaged"] = from_bool(self.serial_managed) result["displayName"] = from_str(self.display_name) result["color"] = to_class(Brand, self.color) result["tags"] = from_list(lambda x: x, self.tags) result["promotionPrices"] = from_list( lambda x: to_class(PromotionPrice, x), self.promotion_prices) result["promotions"] = from_list(lambda x: x, self.promotions) result["flashSales"] = from_list(lambda x: x, self.flash_sales) result["attributeSet"] = to_class(AttributeSet, self.attribute_set) result["categories"] = from_list(lambda x: to_class(Category, x), self.categories) result["sellerCategories"] = from_list(lambda x: to_class(Category, x), self.seller_categories) result["magentoId"] = from_int(self.magento_id) result["seoInfo"] = to_class(SEOInfo, self.seo_info) result["rating"] = to_class(Rating, self.rating) result["allActiveFlashSales"] = from_list(lambda x: x, self.all_active_flash_sales) return result
def from_dict(obj: Any) -> 'Product': assert isinstance(obj, dict) sku = from_str(obj.get("sku")) name = from_str(obj.get("name")) url = from_str(obj.get("url")) seller = Seller.from_dict(obj.get("seller")) brand = Brand.from_dict(obj.get("brand")) status = Status.from_dict(obj.get("status")) objective = Brand.from_dict(obj.get("objective")) product_type = Brand.from_dict(obj.get("productType")) images = from_list(Image.from_dict, obj.get("images")) price = Price.from_dict(obj.get("price")) product_line = Brand.from_dict(obj.get("productLine")) stocks = from_list(lambda x: x, obj.get("stocks")) total_available_by_stores = from_list( TotalAvailableByStore.from_dict, obj.get("totalAvailableByStores")) total_available = from_float(obj.get("totalAvailable")) is_bundle = from_bool(obj.get("isBundle")) bundle_products = from_union( [from_none, lambda x: from_list(BundleProduct.from_dict, x)], obj.get("bundleProducts")) parent_bundles = from_union( [lambda x: from_list(ParentBundle.from_dict, x), from_none], obj.get("parentBundles")) total_available_by_stocks = from_list( TotalAvailableByStock.from_dict, obj.get("totalAvailableByStocks")) serial_generated = from_bool(obj.get("serialGenerated")) serial_managed = from_bool(obj.get("serialManaged")) display_name = from_str(obj.get("displayName")) color = Brand.from_dict(obj.get("color")) tags = from_list(lambda x: x, obj.get("tags")) promotion_prices = from_list(PromotionPrice.from_dict, obj.get("promotionPrices")) promotions = from_list(lambda x: x, obj.get("promotions")) flash_sales = from_list(lambda x: x, obj.get("flashSales")) attribute_set = AttributeSet.from_dict(obj.get("attributeSet")) categories = from_list(Category.from_dict, obj.get("categories")) seller_categories = from_list(Category.from_dict, obj.get("sellerCategories")) magento_id = from_int(obj.get("magentoId")) seo_info = SEOInfo.from_dict(obj.get("seoInfo")) rating = Rating.from_dict(obj.get("rating")) all_active_flash_sales = from_list(lambda x: x, obj.get("allActiveFlashSales")) return Product(sku, name, url, seller, brand, status, objective, product_type, images, price, product_line, stocks, total_available_by_stores, total_available, is_bundle, bundle_products, parent_bundles, total_available_by_stocks, serial_generated, serial_managed, display_name, color, tags, promotion_prices, promotions, flash_sales, attribute_set, categories, seller_categories, magento_id, seo_info, rating, all_active_flash_sales)
def from_dict(obj: Any) -> 'Rating': assert isinstance(obj, dict) average_point = from_none(obj.get("averagePoint")) vote_count = from_int(obj.get("voteCount")) return Rating(average_point, vote_count)
def from_dict(obj: Any) -> 'Image': assert isinstance(obj, dict) url = from_str(obj.get("url")) priority = from_int(obj.get("priority")) path = from_str(obj.get("path")) return Image(url, priority, path)
def to_dict(self) -> dict: result: dict = {} result["code"] = to_enum(Code, self.code) result["total"] = from_int(self.total) return result
def to_dict(self) -> dict: result: dict = {} result["url"] = from_str(self.url) result["priority"] = from_int(self.priority) result["path"] = from_str(self.path) return result
def to_dict(self) -> dict: result: dict = {} result["type"] = to_enum(TypeEnum, self.type) result["total"] = from_int(self.total) return result
def to_dict(self) -> dict: result: dict = {} result["id"] = from_int(self.id) result["name"] = to_enum(SellerName, self.name) result["displayName"] = to_enum(DisplayName, self.display_name) return result
def from_dict(obj: Any) -> 'Seller': assert isinstance(obj, dict) id = from_int(obj.get("id")) name = SellerName(obj.get("name")) display_name = DisplayName(obj.get("displayName")) return Seller(id, name, display_name)
def to_dict(self) -> dict: result: dict = {} result["supplierSalePrice"] = from_int(self.supplier_sale_price) result["sellPrice"] = from_int(self.sell_price) return result
def from_dict(obj: Any) -> 'AttributeSet': assert isinstance(obj, dict) id = from_int(obj.get("id")) name = from_str(obj.get("name")) return AttributeSet(id, name)
def to_dict(self) -> dict: result: dict = {} result["maxPrice"] = from_int(self.max_price) result["minPrice"] = from_int(self.min_price) return result
def to_dict(self) -> dict: result: dict = {} result["id"] = from_int(self.id) result["name"] = self.name return result
def to_dict(self) -> dict: result: dict = {} result["averagePoint"] = from_none(self.average_point) result["voteCount"] = from_int(self.vote_count) return result