wbapi-async 0.6.2__tar.gz → 0.7.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wbapi-async
3
- Version: 0.6.2
3
+ Version: 0.7.1
4
4
  Summary: Asynchronous client for Wildberries API
5
5
  Project-URL: Documentation, https://serdukow.github.io/wbapi-async/
6
6
  Project-URL: Repository, https://github.com/serdukow/wbapi-async
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "wbapi-async"
7
- version = "0.6.2"
7
+ version = "0.7.1"
8
8
  description = "Asynchronous client for Wildberries API"
9
9
  authors = [
10
10
  { name = "Andrei Serdiukov", email = "asyncdf@gmail.com" },
@@ -575,9 +575,9 @@ class MethodDispatcher:
575
575
  body = kwargs.pop("body", None)
576
576
  http_method = "POST" if body is not None else "GET"
577
577
 
578
- def _do_request(extra: dict[str, Any] | None = None) -> Any:
578
+ def _do_request(extra: dict[str, Any] | None = None, extra_body: dict[str, Any] | None = None) -> Any:
579
579
  if body is not None:
580
- json = {**body, **(extra or {})}
580
+ json = {**body, **(extra or {}), **(extra_body or {})}
581
581
  return self.dispatch(http_method, path, params=kwargs or None, json=json)
582
582
  params = {**kwargs, **(extra or {})} or None
583
583
  return self.dispatch(http_method, path, params=params)
@@ -601,6 +601,34 @@ class MethodDispatcher:
601
601
 
602
602
  result: list[Any] = list(page)
603
603
 
604
+ # rrd_id cursor — detected by presence of rrd_id in last item
605
+ if page and isinstance(page[-1], dict) and "rrd_id" in page[-1]:
606
+ while page:
607
+ rrd_id = page[-1]["rrd_id"]
608
+ page = _extract_list(await _do_request({"rrdid": rrd_id})) or []
609
+ result.extend(page)
610
+ return result
611
+
612
+ # lastChangeDate cursor — detected by presence of lastChangeDate in last item
613
+ if page and isinstance(page[-1], dict) and "lastChangeDate" in page[-1]:
614
+ while page:
615
+ date_from = page[-1]["lastChangeDate"]
616
+ page = _extract_list(await _do_request({"dateFrom": date_from})) or []
617
+ result.extend(page)
618
+ return result
619
+
620
+ # cursor in response body — for POST endpoints like /content/v2/get/cards/list
621
+ if body is not None and isinstance(raw, dict) and "cursor" in raw:
622
+ cursor_val = raw["cursor"]
623
+ while cursor_val:
624
+ raw = await _do_request(extra_body={"cursor": cursor_val})
625
+ page = _extract_list(raw)
626
+ if not page:
627
+ break
628
+ result.extend(page)
629
+ cursor_val = raw.get("cursor") if isinstance(raw, dict) else None
630
+ return result
631
+
604
632
  # Cursor pagination
605
633
  if isinstance(raw, dict) and "next" in raw:
606
634
  cursor = raw["next"]
File without changes
File without changes
File without changes