diff --git a/CHANGELOG.md b/CHANGELOG.md index 854129c..f671986 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning]. [Keep a Changelog]: https://keepachangelog.com/en/1.0.0/ [Semantic Versioning]: https://semver.org/spec/v2.0.0.html +## [4.1.1] - 2023-12-21 +- Fix missing customer_uuid when creating a note from a customer + ## [4.1.0] - 2023-12-20 - Support customer notes diff --git a/chartmogul/api/customer.py b/chartmogul/api/customer.py index 83f86bb..eb700fd 100644 --- a/chartmogul/api/customer.py +++ b/chartmogul/api/customer.py @@ -84,4 +84,4 @@ def make(self, data, **kwargs): "create", "post", "/customers/{uuid}/contacts", useCallerClass=True ) Customer.notes = CustomerNote._method("all", "get", "/customer_notes?customer_uuid={uuid}", useCallerClass=True) -Customer.createNote = CustomerNote._method("create", "post", "/customer_notes", useCallerClass=True) +Customer.createNote = CustomerNote._method("create", "post", "/customer_notes", useCallerClass=True, useUUIDFor="customer_uuid") diff --git a/chartmogul/resource.py b/chartmogul/resource.py index bdfffab..9a3ceb8 100644 --- a/chartmogul/resource.py +++ b/chartmogul/resource.py @@ -191,7 +191,7 @@ def _validate_arguments(cls, method, kwargs): ) @classmethod - def _method(callerClass, method, http_verb, path=None, useCallerClass=False): + def _method(callerClass, method, http_verb, path=None, useCallerClass=False, useUUIDFor=None): @classmethod def fc(calleeClass, config, **kwargs): if config is None or not isinstance(config, Config): @@ -208,6 +208,10 @@ def fc(calleeClass, config, **kwargs): cls._validate_arguments(method, kwargs) pathTemp = Resource._expandPath(pathTemp, kwargs) + + if useUUIDFor is not None and 'data' in kwargs.keys(): + kwargs["data"][useUUIDFor] = kwargs["uuid"] + # UUID is always path parameter only. if "uuid" in kwargs: del kwargs["uuid"] diff --git a/chartmogul/version.py b/chartmogul/version.py index 7039708..72aa758 100644 --- a/chartmogul/version.py +++ b/chartmogul/version.py @@ -1 +1 @@ -__version__ = "4.1.0" +__version__ = "4.1.1" diff --git a/test/api/test_customer.py b/test/api/test_customer.py index c6c1405..0f16ded 100644 --- a/test/api/test_customer.py +++ b/test/api/test_customer.py @@ -290,7 +290,6 @@ } createNote = { - "customer_uuid": "cus_00000000-0000-0000-0000-000000000000", "type": "note", "text": "This is a note", "author_email": "john@xample.com" @@ -547,7 +546,7 @@ def test_createNote(self, mock_requests): config = Config("token") expected = Customer.createNote( - config, data=createNote + config, uuid="cus_00000000-0000-0000-0000-000000000000", data=createNote ).get() self.assertEqual(mock_requests.call_count, 1, "expected call")