Add set_member() API method

also rename `get_customer()` to `get_member`
This commit is contained in:
Lance Edgar 2020-03-17 16:04:22 -05:00
parent 9e850496e7
commit d8e93c9d2e

View file

@ -116,11 +116,11 @@ class CoreWebAPI(object):
assert set(js['result'].keys()) == set(['result']) assert set(js['result'].keys()) == set(['result'])
return js['result']['result'] return js['result']['result']
def get_customer(self, cardNo, **columns): def get_member(self, cardNo):
""" """
Fetch an existing Customer record from CORE. Fetch an existing Member record from CORE.
:returns: Either a customer dict record, or ``None``. :returns: Either a member dict record, or ``None``.
""" """
params = { params = {
'cardNo': cardNo, 'cardNo': cardNo,
@ -131,6 +131,27 @@ class CoreWebAPI(object):
if result: if result:
return result return result
def set_member(self, cardNo, **kwargs):
"""
Update an existing Member record in CORE.
:returns: Boolean indicating success of the operation.
.. warning::
Only simple updates have been attempted thus far; have yet to try
creation or deletion. Neither of those should be expected to work.
"""
kwargs['cardNo'] = cardNo
params = {
'cardNo': cardNo,
'method': 'set',
'member': kwargs,
}
response = self.post(params, method='FannieMember')
result = self.parse_response(response, method='FannieMember')
if result:
return result
def get_departments(self, **columns): def get_departments(self, **columns):
""" """
Fetch some or all of Department records from CORE. Fetch some or all of Department records from CORE.