Add "set" API methods for Department, Subdepartment, Product

This commit is contained in:
Lance Edgar 2020-03-15 15:52:28 -05:00
parent b76e82975a
commit 2d0cfa30ca

View file

@ -151,6 +151,28 @@ class CoreWebAPI(object):
log.warning("CORE API returned %s department results", len(result))
return json.loads(result[0])
def set_department(self, dept_no, **columns):
"""
Update an existing Department record in CORE.
:returns: Boolean indicating success of the operation.
.. note::
Currently this is being used to create a *new* department also. CORE's
``departments`` 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['dept_no'] = dept_no
params = {
'entity': 'Departments',
'submethod': 'set',
'columns': columns,
}
response = self.post(params)
result = self.parse_response(response)
return json.loads(result)
def get_subdepartments(self, **columns):
"""
Fetch some or all of Subdepartment records from CORE.
@ -193,6 +215,28 @@ class CoreWebAPI(object):
log.warning("CORE API returned %s subdepartment results", len(result))
return json.loads(result[0])
def set_subdepartment(self, subdept_no, **columns):
"""
Update an existing Subdepartment record in CORE.
:returns: Boolean indicating success of the operation.
.. note::
Currently this is being used to create a *new* subdepartment also. CORE's
``subdepartments`` 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['subdept_no'] = subdept_no
params = {
'entity': 'SubDepts',
'submethod': 'set',
'columns': columns,
}
response = self.post(params)
result = self.parse_response(response)
return json.loads(result)
def get_vendors(self, **columns):
"""
Fetch some or all of Vendor records from CORE.
@ -298,3 +342,25 @@ class CoreWebAPI(object):
if len(result) > 1:
log.warning("CORE API returned %s product results", len(result))
return json.loads(result[0])
def set_product(self, upc, **columns):
"""
Update an existing Product record in CORE.
:returns: Boolean indicating success of the operation.
.. note::
Currently this is being used to create a *new* product also. CORE's
``products`` 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['upc'] = upc
params = {
'entity': 'Products',
'submethod': 'set',
'columns': columns,
}
response = self.post(params)
result = self.parse_response(response)
return json.loads(result)