From 76f743f3b86060edf8ed77b4ab9d8ca5e5daf7a7 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 9 Feb 2021 14:25:18 -0600 Subject: [PATCH] Add `set_vendor_item()` method for API client --- corepos/api.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/corepos/api.py b/corepos/api.py index 3a8b624..b6ee1ed 100644 --- a/corepos/api.py +++ b/corepos/api.py @@ -2,7 +2,7 @@ ################################################################################ # # pyCOREPOS -- Python Interface to CORE POS -# Copyright © 2018-2020 Lance Edgar +# Copyright © 2018-2021 Lance Edgar # # This file is part of pyCOREPOS. # @@ -487,3 +487,26 @@ class CoreWebAPI(object): if len(result) > 1: log.warning("CORE API returned %s VendorItem results", len(result)) return json.loads(result[0]) + + def set_vendor_item(self, sku, vendorID, **columns): + """ + Update an existing VendorItem record in CORE. + + :returns: Boolean indicating success of the operation. + + .. note:: + Currently this is being used to create a *new* product also. CORE's + ``vendorItems`` table does not use auto-increment for its PK, which + means we must provide one even when creating; therefore this method + may be used for that. + """ + columns['sku'] = sku + columns['vendorID'] = vendorID + params = { + 'entity': 'VendorItems', + 'submethod': 'set', + 'columns': columns, + } + response = self.post(params) + result = self.parse_response(response) + return json.loads(result)