Добавлены тайп-хинты для следующих классов: VideoSupplement, Supplement, Lyrics, Subscription, Status, Product, Plus, Price, Permissions, PassportPhone, AutoRenewable, Account.
2019-12-27 17:42:24 +09:00
|
|
|
|
from typing import TYPE_CHECKING, Optional, List
|
|
|
|
|
|
2020-01-26 21:19:22 +09:00
|
|
|
|
from yandex_music import YandexMusicObject
|
2021-09-19 22:47:19 +09:00
|
|
|
|
from yandex_music.utils import model
|
2020-01-26 21:19:22 +09:00
|
|
|
|
|
Добавлены тайп-хинты для следующих классов: VideoSupplement, Supplement, Lyrics, Subscription, Status, Product, Plus, Price, Permissions, PassportPhone, AutoRenewable, Account.
2019-12-27 17:42:24 +09:00
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from yandex_music import Client, Price
|
|
|
|
|
|
2019-05-10 00:28:46 +09:00
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
@model
|
2019-05-10 00:28:46 +09:00
|
|
|
|
class Product(YandexMusicObject):
|
2020-01-26 03:09:03 +09:00
|
|
|
|
"""Класс, представляющий продаваемый продукт.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
|
|
|
|
|
Attributes:
|
|
|
|
|
product_id (:obj:`str`): Уникальный идентификатор.
|
|
|
|
|
type (:obj:`str`): Тип продаваемого.
|
|
|
|
|
common_period_duration (:obj:`str`): Длительность общего периода.
|
|
|
|
|
duration (:obj:`int`): Длительность.
|
|
|
|
|
trial_duration (:obj:`int`): Длительность испытательного срока.
|
Удаление избыточной информации (#247)
Классы: Account, AutoRenewable, PassportPhone, Permissions, Plus, Price,
Product, Status, Subscription, UserSettings, Album, Label,
TrackPosition, Playlist
У всех классов изменено описание атрибута client
2020-03-22 04:49:20 +09:00
|
|
|
|
price (:obj:`yandex_music.Price`): Цена.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
feature (:obj:`str`): Предоставляемая возможность.
|
|
|
|
|
debug (:obj:`bool`): Отладочный продукт.
|
2020-04-17 02:56:45 +09:00
|
|
|
|
plus (:obj:`bool`): Даёт ли подписку "Плюс".
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
cheapest (:obj:`bool`, optional): Самый дешёвый (лучшее предложение).
|
|
|
|
|
title (:obj:`str`, optional): Заголовок продукта.
|
|
|
|
|
family_sub (:obj:`bool`, optional): Семейная ли подписка.
|
|
|
|
|
fb_image (:obj:`str`, optional): Картинка для превью на facebook.
|
|
|
|
|
fb_name (:obj:`str`, optional): Заголовок превью на facebook.
|
|
|
|
|
family (:obj:`bool`, optional): Доступно ли для семьи.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
features (:obj:`list` из :obj:`str`, optional): Список предоставляемых возможностей.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
description (:obj:`str`, optional): Описание.
|
|
|
|
|
available (:obj:`bool`, optional): Доступна ли покупка.
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
trial_available (:obj:`bool`, optional): Доступен ли пробный период.
|
|
|
|
|
trial_period_duration (:obj:`str`, optional): Длительность пробного периода.
|
|
|
|
|
intro_period_duration (:obj:`str`, optional): Длительность вступительного периода TODO.
|
|
|
|
|
intro_price (:obj:`yandex_music.Price`, optional): Цена вступительного периода.
|
|
|
|
|
start_period_duration (:obj:`str`, optional): Длительность первого срока (за меньшую цену).
|
|
|
|
|
start_price (:obj:`yandex_music.Price`, optional): Цена за первый срок.
|
|
|
|
|
licence_text_parts (:obj:`list` из :obj:`yandex_music.LicenceTextPart`, optional):
|
|
|
|
|
Длительность пробного периода.
|
2019-07-03 21:28:54 +09:00
|
|
|
|
vendor_trial_available (:obj:`bool`, optional): Доступен испытательный срок продавца TODO.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
button_text (:obj:`str`, optional): Текст кнопки.
|
|
|
|
|
button_additional_text (:obj:`str`, optional): Дополнительный текст кнопки.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
payment_method_types (:obj:`list` из :obj:`str`, optional): Способы оплаты.
|
Удаление избыточной информации (#247)
Классы: Account, AutoRenewable, PassportPhone, Permissions, Plus, Price,
Product, Status, Subscription, UserSettings, Album, Label,
TrackPosition, Playlist
У всех классов изменено описание атрибута client
2020-03-22 04:49:20 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
"""
|
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
product_id: str
|
|
|
|
|
type: str
|
|
|
|
|
common_period_duration: str
|
|
|
|
|
duration: int
|
|
|
|
|
trial_duration: int
|
|
|
|
|
price: Optional['Price']
|
|
|
|
|
feature: str
|
|
|
|
|
debug: bool
|
|
|
|
|
plus: bool
|
|
|
|
|
cheapest: Optional[bool] = None
|
|
|
|
|
title: Optional[str] = None
|
|
|
|
|
family_sub: Optional[bool] = None
|
|
|
|
|
fb_image: Optional[str] = None
|
|
|
|
|
fb_name: Optional[str] = None
|
|
|
|
|
family: Optional[bool] = None
|
|
|
|
|
features: List[str] = None
|
|
|
|
|
description: Optional[str] = None
|
|
|
|
|
available: Optional[bool] = None
|
|
|
|
|
trial_available: Optional[bool] = None
|
|
|
|
|
trial_period_duration: Optional[str] = None
|
|
|
|
|
intro_period_duration: Optional[str] = None
|
|
|
|
|
intro_price: Optional['Price'] = None
|
|
|
|
|
start_period_duration: Optional[str] = None
|
|
|
|
|
start_price: Optional['Price'] = None
|
|
|
|
|
licence_text_parts: List['Price'] = None
|
|
|
|
|
vendor_trial_available: Optional[bool] = None
|
|
|
|
|
button_text: Optional[str] = None
|
|
|
|
|
button_additional_text: Optional[str] = None
|
|
|
|
|
payment_method_types: List[str] = None
|
|
|
|
|
client: Optional['Client'] = None
|
2019-05-11 05:01:32 +09:00
|
|
|
|
|
2021-09-19 22:47:19 +09:00
|
|
|
|
def __post_init__(self):
|
2021-02-03 21:28:10 +09:00
|
|
|
|
self._id_attrs = (
|
|
|
|
|
self.product_id,
|
|
|
|
|
self.type,
|
|
|
|
|
self.common_period_duration,
|
|
|
|
|
self.duration,
|
|
|
|
|
self.trial_duration,
|
|
|
|
|
self.product_id,
|
|
|
|
|
self.feature,
|
|
|
|
|
self.debug,
|
|
|
|
|
)
|
2019-05-10 00:28:46 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
Добавлены тайп-хинты для следующих классов: VideoSupplement, Supplement, Lyrics, Subscription, Status, Product, Plus, Price, Permissions, PassportPhone, AutoRenewable, Account.
2019-12-27 17:42:24 +09:00
|
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['Product']:
|
2019-07-02 20:40:41 +09:00
|
|
|
|
"""Десериализация объекта.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`dict`): Поля и значения десериализуемого объекта.
|
Удаление избыточной информации (#247)
Классы: Account, AutoRenewable, PassportPhone, Permissions, Plus, Price,
Product, Status, Subscription, UserSettings, Album, Label,
TrackPosition, Playlist
У всех классов изменено описание атрибута client
2020-03-22 04:49:20 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
|
|
|
|
|
Returns:
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
:obj:`yandex_music.Product`: Продаваемый продукт.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
"""
|
2019-05-10 00:28:46 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
data = super(Product, cls).de_json(data, client)
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
from yandex_music import Price, LicenceTextPart
|
2021-02-03 21:28:10 +09:00
|
|
|
|
|
2019-05-11 05:01:32 +09:00
|
|
|
|
data['price'] = Price.de_json(data.get('price'), client)
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
data['intro_price'] = Price.de_json(data.get('intro_price'), client)
|
|
|
|
|
data['start_price'] = Price.de_json(data.get('start_price'), client)
|
|
|
|
|
data['licence_text_parts'] = LicenceTextPart.de_list(data.get('licence_text_parts'), client)
|
2019-05-10 00:28:46 +09:00
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
2019-05-11 05:01:32 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
Добавлены тайп-хинты для следующих классов: VideoSupplement, Supplement, Lyrics, Subscription, Status, Product, Plus, Price, Permissions, PassportPhone, AutoRenewable, Account.
2019-12-27 17:42:24 +09:00
|
|
|
|
def de_list(cls, data: dict, client: 'Client') -> List['Product']:
|
2019-07-02 20:40:41 +09:00
|
|
|
|
"""Десериализация списка объектов.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
|
Удаление избыточной информации (#247)
Классы: Account, AutoRenewable, PassportPhone, Permissions, Plus, Price,
Product, Status, Subscription, UserSettings, Album, Label,
TrackPosition, Playlist
У всех классов изменено описание атрибута client
2020-03-22 04:49:20 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
|
|
|
|
|
Returns:
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
:obj:`list` из :obj:`yandex_music.Product`: Продаваемые продукты.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
"""
|
2019-05-11 05:01:32 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return []
|
|
|
|
|
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
return [cls.de_json(product, client) for product in data]
|