amochka 0.4.3__tar.gz → 0.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {amochka-0.4.3 → amochka-0.4.4}/PKG-INFO +1 -1
  2. {amochka-0.4.3 → amochka-0.4.4}/amochka/__init__.py +1 -1
  3. {amochka-0.4.3 → amochka-0.4.4}/amochka/client.py +9 -4
  4. {amochka-0.4.3 → amochka-0.4.4}/amochka.egg-info/PKG-INFO +1 -1
  5. {amochka-0.4.3 → amochka-0.4.4}/pyproject.toml +1 -1
  6. {amochka-0.4.3 → amochka-0.4.4}/tests/test_notes_events.py +40 -0
  7. {amochka-0.4.3 → amochka-0.4.4}/README.md +0 -0
  8. {amochka-0.4.3 → amochka-0.4.4}/amochka/errors.py +0 -0
  9. {amochka-0.4.3 → amochka-0.4.4}/amochka/etl.py +0 -0
  10. {amochka-0.4.3 → amochka-0.4.4}/amochka.egg-info/SOURCES.txt +0 -0
  11. {amochka-0.4.3 → amochka-0.4.4}/amochka.egg-info/dependency_links.txt +0 -0
  12. {amochka-0.4.3 → amochka-0.4.4}/amochka.egg-info/requires.txt +0 -0
  13. {amochka-0.4.3 → amochka-0.4.4}/amochka.egg-info/top_level.txt +0 -0
  14. {amochka-0.4.3 → amochka-0.4.4}/etl/__init__.py +0 -0
  15. {amochka-0.4.3 → amochka-0.4.4}/etl/config.py +0 -0
  16. {amochka-0.4.3 → amochka-0.4.4}/etl/extractors.py +0 -0
  17. {amochka-0.4.3 → amochka-0.4.4}/etl/loaders.py +0 -0
  18. {amochka-0.4.3 → amochka-0.4.4}/etl/migrations/001_create_tables.sql +0 -0
  19. {amochka-0.4.3 → amochka-0.4.4}/etl/run_etl.py +0 -0
  20. {amochka-0.4.3 → amochka-0.4.4}/etl/transformers.py +0 -0
  21. {amochka-0.4.3 → amochka-0.4.4}/setup.cfg +0 -0
  22. {amochka-0.4.3 → amochka-0.4.4}/tests/test_cache.py +0 -0
  23. {amochka-0.4.3 → amochka-0.4.4}/tests/test_client.py +0 -0
  24. {amochka-0.4.3 → amochka-0.4.4}/tests/test_etl.py +0 -0
  25. {amochka-0.4.3 → amochka-0.4.4}/tests/test_http.py +0 -0
  26. {amochka-0.4.3 → amochka-0.4.4}/tests/test_security.py +0 -0
  27. {amochka-0.4.3 → amochka-0.4.4}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amochka
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: Python library for working with amoCRM API with ETL capabilities
5
5
  Author-email: Timur <timurdt@gmail.com>
6
6
  License: MIT
@@ -2,7 +2,7 @@
2
2
  amochka: Библиотека для работы с API amoCRM.
