class ProductSchema(xm.Schema): ignore_missing = True class RankSchema(xm.Schema): category = xm.String('./ProductCategoryId') rank = xm.Int('./Rank') sku = xm.String('./Identifiers/MarketplaceASIN/ASIN') brand = xm.First(('.//Brand', './/Manufacturer', './/Label', './/Publisher', './/Studio')) model = xm.First(('.//Model', './/PartNumber')) price = xm.Float('.//ListPrice/Amount') NumberOfItems = xm.Int('.//NumberOfItems') PackageQuantity = xm.Int('.//PackageQuantity') image_url = xm.String('.//SmallImage/URL') title = xm.String('.//Title') ranks = xm.Nested('.//SalesRank', RankSchema(), many=True) features = xm.String('.//Feature', many=True) def post_load(self, data): if 'features' in data: data.features = '\n'.join(data.pop('features')) for ranking in data.pop('ranks', []): if not ranking['category'].isdigit(): data['category'] = ranking.category data['rank'] = ranking.rank break return data
class ProductSchema(xm.Schema): ignore_missing = True sku = xm.String('.//ASIN', required=True) detail_url = xm.Field( 'ASIN', cast=lambda tag: f'http://www.amazon.com/dp/{tag.text}') rank = xm.Int('SalesRank') category = xm.String('.//ProductGroup') image_url = xm.String('.//LargeImage/URL') brand = xm.First(('.//Brand', './/Manufacturer', './/Label', './/Publisher', './/Studio')) model = xm.First(('.//Model', './/MPN', './/PartNumber')) NumberOfItems = xm.Int('.//NumberOfItems') PackageQuantity = xm.Int('.//PackageQuantity') title = xm.String('.//Title') upc = xm.String('.//UPC') merchant = xm.String('.//Merchant/Name') prime = xm.Boolean('.//IsEligibleForPrime') features = xm.String('.//Feature', many=True) description = xm.String('.//EditorialReview/Content') price = xm.Field('.//OfferListing/Price/Amount', cast=lambda tag: int(tag.text) / 100) def post_load(self, data): if 'features' in data: data.features = '\n'.join(data.features) return data
class OrderItemSchema(xm.Schema): ignore_missing = True sku = xm.String('.//ASIN', required=True) msku = xm.String('.//SellerSKU') order_item_id = xm.String('.//OrderItemId') title = xm.String('.//Title') qty_ordered = xm.Int('.//QuantityOrdered') qty_shipped = xm.Int('.//QuantityShipped') price = xm.Float('.//ItemPrice/Amount') currency_code = xm.String('.//ItemPrice/CurrencyCode') shipping_price = xm.Float('.//ShippingPrice/Amount')
class ShipmentSchema(xm.Schema): class PrepDetailsSchema(xm.Schema): instruction = xm.String('.//PrepInstruction') owner = xm.String('.//PrepOwner') order_number = xm.String('.//ShipmentId', required=True) msku = xm.String('.//SellerSKU') fnsku = xm.String('.//FulfillmentNetworkSKU') quantity = xm.Int('.//QuantityShipped') received = xm.Int('.//QuantityReceived') case_quantity = xm.Int('.//QuantityInCase') prep_details = xm.Field('.//PrepDetails', PrepDetailsSchema(), many=True)
class SupplySchema(xm.Schema): ignore_missing = True sku = xm.String('.//ASIN') fnsku = xm.String('.//FNSKU') msku = xm.String('.//SellerSKU') fulfillable = xm.Int('.//InStockSupplyQuantity') condition = xm.String('.//Condition')
class AdjustmentItem(xm.Schema): ignore_missing = True quantity = xm.Int('.//Quantity') per_unit_amount = xm.Float('.//PerUnitAmount/Amount') total_amount = xm.Float('.//TotalAmount/Amount') msku = xm.String('.//SellerSKU') fnsku = xm.String('.//FnSKU') sku = xm.String('.//ASIN') description = xm.String('.//ProductDescription')
class ResponseSchema(MWSResponseSchema): """Response schema for GetCompetitivePricingForASIN.""" success = xm.Attribute('//GetCompetitivePricingForASINResult', attr='status') listing_price = xm.Float('.//ListingPrice/Amount', default=0) shipping = xm.Float('.//Shipping/Amount', default=0) landed_price = xm.Float('.//LandedPrice/Amount', default=0) offers = xm.Int('.//OfferListingCount[@condition="New"]', default=0) def post_load(self, data): data.success = data.success == 'Success' return data
class ShipmentItem(xm.Schema): ignore_missing = True msku = xm.String('.//SellerSKU') order_item_id = xm.String('.//OrderItemId') order_adj_id = xm.String('.//OrderAdjustmentItemId') qty_shipped = xm.Int('.//QuantityShipped') charges = xm.Nested('.//ItemChargeList', ComponentList()) taxes = xm.Nested('.//TaxesWithheldList', ComponentList()) charge_adjustments = xm.Nested('.//ItemChargeAdjustmentList', ComponentList()) fees = xm.Nested('.//ItemFeeList', ComponentList()) fee_adjustments = xm.Nested('.//ItemFeeAdjustmentList', ComponentList()) promotions = xm.Nested('.//PromotionList/Promotion', Promotion()) promo_adjustments = xm.Nested( './/PromotionAdjustmentList/Promotion', Promotion())
class RankSchema(xm.Schema): category = xm.String('./ProductCategoryId') rank = xm.Int('./Rank')
class ContentsFeeSchema(xm.Schema): units = xm.Int('.//TotalUnits') per_unit = xm.Float('.//FeePerUnit/Amount') total = xm.Float('.//TotalFee/Amount')