本文整理汇总了Python中ebaysdk.trading.Connection.build_request方法的典型用法代码示例。如果您正苦于以下问题:Python Connection.build_request方法的具体用法?Python Connection.build_request怎么用?Python Connection.build_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ebaysdk.trading.Connection
的用法示例。
在下文中一共展示了Connection.build_request方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import build_request [as 别名]
def run(self):
with file_lock("/tmp/.ebaysdk-poller-orders.lock"):
log.debug("Started poller %s" % __file__)
to_time = datetime.utcnow() # - timedelta(days=4)
from_time = to_time - timedelta(hours=self.opts.hours,
minutes=self.opts.minutes)
ebay_api = Trading(debug=self.opts.debug, config_file=self.opts.yaml,
appid=self.opts.appid, certid=self.opts.certid,
devid=self.opts.devid, siteid=self.opts.siteid,
warnings=False)
ebay_api.build_request('GetOrders', {
'DetailLevel': 'ReturnAll',
'OrderRole': self.opts.OrderRole,
'OrderStatus': self.opts.OrderStatus,
'Pagination': {
'EntriesPerPage': 25,
'PageNumber': 1,
},
'ModTimeFrom': from_time.strftime('%Y-%m-%dT%H:%M:%S.000Z'),
'ModTimeTo': to_time.strftime('%Y-%m-%dT%H:%M:%S.000Z'),
}, None)
for resp in ebay_api.pages():
if resp.reply.OrderArray:
for order in resp.reply.OrderArray.Order:
if self.storage:
self.storage.set(order)
else:
log.debug("storage object not defined")
else:
log.debug("no orders to process")
示例2: main
# 需要导入模块: from ebaysdk.trading import Connection [as 别名]
# 或者: from ebaysdk.trading.Connection import build_request [as 别名]
def main(opts):
with file_lock("/tmp/.ebaysdk-poller-orders.lock"):
log.debug("Started poller %s" % __file__)
to_time = datetime.utcnow()# - timedelta(days=80)
from_time = to_time - timedelta(hours=opts.hours)
ebay_api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
certid=opts.certid, devid=opts.devid, siteid=opts.siteid, warnings=False
)
ebay_api.build_request('GetOrders', {
'DetailLevel': 'ReturnAll',
'OrderRole': 'Buyer',
'OrderStatus': 'All',
'Pagination': {
'EntriesPerPage': 25,
'PageNumber': 1,
},
'ModTimeFrom': from_time.strftime('%Y-%m-%dT%H:%M:%S.000Z'),
'ModTimeTo': to_time.strftime('%Y-%m-%dT%H:%M:%S.000Z'),
}, None)
for resp in ebay_api.pages():
if resp.reply.OrderArray:
for order in resp.reply.OrderArray.Order:
data = [
("ID", order.OrderID),
("Status", order.OrderStatus),
("Seller Email", order.SellerEmail),
("Title", order.TransactionArray.Transaction.Item.Title),
("ItemID", order.TransactionArray.Transaction.Item.ItemID),
("QTY", order.TransactionArray.Transaction.QuantityPurchased),
("Payment Method", order.CheckoutStatus.PaymentMethod),
("Payment Date", order.PaidTime),
("Total", (order.Total._currencyID + ' ' + order.Total.value))
]
if order.TransactionArray.Transaction.get('Variation', None):
data.append(("SKU", order.TransactionArray.Transaction.Variation.SKU)),
data.extend([
("Shipped Time", order.ShippedTime),
("Shipping Service", order.ShippingServiceSelected)
])
if order.ShippingDetails.get('ShipmentTrackingDetails', None):
data.extend([
("Min Shipping Days", order.ShippingDetails.ShippingServiceOptions.ShippingTimeMin),
("Max Shipping Days", order.ShippingDetails.ShippingServiceOptions.ShippingTimeMax),
("Tracking", order.ShippingDetails.ShipmentTrackingDetails.ShipmentTrackingNumber),
("Carrier", order.ShippingDetails.ShipmentTrackingDetails.ShippingCarrierUsed),
("Cost", (order.ShippingDetails.ShippingServiceOptions.ShippingServiceCost._currencyID, order.ShippingDetails.ShippingServiceOptions.ShippingServiceCost.value))
])
values_array = map((lambda x: "%s=%s" % (x[0], x[1])), data)
log.debug(", ".join(values_array))
# execute SQL here
else:
log.debug("no orders to process")