Skip to content

Commit

Permalink
Fix missing customer_uuid when creating a note (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoeunSona authored Dec 21, 2023
1 parent ed81ce8 commit e76897b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion chartmogul/api/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
6 changes: 5 additions & 1 deletion chartmogul/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion chartmogul/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.1.0"
__version__ = "4.1.1"
3 changes: 1 addition & 2 deletions test/api/test_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit e76897b

Please sign in to comment.