cdek.apps.tariff package¶
- class cdek.apps.tariff.AvailableTariff(*, tariff_name: str | None = None, weight_min: float | None = None, weight_max: float | None = None, weight_calc_max: float | None = None, length_min: int | None = None, length_max: int | None = None, width_min: int | None = None, width_max: int | None = None, height_min: int | None = None, height_max: int | None = None, order_types: list[str] | None = None, payer_contragent_type: list[str] | None = None, sender_contragent_type: list[str] | None = None, recipient_contragent_type: list[str] | None = None, delivery_modes: list[DeliveryMode] | None = None, additional_order_types_param: dict[str, Any] | None = None)[исходный код]¶
Базовые классы:
BaseModel- additional_order_types_param: dict[str, Any] | None¶
- delivery_modes: list[DeliveryMode] | None¶
- height_max: int | None¶
- height_min: int | None¶
- length_max: int | None¶
- length_min: int | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- order_types: list[str] | None¶
- payer_contragent_type: list[str] | None¶
- recipient_contragent_type: list[str] | None¶
- sender_contragent_type: list[str] | None¶
- tariff_name: str | None¶
- weight_calc_max: float | None¶
- weight_max: float | None¶
- weight_min: float | None¶
- width_max: int | None¶
- width_min: int | None¶
- class cdek.apps.tariff.CalcAdditionalService(*, code: str | None = None, parameter: str | None = None)[исходный код]¶
Базовые классы:
BaseModel- code: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parameter: str | None¶
- class cdek.apps.tariff.CalculatorLocation(*, longitude: float | None = None, latitude: float | None = None, postal_code: str | None = None, code: int | None = None, country_code: Annotated[str | None, MaxLen(max_length=2)] = None, city: str | None = None, address: str | None = None, contragent_type: ContragentType | None = None)[исходный код]¶
Базовые классы:
Zip,Coordinates- address: str | None¶
- city: str | None¶
- code: int | None¶
- contragent_type: ContragentType | None¶
- country_code: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class cdek.apps.tariff.DeliveryDateRange(*, min: str | None = None, max: str | None = None)[исходный код]¶
Базовые классы:
BaseModel- max: str | None¶
- min: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class cdek.apps.tariff.DeliveryMode(*, delivery_mode: str | None = None, delivery_mode_name: str | None = None, tariff_code: int | None = None)[исходный код]¶
Базовые классы:
BaseModelМодель для режима доставки.
- delivery_mode: str | None¶
- delivery_mode_name: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tariff_code: int | None¶
- class cdek.apps.tariff.Services(*, code: str, sum: float, total_sum: float, discount_percent: float, discount_sum: float, vat_rate: float, vat_sum: float)[исходный код]¶
Базовые классы:
BaseModelМодель ответа для дополнительных услуг.
- code: str¶
- discount_percent: float¶
- discount_sum: float¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sum: float¶
- total_sum: float¶
- vat_rate: float¶
- vat_sum: float¶
- class cdek.apps.tariff.TariffApp(client: CdekClient)[исходный код]¶
Базовые классы:
AppКласс для работы с тарифами
- all() TariffAvailableResponse[исходный код]¶
Список доступных тарифов Метод позволяет получить список всех доступных и актуальных тарифов по договору
- Returns:
Список объектов TariffAvailableResponse с информацией о доступных тарифах
- calc(tariff: TariffCodeRequest) TariffResponse[исходный код]¶
Расчёт стоимости и сроков доставки по коду тарифа
- Args:
tariff: объект TariffCodeRequest с параметрами запроса (tariff_code, from_location, to_location, packages)
- Returns:
TariffResponse: объект с информацией о расчёте стоимости и сроков доставки
- Raises:
ValueError: если tariff не является объектом TariffCodeRequest
- calc_list(tariff: TariffListRequest) TariffListResponse[исходный код]¶
Расчёт стоимости и сроков доставки по всем доступным тарифам
- Args:
tariff: объект Tariff с параметрами запроса (type, from_location, to_location, packages)
- Returns:
Список объектов TariffListResponse с информацией о доступных тарифах
- Raises:
ValueError: если tariff не является объектом TariffListRequest
- class cdek.apps.tariff.TariffAvailableResponse(*, tariff_codes: list[AvailableTariff] | None = None)[исходный код]¶
Базовые классы:
BaseModelМодель ответа о доступных тарифах.
- get_codes() list[AvailableTariff][исходный код]¶
Вернуть список доступных тарифов без значений None
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tariff_codes: list[AvailableTariff] | None¶
- class cdek.apps.tariff.TariffCodeRequest(*, date: datetime | None = None, type: int = 1, additional_order_types: list[int] | None = None, currency: int | None = None, lang: Annotated[str, MaxLen(max_length=3)] = 'rus', from_location: CalculatorLocation | None = None, to_location: CalculatorLocation | None = None, packages: list[CalcPackage] | None = None, tariff_code: int, services: list[CalcAdditionalService] | None = None)[исходный код]¶
Базовые классы:
TariffListRequest- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- services: list[CalcAdditionalService] | None¶
- tariff_code: int¶
- class cdek.apps.tariff.TariffListItem(*, tariff_code: int, tariff_name: Annotated[str, MaxLen(max_length=255)], tariff_description: Annotated[str | None, MaxLen(max_length=255)] = None, delivery_mode: int, delivery_sum: float, period_min: int, period_max: int, calendar_min: int | None = None, calendar_max: int | None = None, delivery_date_range: DeliveryDateRange | None = None)[исходный код]¶
Базовые классы:
BaseModelМодель элемента списка тарифов.
- calendar_max: int | None¶
- calendar_min: int | None¶
- delivery_date_range: DeliveryDateRange | None¶
- delivery_mode: int¶
- delivery_sum: float¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- period_max: int¶
- period_min: int¶
- tariff_code: int¶
- tariff_description: str | None¶
- tariff_name: str¶
- class cdek.apps.tariff.TariffListRequest(*, date: datetime | None = None, type: int = 1, additional_order_types: list[int] | None = None, currency: int | None = None, lang: Annotated[str, MaxLen(max_length=3)] = 'rus', from_location: CalculatorLocation | None = None, to_location: CalculatorLocation | None = None, packages: list[CalcPackage] | None = None)[исходный код]¶
Базовые классы:
BaseModel- additional_order_types: list[int] | None¶
- currency: int | None¶
- date: datetime | None¶
- from_location: CalculatorLocation | None¶
- lang: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- packages: list[CalcPackage] | None¶
- serialize_date(date: datetime) str[исходный код]¶
Сериализовать дату в формат, поддерживаемый API
- set_city_codes(from_location: int, to_location: int) TariffListRequest[исходный код]¶
Задать коды населённых пунктов отправителя и получателя
- set_package_weight(weight: int) TariffListRequest[исходный код]¶
Определить вес единственной упаковки в граммах
- to_location: CalculatorLocation | None¶
- type: int¶
- class cdek.apps.tariff.TariffListResponse(*, tariff_codes: list[~cdek.apps.tariff.responses.TariffListItem] | None = <factory>, errors: list[~cdek.apps.models.error.Error] | None = None, warnings: list[~cdek.apps.models.warning.WarningModel] | None = None)[исходный код]¶
Базовые классы:
BaseModelМодель ответа со списком тарифов.
- get_codes() list[TariffListItem][исходный код]¶
Вернуть список тарифов, гарантируя, что результат не None
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tariff_codes: list[TariffListItem] | None¶
- warnings: list[WarningModel] | None¶
- class cdek.apps.tariff.TariffResponse(*, delivery_sum: float, period_min: int, period_max: int, calendar_min: int | None = None, calendar_max: int | None = None, weight_calc: int, services: list[Services] | None = None, total_sum: float, currency: str, errors: list[Error] | None = None, warnings: list[WarningModel] | None = None, delivery_date_range: DeliveryDateRange | None = None)[исходный код]¶
Базовые классы:
BaseModel- calendar_max: int | None¶
- calendar_min: int | None¶
- currency: str¶
- delivery_date_range: DeliveryDateRange | None¶
- delivery_sum: float¶
- get_calendar_max() int | None[исходный код]¶
Получить максимальный период доставки.
- get_calendar_min() int | None[исходный код]¶
Получить минимальный период доставки.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- period_max: int¶
- period_min: int¶
- total_sum: float¶
- warnings: list[WarningModel] | None¶
- weight_calc: int¶
Submodules¶
cdek.apps.tariff.requests module¶
- class cdek.apps.tariff.requests.CalcAdditionalService(*, code: str | None = None, parameter: str | None = None)[исходный код]¶
Базовые классы:
BaseModel- code: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- parameter: str | None¶
- class cdek.apps.tariff.requests.CalculatorLocation(*, longitude: float | None = None, latitude: float | None = None, postal_code: str | None = None, code: int | None = None, country_code: Annotated[str | None, MaxLen(max_length=2)] = None, city: str | None = None, address: str | None = None, contragent_type: ContragentType | None = None)[исходный код]¶
Базовые классы:
Zip,Coordinates- address: str | None¶
- city: str | None¶
- code: int | None¶
- contragent_type: ContragentType | None¶
- country_code: str | None¶
- latitude: float | None¶
- longitude: float | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- postal_code: str | None¶
- class cdek.apps.tariff.requests.TariffCodeRequest(*, date: datetime | None = None, type: int = 1, additional_order_types: list[int] | None = None, currency: int | None = None, lang: Annotated[str, MaxLen(max_length=3)] = 'rus', from_location: CalculatorLocation | None = None, to_location: CalculatorLocation | None = None, packages: list[CalcPackage] | None = None, tariff_code: int, services: list[CalcAdditionalService] | None = None)[исходный код]¶
Базовые классы:
TariffListRequest- additional_order_types: list[int] | None¶
- currency: int | None¶
- date: datetime | None¶
- from_location: CalculatorLocation | None¶
- lang: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- packages: list[CalcPackage] | None¶
- services: list[CalcAdditionalService] | None¶
- tariff_code: int¶
- to_location: CalculatorLocation | None¶
- type: int¶
- class cdek.apps.tariff.requests.TariffListRequest(*, date: datetime | None = None, type: int = 1, additional_order_types: list[int] | None = None, currency: int | None = None, lang: Annotated[str, MaxLen(max_length=3)] = 'rus', from_location: CalculatorLocation | None = None, to_location: CalculatorLocation | None = None, packages: list[CalcPackage] | None = None)[исходный код]¶
Базовые классы:
BaseModel- additional_order_types: list[int] | None¶
- currency: int | None¶
- date: datetime | None¶
- from_location: CalculatorLocation | None¶
- lang: str¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- packages: list[CalcPackage] | None¶
- serialize_date(date: datetime) str[исходный код]¶
Сериализовать дату в формат, поддерживаемый API
- set_city_codes(from_location: int, to_location: int) TariffListRequest[исходный код]¶
Задать коды населённых пунктов отправителя и получателя
- set_package_weight(weight: int) TariffListRequest[исходный код]¶
Определить вес единственной упаковки в граммах
- to_location: CalculatorLocation | None¶
- type: int¶
cdek.apps.tariff.responses module¶
- class cdek.apps.tariff.responses.AvailableTariff(*, tariff_name: str | None = None, weight_min: float | None = None, weight_max: float | None = None, weight_calc_max: float | None = None, length_min: int | None = None, length_max: int | None = None, width_min: int | None = None, width_max: int | None = None, height_min: int | None = None, height_max: int | None = None, order_types: list[str] | None = None, payer_contragent_type: list[str] | None = None, sender_contragent_type: list[str] | None = None, recipient_contragent_type: list[str] | None = None, delivery_modes: list[DeliveryMode] | None = None, additional_order_types_param: dict[str, Any] | None = None)[исходный код]¶
Базовые классы:
BaseModel- additional_order_types_param: dict[str, Any] | None¶
- delivery_modes: list[DeliveryMode] | None¶
- height_max: int | None¶
- height_min: int | None¶
- length_max: int | None¶
- length_min: int | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- order_types: list[str] | None¶
- payer_contragent_type: list[str] | None¶
- recipient_contragent_type: list[str] | None¶
- sender_contragent_type: list[str] | None¶
- tariff_name: str | None¶
- weight_calc_max: float | None¶
- weight_max: float | None¶
- weight_min: float | None¶
- width_max: int | None¶
- width_min: int | None¶
- class cdek.apps.tariff.responses.DeliveryDateRange(*, min: str | None = None, max: str | None = None)[исходный код]¶
Базовые классы:
BaseModel- max: str | None¶
- min: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class cdek.apps.tariff.responses.DeliveryMode(*, delivery_mode: str | None = None, delivery_mode_name: str | None = None, tariff_code: int | None = None)[исходный код]¶
Базовые классы:
BaseModelМодель для режима доставки.
- delivery_mode: str | None¶
- delivery_mode_name: str | None¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tariff_code: int | None¶
- class cdek.apps.tariff.responses.Services(*, code: str, sum: float, total_sum: float, discount_percent: float, discount_sum: float, vat_rate: float, vat_sum: float)[исходный код]¶
Базовые классы:
BaseModelМодель ответа для дополнительных услуг.
- code: str¶
- discount_percent: float¶
- discount_sum: float¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- sum: float¶
- total_sum: float¶
- vat_rate: float¶
- vat_sum: float¶
- class cdek.apps.tariff.responses.TariffAvailableResponse(*, tariff_codes: list[AvailableTariff] | None = None)[исходный код]¶
Базовые классы:
BaseModelМодель ответа о доступных тарифах.
- get_codes() list[AvailableTariff][исходный код]¶
Вернуть список доступных тарифов без значений None
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tariff_codes: list[AvailableTariff] | None¶
- class cdek.apps.tariff.responses.TariffListItem(*, tariff_code: int, tariff_name: Annotated[str, MaxLen(max_length=255)], tariff_description: Annotated[str | None, MaxLen(max_length=255)] = None, delivery_mode: int, delivery_sum: float, period_min: int, period_max: int, calendar_min: int | None = None, calendar_max: int | None = None, delivery_date_range: DeliveryDateRange | None = None)[исходный код]¶
Базовые классы:
BaseModelМодель элемента списка тарифов.
- calendar_max: int | None¶
- calendar_min: int | None¶
- delivery_date_range: DeliveryDateRange | None¶
- delivery_mode: int¶
- delivery_sum: float¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- period_max: int¶
- period_min: int¶
- tariff_code: int¶
- tariff_description: str | None¶
- tariff_name: str¶
- class cdek.apps.tariff.responses.TariffListResponse(*, tariff_codes: list[~cdek.apps.tariff.responses.TariffListItem] | None = <factory>, errors: list[~cdek.apps.models.error.Error] | None = None, warnings: list[~cdek.apps.models.warning.WarningModel] | None = None)[исходный код]¶
Базовые классы:
BaseModelМодель ответа со списком тарифов.
- get_codes() list[TariffListItem][исходный код]¶
Вернуть список тарифов, гарантируя, что результат не None
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- tariff_codes: list[TariffListItem] | None¶
- warnings: list[WarningModel] | None¶
- class cdek.apps.tariff.responses.TariffResponse(*, delivery_sum: float, period_min: int, period_max: int, calendar_min: int | None = None, calendar_max: int | None = None, weight_calc: int, services: list[Services] | None = None, total_sum: float, currency: str, errors: list[Error] | None = None, warnings: list[WarningModel] | None = None, delivery_date_range: DeliveryDateRange | None = None)[исходный код]¶
Базовые классы:
BaseModel- calendar_max: int | None¶
- calendar_min: int | None¶
- currency: str¶
- delivery_date_range: DeliveryDateRange | None¶
- delivery_sum: float¶
- get_calendar_max() int | None[исходный код]¶
Получить максимальный период доставки.
- get_calendar_min() int | None[исходный код]¶
Получить минимальный период доставки.
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- period_max: int¶
- period_min: int¶
- total_sum: float¶
- warnings: list[WarningModel] | None¶
- weight_calc: int¶
cdek.apps.tariff.tariff module¶
- class cdek.apps.tariff.tariff.TariffApp(client: CdekClient)[исходный код]¶
Базовые классы:
AppКласс для работы с тарифами
- all() TariffAvailableResponse[исходный код]¶
Список доступных тарифов Метод позволяет получить список всех доступных и актуальных тарифов по договору
- Returns:
Список объектов TariffAvailableResponse с информацией о доступных тарифах
- calc(tariff: TariffCodeRequest) TariffResponse[исходный код]¶
Расчёт стоимости и сроков доставки по коду тарифа
- Args:
tariff: объект TariffCodeRequest с параметрами запроса (tariff_code, from_location, to_location, packages)
- Returns:
TariffResponse: объект с информацией о расчёте стоимости и сроков доставки
- Raises:
ValueError: если tariff не является объектом TariffCodeRequest
- calc_list(tariff: TariffListRequest) TariffListResponse[исходный код]¶
Расчёт стоимости и сроков доставки по всем доступным тарифам
- Args:
tariff: объект Tariff с параметрами запроса (type, from_location, to_location, packages)
- Returns:
Список объектов TariffListResponse с информацией о доступных тарифах
- Raises:
ValueError: если tariff не является объектом TariffListRequest