From d8e93c9d2ee6ca54bf8f838e94f4310342b59398 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 17 Mar 2020 16:04:22 -0500 Subject: [PATCH] Add `set_member()` API method also rename `get_customer()` to `get_member` --- corepos/api.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/corepos/api.py b/corepos/api.py index 9a6b5de..5c2a66f 100644 --- a/corepos/api.py +++ b/corepos/api.py @@ -116,11 +116,11 @@ class CoreWebAPI(object): assert set(js['result'].keys()) == set(['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 = { 'cardNo': cardNo, @@ -131,6 +131,27 @@ class CoreWebAPI(object): if 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): """ Fetch some or all of Department records from CORE.