amochka 0.4.3__py3-none-any.whl → 0.4.5__py3-none-any.whl

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/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
  amochka: Библиотека для работы с API amoCRM.
3
3
  """
4
4
 
5
- __version__ = "0.4.3"
5
+ __version__ = "0.4.5"
6
6
 
7
7
  from .client import AmoCRMClient, CacheConfig
8
8
  from .errors import (
amochka/client.py CHANGED
@@ -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
- Итератор контактов с фильтрацией по диапазону обновления или списку ID.
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
 
@@ -1228,6 +1238,8 @@ class AmoCRMClient:
1228
1238
  if end_ts is not None:
1229
1239
  params["filter[updated_at][to]"] = end_ts
1230
1240
  note_type_param = self._format_filter_values(note_type)
1241
+ if isinstance(note_type_param, (list, tuple, set)):
1242
+ note_type_param = ",".join(note_type_param)
1231
1243
  if note_type_param:
1232
1244
  params["filter[note_type]"] = note_type_param
1233
1245
  entity_param = self._format_filter_values(entity_ids)
@@ -1597,8 +1609,11 @@ class AmoCRMClient:
1597
1609
  "page": 1,
1598
1610
  "limit": 250
1599
1611
  }
1600
- if note_type is not None:
1601
- params["filter[note_type]"] = note_type
1612
+ note_type_param = self._format_filter_values(note_type)
1613
+ if isinstance(note_type_param, (list, tuple, set)):
1614
+ note_type_param = ",".join(note_type_param)
1615
+ if note_type_param:
1616
+ params["filter[note_type]"] = note_type_param
1602
1617
  if extra_params:
1603
1618
  params.update(extra_params)
1604
1619
 
@@ -1606,7 +1621,7 @@ class AmoCRMClient:
1606
1621
  while True:
1607
1622
  response = self._make_request("GET", endpoint, params=params)
1608
1623
  if not response:
1609
- self.logger.warning(f"Empty response for notes {entity} {entity_id}, stopping pagination")
1624
+ self.logger.debug(f"Empty response for notes {entity} {entity_id}, stopping pagination")
1610
1625
  break
1611
1626
  if response and "_embedded" in response and "notes" in response["_embedded"]:
1612
1627
  notes.extend(response["_embedded"]["notes"])
@@ -1690,7 +1705,7 @@ class AmoCRMClient:
1690
1705
  while True:
1691
1706
  response = self._make_request("GET", "/api/v4/events", params=params)
1692
1707
  if not response:
1693
- self.logger.warning(f"Empty response for events {entity} {entity_id}, stopping pagination")
1708
+ self.logger.debug(f"Empty response for events {entity} {entity_id}, stopping pagination")
1694
1709
  break
1695
1710
  if response and "_embedded" in response and "events" in response["_embedded"]:
1696
1711
  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.5
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
@@ -1,5 +1,5 @@
1
- amochka/__init__.py,sha256=SXqHWqb3-E2ixu87d6j8Bw8MF7TJ_3_hzSFe3vFUUVk,925
2
- amochka/client.py,sha256=z4E25n5JkK64Si_RZkc-rD735a9sxmWDtGqgGnffpIw,89189
1
+ amochka/__init__.py,sha256=xqqZUwHZXWpqCmIOmBirxG6KoN5wrezaG-ZMT_x6ttM,925
2
+ amochka/client.py,sha256=oAsFGXVIVC8IPdkbRdB-d16VFUb78FhZGhOBSFcrxJI,90171
3
3
  amochka/errors.py,sha256=Rg4U9srjboQwgU3wwhAed0p3vGcc0ZhuyKHIDhYFnp8,1371
4
4
  amochka/etl.py,sha256=tzdGPRGxR49aSAjLksic-FqechvDUTfK8ZUUJGuIU7M,8960
5
5
  etl/__init__.py,sha256=bp9fPqbKlOc7xzs27diHEvysy1FgBrwlpX6GnR6GL9U,255
@@ -9,7 +9,7 @@ etl/loaders.py,sha256=x8PcDQoq2kjbd52H2VzKKz5vHzyD6DXSsb9X0foPX_U,31941
9
9
  etl/run_etl.py,sha256=LxKQLE_yUPkg7kaFmmMxrdggz27puS1VdV9NTna9e4Q,26665
10
10
  etl/transformers.py,sha256=OwYJ_9l3oqvy2Y3-umXjAGweOIqlfRI0iSiCFPrcQ8E,17867
11
11
  etl/migrations/001_create_tables.sql,sha256=YrSaZjpofC1smjYx0bM4eHQumboruIBY3fwRDlJLLSo,15749
12
- amochka-0.4.3.dist-info/METADATA,sha256=nRqy4mnZ-FRsmNdZNCLsooEZjQKbceZwDdzQ_cAEoyU,7530
13
- amochka-0.4.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- amochka-0.4.3.dist-info/top_level.txt,sha256=grRX8aLFG-yYKPsAqCD6sUBmdLSQeOMHsc9Dl6S7Lzo,12
15
- amochka-0.4.3.dist-info/RECORD,,
12
+ amochka-0.4.5.dist-info/METADATA,sha256=4OROMcyke4Ffs6xli8q1FJaY4xrmvfzimubSfqegZjY,7530
13
+ amochka-0.4.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ amochka-0.4.5.dist-info/top_level.txt,sha256=grRX8aLFG-yYKPsAqCD6sUBmdLSQeOMHsc9Dl6S7Lzo,12
15
+ amochka-0.4.5.dist-info/RECORD,,