From df611b1a5500a9e597c371277f22eaff23eeadac Mon Sep 17 00:00:00 2001 From: Aleksandr Omyshev Date: Tue, 24 Jan 2023 17:35:28 +0200 Subject: [PATCH] fix: Change parameter name id_ to identifier to avoid collision (#9) * fix: Change parameter name id_ to identifier Fix test --- CHANGES.md | 4 ++++ async_customerio/track.py | 10 +++++----- pyproject.toml | 2 +- tests/test_track.py | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8a4b038..fc533b2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 0.5.1 + +- [FIX] Change parameter name from ``id_`` to ``identifier`` of the method ``identify`` to avoid naming collision. + ## 0.5.0 - Add a couple of new attributes to object ``SendEmailRequest`` diff --git a/async_customerio/track.py b/async_customerio/track.py index 2774602..6f7e61c 100644 --- a/async_customerio/track.py +++ b/async_customerio/track.py @@ -69,18 +69,18 @@ def setup_base_url(host: str, port: int, prefix: str) -> str: return template.format(host=host.strip("/"), port=port, prefix=prefix.strip("/")) - async def identify(self, id_: t.Union[str, int], **attrs) -> None: + async def identify(self, identifier: t.Union[str, int], **attrs) -> None: """ Identify a single customer by their unique id, and optionally add attributes. - :param id_: the unique value representing a person. The values you use to identify a person may be an + :param identifier: the unique value representing a person. The values you use to identify a person may be an ``id``, ``email`` address, or the ``cio_id`` (when updating people), depending on your workspace settings. When you reference people by ``cio_id``, you must prefix the value with ``cio_``. """ - if not id_: - raise AsyncCustomerIOError("id_ cannot be blank in identify") + if not identifier: + raise AsyncCustomerIOError("identifier cannot be blank in identify") await self.send_request( - "PUT", join_url(self.base_url, self.CUSTOMER_ENDPOINT.format(id=id_)), json_payload=attrs + "PUT", join_url(self.base_url, self.CUSTOMER_ENDPOINT.format(id=identifier)), json_payload=attrs ) async def track(self, customer_id: t.Union[str, int], name: str, **data) -> None: diff --git a/pyproject.toml b/pyproject.toml index d87b282..e24ad52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "async-customerio" -version = "0.5.0" +version = "0.5.1" description = "Async CustomerIO Client - a Python client to interact with CustomerIO in an async fashion." license = "MIT" authors = [ diff --git a/tests/test_track.py b/tests/test_track.py index cea39a6..0e1994b 100644 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -28,7 +28,7 @@ async def test_identify(fake_async_customerio, faker_, httpx_mock: HTTPXMock): async def test_identify_empty_id(fake_async_customerio): - with pytest.raises(AsyncCustomerIOError, match="id_ cannot be blank in identify"): + with pytest.raises(AsyncCustomerIOError, match="identifier cannot be blank in identify"): await fake_async_customerio.identify(0, first_name="John", last_name="Smith") @@ -197,7 +197,7 @@ async def test_merge_customers_empty_customer_id( @pytest.mark.parametrize( "method, method_arguments", ( - ("identify", {"id_": 1, "name": "Jack"}), + ("identify", {"identifier": 1, "name": "Jack"}), ("track", {"customer_id": 1, "name": "some-event"}), ("track_anonymous", {"anonymous_id": "1111-2", "name": "some-event"}), ("pageview", {"customer_id": 1, "page": "home-screen"}),