platypush/common/spotify/__init__.py
def spotify_api_call(self, url: str, method='get', scopes: Optional[Iterable[str]] = None, **kwargs) -> dict:
        """
        Send an API request to a Spotify endpoint.

        :param url: URL to be requested.
        :param method: HTTP method (default: ``get``).
        :param scopes: List of scopes required by the call.
        :param kwargs: Extra keyword arguments to be passed to the request.
        :return: The response payload.
        """
        if scopes:
            self.spotify_user_authenticate(scopes=scopes)
        else:
            self.spotify_api_authenticate()

        method = getattr(requests, method.lower())
        rs = method(
            f'https://api.spotify.com{url}',
            headers={
                'Authorization': f'Bearer {self._spotify_user_token or self._spotify_api_token}',
                'Content-Type': 'application/json',
                'Accept': 'application/json',
            },
            **kwargs
        )

        rs.raise_for_status()
        if rs.status_code != 204 and rs.text:
            return rs.json()

        Send an API request to a Spotify endpoint.

        :param url: URL to be requested.
        :param method: HTTP method (default: ``get``).
        :param scopes: List of scopes required by the call.
        :param kwargs: Extra keyword arguments to be passed to the request.
        :return: The response payload.
        
Send an API request to a Spotify endpoint.
Send an API request to a Spotify endpoint .
def spotify_api_call(self, url: str, method='get', scopes: Optional[Iterable[str]] = None, **kwargs) -> dict:
        if scopes:
            self.spotify_user_authenticate(scopes=scopes)
        else:
            self.spotify_api_authenticate()
        method = getattr(requests, method.lower())
        rs = method(
            f'https://api.spotify.com{url}',
            headers={
                'Authorization': f'Bearer {self._spotify_user_token or self._spotify_api_token}',
                'Content-Type': 'application/json',
                'Accept': 'application/json',
            },
            **kwargs
        )
        rs.raise_for_status()
        if rs.status_code != 204 and rs.text:
            return rs.json()
def spotify_api_call ( self , url : str , method = 'get' , scopes : Optional [ Iterable [ str ] ] = None , ** kwargs ) -> dict : if scopes : self . spotify_user_authenticate ( scopes = scopes ) else : self . spotify_api_authenticate ( ) method = getattr ( requests , method . lower ( ) ) rs = method ( f'https://api.spotify.com{url}' , headers = { 'Authorization' : f'Bearer {self._spotify_user_token or self._spotify_api_token}' , 'Content-Type' : 'application/json' , 'Accept' : 'application/json' , } , ** kwargs ) rs . raise_for_status ( ) if rs . status_code != 204 and rs . text : return rs . json ( )
Send an API request to a Spotify endpoint.
Send an API request to a Spotify endpoint .
"""
        Send an API request to a Spotify endpoint.

        :param url: URL to be requested.
        :param method: HTTP method (default: ``get``).
        :param scopes: List of scopes required by the call.
        :param kwargs: Extra keyword arguments to be passed to the request.
        :return: The response payload.
        """
The response payload.
The response payload .
self
url
str
URL to be requested.
URL to be requested .
method
HTTP method (default: ``get``).
HTTP method ( default : ` ` get ` ` ) .
scopes
Optional[Iterable[str]]
List of scopes required by the call.
List of scopes required by the call .
kwargs
Extra keyword arguments to be passed to the request.
Extra keyword arguments to be passed to the request .