Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from typing import List, Dict, Any
- class RedisApi:
- def __init__(self, api_token: str) -> None:
- """
- Initialize RedisApi with the base URL for the landings service and an API token.
- Parameters:
- api_token (str): The API token used for authorization.
- """
- self.hostname: str = "develop.k8s.tetrika-school.ru"
- self.url: str = f"https://{self.hostname}/landings_service/api/v1/landings/"
- self.api_token: str = api_token
- def get_landings(self) -> List[Dict[str, Any]]:
- """
- Fetches landing page data from the API using the stored API token.
- Returns:
- List[Dict[str, Any]]: A list of dictionaries containing the response JSON from the API,
- where each dictionary represents a landing.
- """
- headers = {"Authorization": f"Bearer {self.api_token}"}
- response = requests.get(url=self.url, headers=headers)
- response_data = response.json()
- return response_data
Advertisement
Add Comment
Please, Sign In to add comment