def parse_product(self, r): return { # Ids 'id': pluck(r, ['Id', 'value']), 'IdType': pluck(r, ['IdType', 'value']), 'Product': pluck(r, ['Products', 'Product']) }
def sync_order_items(self, order_id): order_items = self.client.fetch_order_items(order_id) time.sleep(1) parsed = [] for o in order_items: parsed.append({ "QuantityOrdered": pluck(o, ['QuantityOrdered', 'value']), "QuantityShipped": pluck(o, ['QuantityShipped', 'value']), "Title": pluck(o, ['Title', 'value']), "IsGift": pluck(o, ['IsGift', 'value']), "ASIN": pluck(o, ['ASIN', 'value']), "SellerSKU": pluck(o, ['SellerSKU', 'value']), "OrderItemId": pluck(o, ['OrderItemId', 'value']), "IsTransparency": pluck(o, ['IsTransparency', 'value']), "ProductInfo": { "NumberOfItems": pluck(o, ['ProductInfo', 'NumberOfItems', 'value']), "SerialNumberRequired": pluck(o, ['ProductInfo', 'SerialNumberRequired', 'value']), }, "ItemPrice": get_price(o, 'ItemPrice'), "ItemTax": get_price(o, 'ItemTax'), "PromotionDiscount": get_price(o, 'PromotionDiscount'), "PromotionDiscountTax": get_price(o, 'PromotionDiscountTax'), }) return parsed
def parse_inventory_item(self, r): return { # Ids "id": pluck(r, ['SellerSKU', 'value']), "ASIN": pluck(r, ['ASIN', 'value']), "FNSKU": pluck(r, ['FNSKU', 'value']), "SellerSKU": pluck(r, ['SellerSKU', 'value']), "Condition": pluck(r, ['Condition', 'value']), "SupplyDetail": pluck(r, ['SupplyDetail', 'value']), "TotalSupplyQuantity": pluck(r, ['TotalSupplyQuantity', 'value']), "InStockSupplyQuantity": pluck(r, ['InStockSupplyQuantity', 'value']), "EarliestAvailability": pluck(r, ['EarliestAvailability', 'TimepointType', 'value']), }
def parse_order(self, r): return { # Ids "id": pluck(r, ['AmazonOrderId', 'value']), "SellerOrderId": pluck(r, ['SellerOrderId', 'value']), "AmazonOrderId": pluck(r, ['AmazonOrderId', 'value']), "MarketplaceId": pluck(r, ['MarketplaceId', 'value']), # Strings "OrderStatus": pluck(r, ['OrderStatus', 'value']), "OrderType": pluck(r, ['OrderType', 'value']), "BuyerName": pluck(r, ['BuyerName', 'value']), "BuyerEmail": pluck(r, ['BuyerEmail', 'value']), "ShipServiceLevel": pluck(r, ['ShipServiceLevel', 'value']), "ShipServiceLevelCategory": pluck(r, ['ShipServiceLevelCategory', 'value']), "SalesChannel": pluck(r, ['SalesChannel', 'value']), "FulfillmentChannel": pluck(r, ['FulfillmentChannel', 'value']), "PaymentMethod": pluck(r, ['PaymentMethod', 'value']), # Dates "PurchaseDate": pluck(r, ['PurchaseDate', 'value']), "EarliestShipDate": pluck(r, ['EarliestShipDate', 'value']), "LatestShipDate": pluck(r, ['LatestShipDate', 'value']), "LastUpdateDate": pluck(r, ['LastUpdateDate', 'value']), # Counts "NumberOfItemsShipped": pluck(r, ['NumberOfItemsShipped', 'value']), "NumberOfItemsUnshipped": pluck(r, ['NumberOfItemsUnshipped', 'value']), # bools "IsReplacementOrder": pluck(r, ['IsReplacementOrder', 'value']), "IsBusinessOrder": pluck(r, ['IsBusinessOrder', 'value']), "IsPrime": pluck(r, ['IsPrime', 'value']), "IsPremiumOrder": pluck(r, ['IsPremiumOrder', 'value']), # Structs "ShippingAddress": { "City": pluck(r, ['ShippingAddress', 'City', 'value']), "PostalCode": pluck(r, ['ShippingAddress', 'PostalCode', 'value']), "StateOrRegion": pluck(r, ['ShippingAddress', 'StateOrRegion', 'value']), "CountryCode": pluck(r, ['ShippingAddress', 'CountryCode', 'value']), "Name": pluck(r, ['ShippingAddress', 'Name', 'value']), "AddressLine1": pluck(r, ['ShippingAddress', 'AddressLine1', 'value']), "AddressLine2": pluck(r, ['ShippingAddress', 'AddressLine2', 'value']) }, # Prices "OrderTotal": get_price(r, 'OrderTotal'), "ShippingDiscount": get_price(r, 'ShippingDiscount'), "PromotionDiscount": get_price(r, 'PromotionDiscount'), }