def __init__(self, image): if image: self.height: int = object_handler(image, "height") self.url: str = object_handler(image, "url") self.width: int = object_handler(image, "width")
def __init__(self, artist): self.href: str = object_handler(artist, "href") self.id: str = object_handler(artist, "id") self.name: str = object_handler(artist, "name") self.type: str = object_handler(artist, "type") self.uri: str = object_handler(artist, "uri")
def __init__(self, context: dict): if context: self.href: str = object_handler(context, "href") if context: self.type: str = object_handler(context, "type") if context: self.uri: str = object_handler(context, "uri") if context: self.external_urls: str = object_handler(context, "external_urls")
def __init__(self, device: dict): self.id: str = object_handler(device, "id") # self.id.accepted_values = \ # [None, 'Computer', 'Speaker', 'Smartphone'] self.is_active: bool = object_handler(device, "is_active") self.is_private_session: bool = object_handler(device, "is_private_session") self.is_restricted: bool = object_handler(device, "is_restricted") self.name: str = object_handler(device, "name") self.type: str = object_handler(device, "type") self.volume_percent: int = object_handler(device, "volume_percent")
def __init__(self, show): if show: self.available_markets: str = object_handler( show, "available_markets") self.copyrights: str = object_handler(show, "copyrights") self.description: str = object_handler(show, "description") self.explicit: str = object_handler(show, "explicit") self.external_urls: ExternalUrl = ExternalUrl( object_handler(show, "external_urls")) self.href: str = object_handler(show, "href") self.id: str = object_handler(show, "id") self.images: list = [ Image(image) for image in show.get("images", [None]) ] self.is_externally_hosted: str = object_handler( show, "is_externally_hosted") self.languages: str = object_handler(show, "languages") self.media_type: str = object_handler(show, "media_type") self.name: str = object_handler(show, "name") self.publisher: str = object_handler(show, "publisher") self.type: str = object_handler(show, "type") self.uri: str = object_handler(show, "uri")
def __init__(self, episode): self.audio_preview_url: str = object_handler(episode, "audio_preview_url") self.description: str = object_handler(episode, "description") self.duration: Time.Timestamp = Time.Timestamp( episode.get("duration_ms"), base="milliseconds") self.explicit: bool = object_handler(episode, "explicit") self.external_urls: ExternalUrl = ExternalUrl( object_handler(episode, "external_urls")) self.href: str = object_handler(episode, "href") self.id: str = object_handler(episode, "id") self.images: list = object_handler(episode, "images") self.is_externally_hosted: bool = object_handler( episode, "is_externally_hosted") self.is_playable: bool = object_handler(episode, "is_playable") self.language: str = object_handler(episode, "language") self.languages: list = object_handler(episode, "languages") self.name: str = object_handler(episode, "name") self.release_date: str = object_handler(episode, "release_date") self.release_date_precision: str = object_handler( episode, "release_date_precision") self.show: Show = Show(episode.get("show")) self.type: str = object_handler(episode, "type") self.uri: str = object_handler(episode, "uri")
def __init__(self, album): self.album_type: str = object_handler(album, "album_type") self.artists: list = [ Artist(artist) for artist in object_handler(album, "artists") ] self.available_markets: list = object_handler(album, "available_markets") self.external_urls: ExternalUrl = ExternalUrl( object_handler(album, "external_urls") ) self.href: str = object_handler(album, "href") self.id: str = object_handler(album, "id") self.images: list = [Image(image) for image in object_handler(album, "images")] self.name: str = object_handler(album, "name") self.release_date: str = object_handler(album, "release_date") self.release_date_precision: str = object_handler( album, "release_date_precision" ) self.restrictions: dict = object_handler(album, "restrictions") self.type: str = object_handler(album, "type") self.uri: str = object_handler(album, "uri")
def __init__(self, track: dict): self.album: Album = Album(object_handler(track, "album")) self.artists: list = [ Artist(artist) for artist in object_handler(track, "artists") ] self.available_markets: list = object_handler(track, "available_markets") self.disc_number: int = object_handler(track, "disc_number") self.duration: Time.Timestamp = Time.Timestamp( track.get("duration_ms"), base="milliseconds" ) self.explicit: bool = object_handler(track, "explicit") self.external_ids: ExternalId = ExternalId( object_handler(track, "external_ids") ) self.external_urls: ExternalUrl = ExternalUrl( object_handler(track, "external_urls") ) self.href: str = object_handler(track, "href") self.id: str = object_handler(track, "id") self.is_local: bool = object_handler(track, "is_local") self.name: str = object_handler(track, "name") self.popularity: int = object_handler(track, "popularity") self.preview_url: str = object_handler(track, "preview_url") self.track_number: int = object_handler(track, "track_number") self.type: str = object_handler(track, "type") self.uri: str = object_handler(track, "uri")
def __init__(self, external_id: dict): self.typ: str = list(external_id.keys())[0] self.id: str = object_handler(external_id, self.typ)
def __init__(self, url): self.typ: str = object_handler(url, "typ") self.url: str = object_handler(url, "url")
def test_object_handler(setup): obj, key, outcome = setup assert object_handler(obj, key) == outcome