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 ResponseSchema(MWSResponseSchema): """Response schema for ListInboundShipments.""" class ShipmentSchema(xm.Schema): ignore_missing = True class ContentsFeeSchema(xm.Schema): units = xm.Int('.//TotalUnits') per_unit = xm.Float('.//FeePerUnit/Amount') total = xm.Float('.//TotalFee/Amount') order_number = xm.String('.//ShipmentId', required=True) name = xm.String('.//ShipmentName') fulfillment_cented_id = xm.String( './/DestinationFulfillmentCenterId') label_prep_type = xm.String('.//LabelPrepType') status = xm.String('.//ShipmentStatus') cases_required = xm.Boolean('.//AreCasesRequired') need_by_date = xm.String('.//ConfirmedNeedByDate') box_contents_source = xm.String('.//BoxContentsSource') box_contents_fee = xm.Field('.//EstimatedBoxContentsFee', ContentsFeeSchema()) items = xm.Field('.//member', ShipmentSchema(), many=True, default=list) next_token = xm.String('.//NextToken', default=None)
class ResponseSchema(MWSResponseSchema): class OrderSchema(xm.Schema): ignore_missing = True order_number = xm.String('.//AmazonOrderId', required=True) seller_order_id = xm.String('.//SellerOrderId') date = xm.String('.//PurchaseDate') status = xm.String('.//OrderStatus') prime = xm.Boolean('.//IsPrime') fulfillment_channel = xm.String('.//FulfillmentChannel') business = xm.Boolean('.//IsBusinessOrder') replacement = xm.Boolean('.//IsReplacementOrder') class CustomerSchema(xm.Schema): ignore_missing = True class AddressSchema(xm.Schema): ignore_missing = True city = xm.String('.//City') postal_code = xm.String('.//PostalCode') state = xm.String('.//StateOrRegion') country = xm.String('.//CountryCode') lines = xm.String( './/*[starts-with(name(), "AddressLine")]', many=True) name = xm.String('.//BuyerName') email = xm.String('.//BuyerEmail') address = xm.Field('.//ShippingAddress', AddressSchema()) orders = xm.Field('.//Order', OrderSchema(), many=True, default=list) next_token = xm.String('.//NextToken', default=None)
class CDSchema(xm.Schema): title = xm.Field('TITLE') artist = xm.Field('ARTIST') country = xm.Field('COUNTRY') company = xm.Field('COMPANY') price = xm.Field('PRICE', float) year = xm.Field('YEAR', int) missing = xm.Field('missingfield', str, 'missing')
class MWSResponseSchema(xm.Schema): """Base schema for MWS responses.""" ignore_missing = True class Error(xm.Schema): """Schema for MWS errors.""" type = xm.Field('.//Type') code = xm.Field('.//Code') message = xm.Field('.//Message') request_id = xm.String('//RequestId') errors = xm.Field('//Error', Error(), default=list, many=True)
class ResponseSchema(MWSResponseSchema): """Response schema for ListInventorySupply.""" 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') items = xm.Field('.//member', SupplySchema(), many=True, default=list) next_token = xm.String('.//NextToken', default=None)
class PackageSchema(xm.Schema): ignore_missing = True class Dimensions(xm.Schema): units = xm.String('.//Unit') height = xm.Float('.//Height') length = xm.Float('.//Length') width = xm.Float('.//Width') weight = xm.Float('.//Weight/Value') tracking_number = xm.String('.//TrackingId') carrier = xm.String('.//CarrierName') status = xm.String('.//PackageStatus') dimensions = xm.Field('.//Dimensions', Dimensions())
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 CustomerSchema(xm.Schema): ignore_missing = True class AddressSchema(xm.Schema): ignore_missing = True city = xm.String('.//City') postal_code = xm.String('.//PostalCode') state = xm.String('.//StateOrRegion') country = xm.String('.//CountryCode') lines = xm.String( './/*[starts-with(name(), "AddressLine")]', many=True) name = xm.String('.//BuyerName') email = xm.String('.//BuyerEmail') address = xm.Field('.//ShippingAddress', AddressSchema())
class ShipmentSchema(xm.Schema): ignore_missing = True class ContentsFeeSchema(xm.Schema): units = xm.Int('.//TotalUnits') per_unit = xm.Float('.//FeePerUnit/Amount') total = xm.Float('.//TotalFee/Amount') order_number = xm.String('.//ShipmentId', required=True) name = xm.String('.//ShipmentName') fulfillment_cented_id = xm.String( './/DestinationFulfillmentCenterId') label_prep_type = xm.String('.//LabelPrepType') status = xm.String('.//ShipmentStatus') cases_required = xm.Boolean('.//AreCasesRequired') need_by_date = xm.String('.//ConfirmedNeedByDate') box_contents_source = xm.String('.//BoxContentsSource') box_contents_fee = xm.Field('.//EstimatedBoxContentsFee', ContentsFeeSchema())
class ResponseSchema(MWSResponseSchema): 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') items = xm.Field('.//OrderItem', OrderItemSchema(), many=True, default=list) next_token = xm.String('.//NextToken', default=None)
class ResponseSchema(MWSResponseSchema): class EventGroupSchema(xm.Schema): ignore_missing = True group_id = xm.String('.//FinancialEventGroupId', required=True) group_status = xm.String('.//FinancialEventGroupStatus') fund_transfer_status = xm.String('.//FundTransferStatus') original_total = xm.Float('.//OriginalTotal/Amount') converted_total = xm.Float('.//ConvertedTotal/Amount') fund_transfer_date = xm.String('.//FundTransferDate') trace_id = xm.String('.//TraceId') account_tail = xm.String('.//AccountTail') beginning_balance = xm.Float('.//BeginningBalance/Amount') start_date = xm.String('.//FinancialEventGroupStartDate') end_date = xm.String('.//FinancialEventGroupEndDate') groups = xm.Field('.//FinancialEventGroup', EventGroupSchema(), many=True, default=list) next_token = xm.String('.//NextToken', default=None)
class ResponseSchema(MWSResponseSchema): 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) items = xm.Field('.//member', ShipmentSchema(), many=True, default=list) next_token = xm.String('.//NextToken', default=None)
class ResponseSchema(MWSResponseSchema): class PackageSchema(xm.Schema): ignore_missing = True class Dimensions(xm.Schema): units = xm.String('.//Unit') height = xm.Float('.//Height') length = xm.Float('.//Length') width = xm.Float('.//Width') weight = xm.Float('.//Weight/Value') tracking_number = xm.String('.//TrackingId') carrier = xm.String('.//CarrierName') status = xm.String('.//PackageStatus') dimensions = xm.Field('.//Dimensions', Dimensions()) shipping = xm.Float('.//PartneredEstimate/Amount/Value') transport_status = xm.String('.//TransportStatus', required=True) packages = xm.Field('//member', PackageSchema(), many=True, default=list)
class RawXMLSchema(MWSResponseSchema): """Utility schema that just grabs the raw XML response.""" xml = xm.Field('.', cast=lambda tag: etree.tostring(tag).decode(), default='Not found?')
class CatalogSchema(xm.Schema): catalog = xm.Field('CATALOG', CDSchema, many=True)
class Error(xm.Schema): """Schema for MWS errors.""" type = xm.Field('.//Type') code = xm.Field('.//Code') message = xm.Field('.//Message')