Created
May 18, 2015 17:40
-
-
Save clintmjohnson/1b0aa952ca8c3cf5bc91 to your computer and use it in GitHub Desktop.
Channel Advisor / Python Get Orders API Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from suds.client import Client | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
logging.getLogger('suds.client').setLevel(logging.DEBUG) | |
# Specify Login Information | |
developer_key = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' | |
password = 'xxxxxxxx' | |
account_guid = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' | |
# Specify URLs | |
wsdl_url = 'https://api.channeladvisor.com/ChannelAdvisorAPI/v6/OrderService.asmx?WSDL' | |
service_url = 'https://api.channeladvisor.com/ChannelAdvisorAPI/v6/OrderService.asmx' | |
# Initialize client. | |
client = Client(wsdl_url, location = service_url) | |
login = client.factory.create('APICredentials') | |
login.DeveloperKey = developer_key | |
login.Password = password | |
client.set_options(soapheaders=login) | |
# Instantiate our GetOrderList Object | |
getOrderList = client.factory.create('GetOrderList') | |
getOrderList.orderCriteria.OrderCreationFilterBeginTimeGMT = '2000-01-01T00:00:00' | |
getOrderList.orderCriteria.OrderCreationFilterEndTimeGMT = '2012-09-05T00:00:00' | |
getOrderList.orderCriteria.StatusUpdateFilterBeginTimeGMT = None | |
getOrderList.orderCriteria.StatusUpdateFilterEndTimeGMT = None | |
getOrderList.orderCriteria.JoinDateFiltersWithOr = None | |
getOrderList.orderCriteria.DetailLevel = 'High' | |
getOrderList.orderCriteria.ExportState = None | |
getOrderList.orderCriteria.OrderIDList = None | |
getOrderList.orderCriteria.ClientOrderIdentifierList = None | |
getOrderList.orderCriteria.OrderStateFilter = 'Active' | |
getOrderList.orderCriteria.PaymentStatusFilter = 'Cleared' | |
getOrderList.orderCriteria.CheckoutStatusFilter = 'Completed' | |
getOrderList.orderCriteria.ShippingStatusFilter = 'Unshipped' | |
getOrderList.orderCriteria.RefundStatusFilter = None | |
getOrderList.orderCriteria.DistributionCenterCode = None | |
getOrderList.orderCriteria.PageSize = 20 | |
getOrderList.orderCriteria.PageNumberFilter = 1 | |
continueRequests = True | |
while continueRequests is True: | |
print 'Page', getOrderList.orderCriteria.PageNumberFilter | |
result = client.service.GetOrderList(account_guid, getOrderList.orderCriteria) | |
ordersInResult = len(result.ResultData.OrderResponseItem) | |
print ' Orders In Page:', ordersInResult | |
for order in result.ResultData.OrderResponseItem: | |
print ' ', order.OrderID | |
if ordersInResult < 20: | |
continueRequests = False | |
else: | |
getOrderList.orderCriteria.PageNumberFilter += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment