Skip to content

methods

OfferMappingMethods

Bases: MarketApiABCMethods

list_offer_mappings async

Python
1
list_offer_mappings(limit: int = 50, iter_: bool = True, **kwargs: Unpack[ListOfferMappings]) -> list[OfferMapping]

List offer mappings. :param limit: Maximum amount of offer mappings what will be retrieved in one request :param iter_: Whenever to get all offer mappings by making multiple requests or not

:return: List of offer mappings

Source code in marketplace_apis/yandex/offer_mapping/methods.py
Python
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
async def list_offer_mappings(
    self, limit: int = 50, iter_: bool = True, **kwargs: Unpack[ListOfferMappings]
) -> list[OfferMapping]:
    """List offer mappings.
    :param limit: Maximum amount of offer mappings what will be retrieved in one
    request
    :param iter_: Whenever to get all offer mappings by making multiple requests or
    not

    :return: List of offer mappings
    """
    raw_offer_mappings = []

    page_token = None

    async def make_request():
        resp, decoded_resp = await self.client.post(
            self.client.build_business_url(API_PATH["list_offer_mappings"]),
            data=kwargs,
            params={
                "limit": limit if not kwargs else None,
                "page_token": page_token,
            },
        )
        nonlocal raw_offer_mappings
        raw_offer_mappings += decoded_resp["result"]["offerMappings"]
        return resp, decoded_resp

    _, data = await make_request()
    while iter_ and "nextPageToken" in data["result"]["paging"]:
        page_token = data["result"]["paging"]["nextPageToken"]
        _, data = await make_request()

    return [
        OfferMapping.from_dict(raw_offer_mapping)
        for raw_offer_mapping in raw_offer_mappings
    ]