Exemple #1
0
        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
Exemple #2
0
        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())
Exemple #3
0
        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')
Exemple #4
0
 class RetroChargeEvent(xm.Schema):
     ignore_missing = True
     type = xm.String('.//RetrochargeEventType')
     amazon_order_id = xm.String('.//AmazonOrderId')
     posted_date = xm.String('.//PostedDate')
     base_tax = xm.Float('.//BaseTax/Amount')
     shipping_tax = xm.Float('.//ShippingTax/Amount')
     marketplace = xm.String('.//MarketplaceName')
Exemple #5
0
                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)
Exemple #6
0
            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')
Exemple #7
0
        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')
Exemple #8
0
        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
Exemple #9
0
        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())
Exemple #10
0
        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)
Exemple #11
0
    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)
Exemple #12
0
            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())
Exemple #13
0
            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())
Exemple #14
0
        class AdjustmentEvent(xm.Schema):
            ignore_missing = True

            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')

            type = xm.String('.//AdjustmentType')
            amount = xm.Float('.//AdjustmentAmount/Amount')
            posted_date = xm.String('.//PostedDate')
            items = xm.List('.//AdjustmentItemList/AdjustmentItem',
                            AdjustmentItem())
Exemple #15
0
        class ShipmentEvent(xm.Schema):
            ignore_missing = True

            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())

            amazon_order_id = xm.String('.//AmazonOrderId')
            seller_order_id = xm.String('.//SellerOrderId')
            marketplace = xm.String('.//MarketplaceName')
            posted_date = xm.String('.//PostedDate')

            charges = xm.Nested('.//OrderChargeList', ComponentList())
            charge_adjustments = xm.Nested('.//OrderChargeAdjustmentList',
                                           ComponentList())
            shipment_fees = xm.Nested('.//ShipmentFeeList', ComponentList())
            shipment_adjustments = xm.Nested('.//ShipmentFeeAdjustmentList',
                                             ComponentList())
            fees = xm.Nested('.//OrderFeeList', ComponentList())
            fee_adjustments = xm.Nested('.//OrderFeeAdjustmentList',
                                        ComponentList())
            direct_payments = xm.Nested('.//DirectPaymentList',
                                        ComponentList())
            items = xm.List('.//ShipmentItemList/ShipmentItem', ShipmentItem())
            item_adjustments = xm.List(
                './/ShipmentItemAdjustments/ShipmentItem', ShipmentItem())
Exemple #16
0
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)
Exemple #17
0
        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')
Exemple #18
0
    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)
Exemple #19
0
 class ServiceFeeEvent(xm.Schema):
     ignore_missing = True
     amazon_order_id = xm.String('.//AmazonOrderId')
     reason = xm.String('.//FeeReason')
     fees = xm.Nested('.//FeeList', ComponentList())
     msku = xm.String('.//SellerSKU')
     fnsku = xm.String('.//FnSKU')
     description = xm.String('.//FeeDescription')
     sku = xm.String('.//ASIN')
Exemple #20
0
    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)
Exemple #21
0
        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())
Exemple #22
0
    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)
Exemple #23
0
    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)
Exemple #24
0
    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)
Exemple #25
0
 class PrepDetailsSchema(xm.Schema):
     instruction = xm.String('.//PrepInstruction')
     owner = xm.String('.//PrepOwner')
Exemple #26
0
 class ResponseSchema(MWSResponseSchema):
     status = xm.String('.//Status')
Exemple #27
0
 class RankSchema(xm.Schema):
     category = xm.String('./ProductCategoryId')
     rank = xm.Int('./Rank')
Exemple #28
0
    class ResponseSchema(MWSResponseSchema):
        class ShipmentEvent(xm.Schema):
            ignore_missing = True

            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())

            amazon_order_id = xm.String('.//AmazonOrderId')
            seller_order_id = xm.String('.//SellerOrderId')
            marketplace = xm.String('.//MarketplaceName')
            posted_date = xm.String('.//PostedDate')

            charges = xm.Nested('.//OrderChargeList', ComponentList())
            charge_adjustments = xm.Nested('.//OrderChargeAdjustmentList',
                                           ComponentList())
            shipment_fees = xm.Nested('.//ShipmentFeeList', ComponentList())
            shipment_adjustments = xm.Nested('.//ShipmentFeeAdjustmentList',
                                             ComponentList())
            fees = xm.Nested('.//OrderFeeList', ComponentList())
            fee_adjustments = xm.Nested('.//OrderFeeAdjustmentList',
                                        ComponentList())
            direct_payments = xm.Nested('.//DirectPaymentList',
                                        ComponentList())
            items = xm.List('.//ShipmentItemList/ShipmentItem', ShipmentItem())
            item_adjustments = xm.List(
                './/ShipmentItemAdjustments/ShipmentItem', ShipmentItem())

        class RetroChargeEvent(xm.Schema):
            ignore_missing = True
            type = xm.String('.//RetrochargeEventType')
            amazon_order_id = xm.String('.//AmazonOrderId')
            posted_date = xm.String('.//PostedDate')
            base_tax = xm.Float('.//BaseTax/Amount')
            shipping_tax = xm.Float('.//ShippingTax/Amount')
            marketplace = xm.String('.//MarketplaceName')

        class ServiceFeeEvent(xm.Schema):
            ignore_missing = True
            amazon_order_id = xm.String('.//AmazonOrderId')
            reason = xm.String('.//FeeReason')
            fees = xm.Nested('.//FeeList', ComponentList())
            msku = xm.String('.//SellerSKU')
            fnsku = xm.String('.//FnSKU')
            description = xm.String('.//FeeDescription')
            sku = xm.String('.//ASIN')

        class AdjustmentEvent(xm.Schema):
            ignore_missing = True

            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')

            type = xm.String('.//AdjustmentType')
            amount = xm.Float('.//AdjustmentAmount/Amount')
            posted_date = xm.String('.//PostedDate')
            items = xm.List('.//AdjustmentItemList/AdjustmentItem',
                            AdjustmentItem())

        shipment_events = xm.List('.//ShipmentEventList/ShipmentEvent',
                                  ShipmentEvent())
        refund_events = xm.List('.//RefundEventList/ShipmentEvent',
                                ShipmentEvent())
        guarantee_events = xm.List('.//GuaranteeClaimEventList/ShipmentEvent',
                                   ShipmentEvent())
        chargeback_events = xm.List('.//ChargebackEventList/ShipmentEvent',
                                    ShipmentEvent())
        retrocharge_events = xm.List(
            './/RetrochargeEventList/RetrochargeEvent', RetroChargeEvent())
        service_fee_events = xm.List('.//ServiceFeeEventList/ServiceFeeEvent',
                                     ServiceFeeEvent())
        adjustment_events = xm.List('.//AdjustmentEventList/AdjustmentEvent',
                                    AdjustmentEvent())
        next_token = xm.String('.//NextToken', default=None)
Exemple #29
0
class Promotion(xm.Schema):
    ignore_missing = True

    type = xm.String('.//PromotionType')
    id = xm.String('.//PromotionId')
    amount = xm.Float('.//PromotionAmount/CurrencyAmount', default=0)
Exemple #30
0
 class Dimensions(xm.Schema):
     units = xm.String('.//Unit')
     height = xm.Float('.//Height')
     length = xm.Float('.//Length')
     width = xm.Float('.//Width')