Skip to content

Commit

Permalink
yandex: order_label method
Browse files Browse the repository at this point in the history
  • Loading branch information
CralixRaev committed Dec 26, 2023
1 parent 66026bc commit ecae194
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions marketplace_apis/yandex/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# region orders
"list_orders": "orders",
"get_order_by_number": "orders",
"get_delivery_labels": "delivery/labels",
# endregion
# region oauth
"oauth_token": "https://oauth.yandex.ru/token",
Expand Down
2 changes: 1 addition & 1 deletion marketplace_apis/yandex/market_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(
)
# print(api.warehouse.list_fby_warehouses())
# print(api.warehouse.list_warehouses())
# print(api.order.list_orders()[-1])
# print(api.order.list_orders(status=OrderStatusType.PROCESSING)[-1])
# print(MarketApi.oauth.get_tokens_by_code(
# os.getenv("CLIENT_ID"),
# os.getenv("CLIENT_SECRET"), 8863298
Expand Down
17 changes: 16 additions & 1 deletion marketplace_apis/yandex/order/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from marketplace_apis.yandex.base import UTC3Timezone
from marketplace_apis.yandex.endpoints import API_PATH
from marketplace_apis.yandex.market_api_requester import MarketApiRequester
from marketplace_apis.yandex.order.methods_types import ListOrders
from marketplace_apis.yandex.order.methods_types import ListOrders, PageFormatType
from marketplace_apis.yandex.order.order import Order


Expand Down Expand Up @@ -71,3 +71,18 @@ def make_request():
# data={"posting_number": posting_number, "with": with_},
# )
# return Posting.from_dict(data["result"])

def get_label(self, order_id: int, format_: PageFormatType | None = None) -> bytes:
"""Get all labels for order in specified format.
:param order_id: order id.
:param format_: pdf file format. Defaults to A6
:return: PDF-file with all labels"""
_, data = self._requester.get(
self._requester.build_campaign_url(
f"orders/{order_id}/{API_PATH["get_delivery_labels"]}"
),
decode=False,
params={"format": format_},
)
return data
10 changes: 10 additions & 0 deletions marketplace_apis/yandex/order/methods_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
from datetime import datetime, date
from enum import StrEnum
from typing import TypedDict, NotRequired

from marketplace_apis.yandex.order.enums import (
Expand Down Expand Up @@ -72,3 +73,12 @@ class ListOrders(TypedDict):
* ``true`` — возвращаются только заказы с неподтвержденной датой доставки.
* ``false`` — фильтрация не применяется."""


class PageFormatType(StrEnum):
"""Параметр управляет размещением ярлыков на странице"""

A7 = "A7"
"""в PDF-файле будут странички размером A7, на каждой из которых разместится один ярлык"""
A4 = "A4"
"""PDF-файл будет состоять из страниц A4, на каждой из которых будет по восемь ярлыков."""

0 comments on commit ecae194

Please sign in to comment.