Добавлены тайп-хинты для следующих классов: 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
|
|
|
|
|
|
Добавлены тайп-хинты для следующих классов: 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
|
|
|
|
|
|
|
|
|
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`): Длительность испытательного срока.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
price (:obj:`yandex_music.Price`): Объект класса :class:`yandex_music.Price` представляющий цену.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
feature (:obj:`str`): Предоставляемая возможность.
|
|
|
|
|
debug (:obj:`bool`): Отладочный продукт.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
features (:obj:`list` из :obj:`str`): Список предоставляемых возможностей.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
description (:obj:`str`): Описание.
|
|
|
|
|
available (:obj:`bool`): Доступна ли покупка.
|
2019-07-03 21:28:54 +09:00
|
|
|
|
trial_available (:obj:`bool`): Доступен ли испытательный срок.
|
|
|
|
|
vendor_trial_available (:obj:`bool`): Доступен испытательный срок продавца TODO.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
button_text (:obj:`str`): Текст кнопки.
|
|
|
|
|
button_additional_text (:obj:`str`): Дополнительный текст кнопки.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
payment_method_types (:obj:`list` из :obj:`str`): Способы оплаты.
|
|
|
|
|
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
|
2019-07-02 20:40:41 +09:00
|
|
|
|
Music.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
product_id (:obj:`str`): Уникальный идентификатор.
|
2019-12-27 04:51:29 +09:00
|
|
|
|
type_ (:obj:`str`): Тип продаваемого.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
common_period_duration (:obj:`str`): Длительность общего периода.
|
|
|
|
|
duration (:obj:`int`): Длительность.
|
|
|
|
|
trial_duration (:obj:`int`): Длительность испытательного срока.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
price (:obj:`yandex_music.Price`): Объект класса :class:`yandex_music.Price` представляющий цену.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
feature (:obj:`str`): Предоставляемая возможность.
|
|
|
|
|
debug (:obj:`bool`): Отладочный продукт.
|
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): Доступна ли покупка.
|
2019-07-03 21:28:54 +09:00
|
|
|
|
trial_available (:obj:`bool`, optional): Доступен ли испытательный срок.
|
|
|
|
|
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): Способы оплаты.
|
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Объект класса :class:`yandex_music.Client` представляющий клиент
|
2019-07-02 20:40:41 +09:00
|
|
|
|
Yandex Music.
|
|
|
|
|
**kwargs: Произвольные ключевые аргументы полученные от API.
|
|
|
|
|
"""
|
|
|
|
|
|
2019-05-10 00:28:46 +09:00
|
|
|
|
def __init__(self,
|
Добавлены тайп-хинты для следующих классов: VideoSupplement, Supplement, Lyrics, Subscription, Status, Product, Plus, Price, Permissions, PassportPhone, AutoRenewable, Account.
2019-12-27 17:42:24 +09:00
|
|
|
|
product_id: str,
|
|
|
|
|
type_: str,
|
|
|
|
|
common_period_duration: str,
|
|
|
|
|
duration: int,
|
|
|
|
|
trial_duration: int,
|
|
|
|
|
price: Optional['Price'],
|
|
|
|
|
feature: str,
|
|
|
|
|
debug: bool,
|
2019-12-27 21:32:50 +09:00
|
|
|
|
features: List[str] = None,
|
Добавлены тайп-хинты для следующих классов: VideoSupplement, Supplement, Lyrics, Subscription, Status, Product, Plus, Price, Permissions, PassportPhone, AutoRenewable, Account.
2019-12-27 17:42:24 +09:00
|
|
|
|
description: Optional[str] = None,
|
|
|
|
|
available: Optional[bool] = None,
|
|
|
|
|
trial_available: Optional[bool] = None,
|
|
|
|
|
vendor_trial_available: Optional[bool] = None,
|
|
|
|
|
button_text: Optional[str] = None,
|
|
|
|
|
button_additional_text: Optional[str] = None,
|
2019-12-27 21:32:50 +09:00
|
|
|
|
payment_method_types: List[str] = None,
|
Добавлены тайп-хинты для следующих классов: VideoSupplement, Supplement, Lyrics, Subscription, Status, Product, Plus, Price, Permissions, PassportPhone, AutoRenewable, Account.
2019-12-27 17:42:24 +09:00
|
|
|
|
client: Optional['Client'] = None,
|
|
|
|
|
**kwargs) -> None:
|
2019-05-10 00:28:46 +09:00
|
|
|
|
self.product_id = product_id
|
2019-12-27 04:51:29 +09:00
|
|
|
|
self.type = type_
|
2019-05-10 00:28:46 +09:00
|
|
|
|
self.common_period_duration = common_period_duration
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
self.duration = duration
|
|
|
|
|
self.trial_duration = trial_duration
|
2019-05-10 00:28:46 +09:00
|
|
|
|
self.price = price
|
|
|
|
|
self.feature = feature
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
self.debug = debug
|
2019-05-10 00:28:46 +09:00
|
|
|
|
|
2019-05-11 05:01:32 +09:00
|
|
|
|
self.features = features
|
|
|
|
|
self.description = description
|
|
|
|
|
self.available = available
|
|
|
|
|
self.trial_available = trial_available
|
|
|
|
|
self.vendor_trial_available = vendor_trial_available
|
|
|
|
|
self.button_text = button_text
|
|
|
|
|
self.button_additional_text = button_additional_text
|
|
|
|
|
self.payment_method_types = payment_method_types
|
|
|
|
|
|
2019-05-10 00:28:46 +09:00
|
|
|
|
self.client = client
|
2019-11-10 03:11:43 +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`): Поля и значения десериализуемого объекта.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
|
2019-07-02 20:40:41 +09:00
|
|
|
|
Music.
|
|
|
|
|
|
|
|
|
|
Returns:
|
2019-07-05 02:21:54 +09:00
|
|
|
|
:obj:`yandex_music.Product`: Объект класса :class:`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)
|
2020-01-26 02:13:20 +09:00
|
|
|
|
from yandex_music import Price
|
2019-05-11 05:01:32 +09:00
|
|
|
|
data['price'] = Price.de_json(data.get('price'), 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`): Список словарей с полями и значениями десериализуемого объекта.
|
2019-07-05 02:21:54 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex
|
2019-07-02 20:40:41 +09:00
|
|
|
|
Music.
|
|
|
|
|
|
|
|
|
|
Returns:
|
2019-07-05 02:21:54 +09:00
|
|
|
|
:obj:`list` из :obj:`yandex_music.Product`: Список объектов класса :class:`yandex_music.Product`.
|
2019-07-02 20:40:41 +09:00
|
|
|
|
"""
|
2019-05-11 05:01:32 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
products = list()
|
|
|
|
|
for product in data:
|
|
|
|
|
products.append(cls.de_json(product, client))
|
|
|
|
|
|
|
|
|
|
return products
|