1+ # -*- coding: utf-8 -*-
2+
3+ '''
4+ © 2012-2013 eBay Software Foundation
5+ Authored by: Tim Keefer
6+ Licensed under CDDL 1.0
7+ '''
18
2- import time
39from datetime import datetime , timedelta
410
511from ebaysdk .trading import Connection as Trading
612from ebaysdk .poller import parse_args , file_lock
713from ebaysdk import log
814
915
10-
1116def sample ():
1217 pass
1318
@@ -16,64 +21,58 @@ def main(opts):
1621 with file_lock ("/tmp/.ebaysdk-poller-orders.lock" ):
1722 log .debug ("Started poller %s" % __file__ )
1823
19- to_time = datetime .utcnow ()
20- from_time = to_time - timedelta (days = 29 )
24+ to_time = datetime .utcnow () - timedelta ( days = 29 )
25+ from_time = to_time - timedelta (hours = opts . hours )
2126
2227 ebay_api = Trading (debug = opts .debug , config_file = opts .yaml , appid = opts .appid ,
2328 certid = opts .certid , devid = opts .devid , siteid = opts .siteid , warnings = False
2429 )
2530
26- resp = ebay_api .execute ('GetOrders' , {
31+ ebay_api .build_request ('GetOrders' , {
2732 'DetailLevel' : 'ReturnAll' ,
2833 'OrderRole' : 'Buyer' ,
2934 'OrderStatus' : 'All' ,
3035 'Pagination' : {
31- 'EntriesPerPage' : 25 ,
36+ 'EntriesPerPage' : 2 ,
3237 'PageNumber' : 1 ,
3338 },
3439 'ModTimeFrom' : from_time .strftime ('%Y-%m-%dT%H:%M:%S.000Z' ),
3540 'ModTimeTo' : to_time .strftime ('%Y-%m-%dT%H:%M:%S.000Z' ),
36- })
37-
38-
39- if resp .reply .OrderArray :
40- for order in resp .reply .OrderArray .Order :
41- #from IPython import embed; embed()
42-
43- log .debug ("ID: %s" % order .OrderID )
44- log .debug ("Status: %s" % order .OrderStatus )
45- log .debug ("Seller Email: %s" % order .SellerEmail )
46- log .debug ("Title: %s" % order .TransactionArray .Transaction .Item .Title )
47- log .debug ("ItemID: %s" % order .TransactionArray .Transaction .Item .ItemID )
48- log .debug ("QTY: %s" % order .TransactionArray .Transaction .QuantityPurchased )
49- log .debug ("Payment Method: %s" % order .CheckoutStatus .PaymentMethod )
50- log .debug ("Payment Date: %s" % order .PaidTime )
51- log .debug ("Total: %s %s" % (order .Total ._currencyID , order .Total .value ))
52-
53- if order .TransactionArray .Transaction .get ('Variation' , None ):
54- log .debug ("SKU: %s" % order .TransactionArray .Transaction .Variation .SKU )
55- log .debug ("SKU2: %s" % order .TransactionArray .Transaction .Item .get ('SKU' , 'None' ))
56-
57- if order .ShippingDetails .get ('ShipmentTrackingDetails' , None ):
58- log .debug ("Tracking: %s" % order .ShippingDetails .ShipmentTrackingDetails .ShipmentTrackingNumber )
59- log .debug ("Carrier: %s" % order .ShippingDetails .ShipmentTrackingDetails .ShippingCarrierUsed )
60- log .debug ("Cost: %s %s" % (order .ShippingDetails .ShippingServiceOptions .ShippingServiceCost ._currencyID , order .ShippingDetails .ShippingServiceOptions .ShippingServiceCost .value ))
61- else :
62- log .debug ("no orders to process" )
63-
64-
65- '''
66- - item title .. Title
67- - ebay auction Id .. ItemID
68- - seller id or alias ..
69- - seller email .. SellerEmail
70- - date of auction close
71- - ship tracking number
72- - cost of auction or transaction .. TransactionPrice
73- - shipping cost .. ActualShippingCost
74- - SKU .. SKU
75- - payment method and date
76- '''
41+ }, None )
42+
43+ for resp in ebay_api .pages ():
44+
45+ if resp .reply .OrderArray :
46+
47+ for order in resp .reply .OrderArray .Order :
48+
49+ log .debug ("ID: %s" % order .OrderID )
50+ log .debug ("Status: %s" % order .OrderStatus )
51+ log .debug ("Seller Email: %s" % order .SellerEmail )
52+ log .debug ("Title: %s" % order .TransactionArray .Transaction .Item .Title )
53+ log .debug ("ItemID: %s" % order .TransactionArray .Transaction .Item .ItemID )
54+ log .debug ("QTY: %s" % order .TransactionArray .Transaction .QuantityPurchased )
55+ log .debug ("Payment Method: %s" % order .CheckoutStatus .PaymentMethod )
56+ log .debug ("Payment Date: %s" % order .PaidTime )
57+ log .debug ("Total: %s %s" % (order .Total ._currencyID , order .Total .value ))
58+
59+ if order .TransactionArray .Transaction .get ('Variation' , None ):
60+ log .debug ("SKU: %s" % order .TransactionArray .Transaction .Variation .SKU )
61+
62+ log .debug ("Shipped Time: %s" % order .ShippedTime )
63+ log .debug ("Shipping Service: %s" % order .ShippingServiceSelected )
64+
65+ if order .ShippingDetails .get ('ShipmentTrackingDetails' , None ):
66+ log .debug ("Min Shipping Days: %s" % order .ShippingDetails .ShippingServiceOptions .ShippingTimeMin )
67+ log .debug ("Max Shipping Days: %s" % order .ShippingDetails .ShippingServiceOptions .ShippingTimeMax )
68+ log .debug ("Tracking: %s" % order .ShippingDetails .ShipmentTrackingDetails .ShipmentTrackingNumber )
69+ log .debug ("Carrier: %s" % order .ShippingDetails .ShipmentTrackingDetails .ShippingCarrierUsed )
70+ log .debug ("Cost: %s %s" % (order .ShippingDetails .ShippingServiceOptions .ShippingServiceCost ._currencyID , order .ShippingDetails .ShippingServiceOptions .ShippingServiceCost .value ))
71+
72+ # execute SQL here
73+
74+ else :
75+ log .debug ("no orders to process" )
7776
7877
7978if __name__ == '__main__' :
0 commit comments