From 18af65be6c2b0038915b858f436d5d37687283e8 Mon Sep 17 00:00:00 2001 From: tim-s-ccs Date: Thu, 29 Aug 2024 13:58:51 +0100 Subject: [PATCH] Add update_supplier_sharecode method --- dmapiclient/__init__.py | 2 +- dmapiclient/data.py | 11 +++++++++++ tests/test_data_api_client.py | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/dmapiclient/__init__.py b/dmapiclient/__init__.py index 18173c6..955e73f 100644 --- a/dmapiclient/__init__.py +++ b/dmapiclient/__init__.py @@ -1,4 +1,4 @@ -__version__ = '26.6.1' +__version__ = '26.7.0' from .errors import APIError, HTTPError, InvalidResponse # noqa from .errors import REQUEST_ERROR_STATUS_CODE, REQUEST_ERROR_MESSAGE # noqa diff --git a/dmapiclient/data.py b/dmapiclient/data.py index 1036bdc..eb0a24c 100644 --- a/dmapiclient/data.py +++ b/dmapiclient/data.py @@ -153,6 +153,17 @@ def update_supplier(self, supplier_id, supplier, user=None): user=user, ) + def update_supplier_sharecode(self, supplier_id, sharecode, user=None): + return self._post_with_updated_by( + "/suppliers/{}/sharecode".format(supplier_id), + data={ + "suppliers": { + "sharecode": sharecode + }, + }, + user=user, + ) + def update_contact_information(self, supplier_id, contact_id, contact, user=None): return self._post_with_updated_by( diff --git a/tests/test_data_api_client.py b/tests/test_data_api_client.py index 044c4bc..2e7cdec 100644 --- a/tests/test_data_api_client.py +++ b/tests/test_data_api_client.py @@ -859,6 +859,21 @@ def test_update_supplier(self, data_client, rmock): 'suppliers': {'foo': 'bar'}, 'updated_by': 'supplier' } + def test_update_supplier_sharecode(self, data_client, rmock): + rmock.post( + "http://baseurl/suppliers/123/sharecode", + json={"suppliers": "result"}, + status_code=200, + ) + + result = data_client.update_supplier_sharecode(123, "123456789", 'supplier') + + assert result == {"suppliers": "result"} + assert rmock.called + assert rmock.request_history[0].json() == { + 'suppliers': {'sharecode': '123456789'}, 'updated_by': 'supplier' + } + def test_update_contact_information(self, data_client, rmock): rmock.post( "http://baseurl/suppliers/123/contact-information/2",