amochka 0.4.4__tar.gz → 0.4.5__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.
- {amochka-0.4.4 → amochka-0.4.5}/PKG-INFO +1 -1
- {amochka-0.4.4 → amochka-0.4.5}/amochka/__init__.py +1 -1
- {amochka-0.4.4 → amochka-0.4.5}/amochka/client.py +11 -1
- {amochka-0.4.4 → amochka-0.4.5}/amochka.egg-info/PKG-INFO +1 -1
- {amochka-0.4.4 → amochka-0.4.5}/pyproject.toml +1 -1
- {amochka-0.4.4 → amochka-0.4.5}/tests/test_client.py +37 -0
- {amochka-0.4.4 → amochka-0.4.5}/README.md +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/amochka/errors.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/amochka/etl.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/amochka.egg-info/SOURCES.txt +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/amochka.egg-info/dependency_links.txt +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/amochka.egg-info/requires.txt +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/amochka.egg-info/top_level.txt +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/etl/__init__.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/etl/config.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/etl/extractors.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/etl/loaders.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/etl/migrations/001_create_tables.sql +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/etl/run_etl.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/etl/transformers.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/setup.cfg +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/tests/test_cache.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/tests/test_etl.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/tests/test_http.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/tests/test_notes_events.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/tests/test_security.py +0 -0
- {amochka-0.4.4 → amochka-0.4.5}/tests/test_utils.py +0 -0
|
@@ -1093,12 +1093,17 @@ class AmoCRMClient:
|
|
|
1093
1093
|
updated_from: Optional[Union[int, float, str, datetime]] = None,
|
|
1094
1094
|
updated_to: Optional[Union[int, float, str, datetime]] = None,
|
|
1095
1095
|
contact_ids: Optional[Union[int, Sequence[Union[int, str]]]] = None,
|
|
1096
|
+
query: Optional[str] = None,
|
|
1097
|
+
min_query_length: Optional[int] = None,
|
|
1096
1098
|
limit: int = 250,
|
|
1097
1099
|
extra_params: Optional[dict] = None,
|
|
1098
1100
|
max_pages: Optional[int] = None,
|
|
1099
1101
|
) -> Iterator[dict]:
|
|
1100
1102
|
"""
|
|
1101
|
-
Итератор контактов с фильтрацией по диапазону
|
|
1103
|
+
Итератор контактов с фильтрацией по диапазону обновления, списку ID или query.
|
|
1104
|
+
|
|
1105
|
+
:param query: Строка поиска (например, телефон). Перед отправкой очищается до цифр.
|
|
1106
|
+
:param min_query_length: Минимальная длина query (по числу цифр). Если не достигнута, query не отправляется.
|
|
1102
1107
|
|
|
1103
1108
|
:param max_pages: Максимальное количество страниц для итерации (None = без ограничений)
|
|
1104
1109
|
:raises ValidationError: Если параметры имеют некорректный тип или значение.
|
|
@@ -1135,6 +1140,11 @@ class AmoCRMClient:
|
|
|
1135
1140
|
contact_param = self._format_filter_values(contact_ids)
|
|
1136
1141
|
if contact_param:
|
|
1137
1142
|
params["filter[id][]"] = contact_param
|
|
1143
|
+
if query is not None:
|
|
1144
|
+
query_digits = "".join(ch for ch in query.strip() if ch.isdigit())
|
|
1145
|
+
if query_digits:
|
|
1146
|
+
if min_query_length is None or len(query_digits) >= min_query_length:
|
|
1147
|
+
params["query"] = query_digits
|
|
1138
1148
|
if extra_params:
|
|
1139
1149
|
params.update(extra_params)
|
|
1140
1150
|
|
|
@@ -20,6 +20,17 @@ from amochka import (
|
|
|
20
20
|
)
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
def make_client():
|
|
24
|
+
import time
|
|
25
|
+
token_data = {"access_token": "token", "expires_at": str(time.time() + 3600)}
|
|
26
|
+
return AmoCRMClient(
|
|
27
|
+
base_url="https://example.amocrm.ru",
|
|
28
|
+
token_file=json.dumps(token_data),
|
|
29
|
+
cache_config=CacheConfig.disabled(),
|
|
30
|
+
disable_logging=True,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
23
34
|
class DummyClient(AmoCRMClient):
|
|
24
35
|
def __init__(self):
|
|
25
36
|
import time
|
|
@@ -260,3 +271,29 @@ def test_export_helpers_write_expected_files(tmp_path):
|
|
|
260
271
|
|
|
261
272
|
notes_call = next(item for item in client.calls if item[1] == "/api/v4/leads/notes")
|
|
262
273
|
assert notes_call[2]["filter[updated_at][from]"] is None or notes_call[2]["filter[updated_at][from]"] >= 0
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def test_iter_contacts_query_param(monkeypatch):
|
|
277
|
+
client = make_client()
|
|
278
|
+
captured = {}
|
|
279
|
+
|
|
280
|
+
def fake_request(method, endpoint, params=None, **kwargs):
|
|
281
|
+
captured["params"] = params
|
|
282
|
+
return {"_embedded": {"contacts": []}, "_page_count": 1}
|
|
283
|
+
|
|
284
|
+
monkeypatch.setattr(client, "_make_request", fake_request)
|
|
285
|
+
list(client.iter_contacts(query="7925", max_pages=1))
|
|
286
|
+
assert captured["params"]["query"] == "7925"
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
def test_iter_contacts_query_min_length(monkeypatch):
|
|
290
|
+
client = make_client()
|
|
291
|
+
captured = {}
|
|
292
|
+
|
|
293
|
+
def fake_request(method, endpoint, params=None, **kwargs):
|
|
294
|
+
captured["params"] = params
|
|
295
|
+
return {"_embedded": {"contacts": []}, "_page_count": 1}
|
|
296
|
+
|
|
297
|
+
monkeypatch.setattr(client, "_make_request", fake_request)
|
|
298
|
+
list(client.iter_contacts(query="7925", min_query_length=8, max_pages=1))
|
|
299
|
+
assert "query" not in captured["params"]
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|