diff options
author | Filipp Lepalaan <f@230.to> | 2013-05-15 11:47:46 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-05-15 11:47:46 +0300 |
commit | 47db98b2449009f8bf80fe9d30fb6bfe4a331341 (patch) | |
tree | ac6a23f620cec675c87a8421b40a4a21b2b2c1cc /gsxws/orders.py | |
parent | 28b982e69b87c57d5d520b59c68f7bc32bbf9ea4 (diff) | |
download | py-gsxws-47db98b2449009f8bf80fe9d30fb6bfe4a331341.tar.gz py-gsxws-47db98b2449009f8bf80fe9d30fb6bfe4a331341.tar.bz2 py-gsxws-47db98b2449009f8bf80fe9d30fb6bfe4a331341.zip |
Fixed stocking orders
Diffstat (limited to 'gsxws/orders.py')
-rw-r--r-- | gsxws/orders.py | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/gsxws/orders.py b/gsxws/orders.py index e097cf6..791fe58 100644 --- a/gsxws/orders.py +++ b/gsxws/orders.py @@ -1,23 +1,52 @@ from core import GsxObject +class OrderLine(GsxObject): + partNumber = None + quantity = None + + +class APPOrder(GsxObject): + pass + + class StockingOrder(GsxObject): - def __init__(self, type='stocking', *args, **kwargs): + """ + Description: + The Create Stocking Order API is used to create a stocking order. + The purchase order number, ship-to number of the service provider + and a list of parts are required. + The service account number is obtained from the session. + Quote is obtained for the parts and if it is processed successfully, + a confirmation number, array of parts, sub-total, tax and total price are returned. + The part details also contain the net price and availability. + + Context: + The API can be invoked only after valid authentication. + Authentication generates a session ID that needs to be passed while using this API. + + >>> StockingOrder(purchaseOrderNumber=111, shipToCode=677592).add_part('661-5097', 1).submit() + """ + _namespace = "asp:" + + def __init__(self, *args, **kwargs): super(StockingOrder, self).__init__(*args, **kwargs) - self.data['orderLines'] = list() + self.orderLines = list() def add_part(self, part_number, quantity): - self.data['orderLines'].append({ - 'partNumber': part_number, 'quantity': quantity - }) + self.orderLines.append(OrderLine(partNumber=part_number, quantity=quantity)) + return self def submit(self): - dt = CLIENT.factory.create('ns1:createStockingOrderRequestType') - dt.userSession = SESSION - dt.orderData = self.data - - try: - result = CLIENT.service.CreateStockingOrder(dt) - return result.orderConfirmation - except suds.WebFault, e: - raise GsxError(fault=e) + self._submit("orderData", "CreateStockingOrder", "orderConfirmation") + return self._req.objects[0] + + +if __name__ == '__main__': + import sys + import doctest + import logging + from core import connect + logging.basicConfig(level=logging.DEBUG) + connect(*sys.argv[1:5]) + doctest.testmod() |