"""Common API models.""" import abc from enum import Enum from typing import Dict import requests from pydantic import BaseModel class Store(Enum): """Store name type.""" APPLE_MUSIC = 'APPLE_MUSIC' SPOTIFY = 'SPOTIFY' class RequestType(Enum): """Store API Request type.""" get_album_artist_by_id = 'GET_ALBUM_ARTIST_BY_ID' search_track_by_isrc = 'SEARCH_TRACK_BY_ISRC' search_album_by_upc = 'SEARCH_ALBUM_BY_UPC' get_audio_features = 'GET_AUDIO_FEATURES' class ApiRequestType(BaseModel): """Store API request model.""" store: Store type: RequestType class BaseStoreAPI(abc.ABC): """Store API interface.""" @abc.abstractmethod def call(self, endpoint: str, params: Dict) -> requests.Response: """Call Store API with a GET method. Args: endpoint: Store API endpoint. params: API request params according to the endpoint. returns: HTTP response from the API. """ ... class BaseAPIRequest(abc.ABC): """Request for Store API.""" @property @abc.abstractmethod def endpoint(self) -> str: """Store API endpoint.""" ... @property @abc.abstractmethod def endpoint_params(self) -> Dict: """Get API endpoint parameters.""" ...