3
3
  """
4
4
 
5
- __version__ = "0.4.3"
5
+ __version__ = "0.4.4"
6
6
 
7
7
  from .client import AmoCRMClient, CacheConfig
8
8
  from .errors import (
@@ -1228,6 +1228,8 @@ class AmoCRMClient:
1228
1228
  if end_ts is not None:
1229
1229
  params["filter[updated_at][to]"] = end_ts
1230
1230
  note_type_param = self._format_filter_values(note_type)
1231
+ if isinstance(note_type_param, (list, tuple, set)):
1232
+ note_type_param = ",".join(note_type_param)
1231
1233
  if note_type_param:
1232
1234
  params["filter[note_type]"] = note_type_param
1233
1235
  entity_param = self._format_filter_values(entity_ids)
@@ -1597,8 +1599,11 @@ class AmoCRMClient:
1597
1599
  "page": 1,
1598
1600
  "limit": 250
1599
1601
  }
1600
- if note_type is not None:
1601
- params["filter[note_type]"] = note_type
1602
+ note_type_param = self._format_filter_values(note_type)
1603
+ if isinstance(note_type_param, (list, tuple, set)):
1604
+ note_type_param = ",".join(note_type_param)
1605
+ if note_type_param:
1606
+ params["filter[note_type]"] = note_type_param
1602
1607
  if extra_params:
1603
1608
  params.update(extra_params)
1604
1609
 
@@ -1606,7 +1611,7 @@ class AmoCRMClient:
1606
1611
  while True:
1607
1612
  response = self._make_request("GET", endpoint, params=params)
1608
1613
  if not response:
1609
- self.logger.warning(f"Empty response for notes {entity} {entity_id}, stopping pagination")
1614
+ self.logger.debug(f"Empty response for notes {entity} {entity_id}, stopping pagination")
1610
1615
  break
1611
1616
  if response and "_embedded" in response and "notes" in response["_embedded"]:
1612
1617
  notes.extend(response["_embedded"]["notes"])
@@ -1690,7 +1695,7 @@ class AmoCRMClient:
1690
1695
  while True:
1691
1696
  response = self._make_request("GET", "/api/v4/events", params=params)
1692
1697
  if not response:
1693
- self.logger.warning(f"Empty response for events {entity} {entity_id}, stopping pagination")
1698
+ self.logger.debug(f"Empty response for events {entity} {entity_id}, stopping pagination")
1694
1699
  break
1695
1700
  if response and "_embedded" in response and "events" in response["_embedded"]:
1696
1701
  events.extend(response["_embedded"]["events"])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: amochka
3
- Version: 0.4.3
3
+ Version: 0.4.4
4
4
  Summary: Python library for working with amoCRM API with ETL capabilities
5
5
  Author-email: Timur <timurdt@gmail.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "amochka"
7
- version = "0.4.3"
7
+ version = "0.4.4"
8
8
  description = "Python library for working with amoCRM API with ETL capabilities"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -32,6 +32,46 @@ def test_get_entity_events_handles_none_response(monkeypatch):
32
32
  assert client.get_entity_events("lead", 1, get_all=True) == []
33
33
 
34
34
 
35
+ def test_get_entity_notes_note_type_list_serialized(monkeypatch):
36
+ client = make_client()
37
+ captured = {}
38
+
39
+ def fake_request(method, endpoint, params=None, **kwargs):
40
+ captured["params"] = params
41
+ return {"_embedded": {"notes": []}, "_page_count": 1}
42
+
43
+ monkeypatch.setattr(client, "_make_request", fake_request)
44
+ notes = client.get_entity_notes("lead", 1, note_type=["common", "call_in"])
45
+ assert notes == []
46
+ assert captured["params"]["filter[note_type]"] == "common,call_in"
47
+
48
+
49
+ def test_get_entity_notes_note_type_string_kept(monkeypatch):
50
+ client = make_client()
51
+ captured = {}
52
+
53
+ def fake_request(method, endpoint, params=None, **kwargs):
54
+ captured["params"] = params
55
+ return {"_embedded": {"notes": []}, "_page_count": 1}
56
+
57
+ monkeypatch.setattr(client, "_make_request", fake_request)
58
+ client.get_entity_notes("lead", 1, note_type="common")
59
+ assert captured["params"]["filter[note_type]"] == "common"
60
+
61
+
62
+ def test_iter_notes_note_type_list_serialized(monkeypatch):
63
+ client = make_client()
64
+ captured = {}
65
+
66
+ def fake_request(method, endpoint, params=None, **kwargs):
67
+ captured["params"] = params
68
+ return {"_embedded": {"notes": []}, "_page_count": 1}
69
+
70
+ monkeypatch.setattr(client, "_make_request", fake_request)
71
+ list(client.iter_notes(note_type=["common", "call_in"], max_pages=1))
72
+ assert captured["params"]["filter[note_type]"] == "common,call_in"
73
+
74
+
35
75
  def test_get_entity_note_invalid_response_raises(monkeypatch):
36
76
  client = make_client()
37
77
  monkeypatch.setattr(client, "_make_request", lambda *args, **kwargs: None)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes