Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import Any, Dict, List, Optional, Union
- class PexelsType:
- """Base class for all pexels objects"""
- def __str__(self) -> str:
- return f'<{self.__class__.__name__}: {self.__dict__}'
- def __repr__(self) -> str:
- return self.__str__()
- class Src(PexelsType):
- original: str
- "The image without any size changes. It will be the same as the width and height attributes."
- large: str
- "The image resized to W 940px X H 650px DPR 1."
- large2x: str
- "The image resized W 940px X H 650px DPR 2."
- medium: str
- "The image resized W 940px X H 650px DPR 2."
- small: str
- "The image scaled proportionally so that it's new height is 130px."
- portrait: str
- "The image cropped to W 800px X H 1200px."
- landscape: str
- "The image cropped to W 1200px X H 627px."
- tiny: str
- "The image cropped to W 280px X H 200px."
- def __init__(
- self,
- original: str,
- large: str,
- large2x: str,
- medium: str,
- small: str,
- portrait: str,
- landscape: str,
- tiny: str,
- **kwargs
- ) -> None:
- self.original = original
- self.large = large
- self.large2x = large2x
- self.medium = medium
- self.small = small
- self.portrait = portrait
- self.landscape = landscape
- self.tiny = tiny
- class Photo(PexelsType):
- id: int
- "The id of the photo."
- width: int
- "The real width of the photo in pixels."
- height: int
- "The real height of the photo in pixels."
- url: str
- "The Pexels URL where the photo is located."
- photographer: str
- "The name of the photographer who took the photo."
- photographer_url: str
- "The URL of the photographer's Pexels profile."
- photographer_id: str
- "The id of the photographer."
- avg_color: str
- "The average color of the photo. Useful for a placeholder while the image loads"
- src: Src
- "An assortment of different image sizes that can be used to display this Photo."
- alt: str
- "Text description of the photo for use in the alt attribute."
- def __init__(
- self,
- id: int,
- width: int,
- height: int,
- url: str,
- photographer: str,
- photographer_url: str,
- photographer_id: int,
- avg_color: str,
- src: Any,
- alt: str,
- **kwargs
- ) -> None:
- self.id = id
- self.width = width
- self.height = height
- self.url = url
- self.photographer = photographer
- self.photographer_url = photographer_url
- self.photographer_id = photographer_id
- self.avg_color = avg_color
- self.src = Src(**src)
- self.alt = alt
- class SearchResponse(PexelsType):
- photos = List[Photo]
- "A list of `Photo` object"
- page = int
- "The current page number"
- per_page = int
- "The number of results returned with each page"
- total_results = int
- "The total number of results for the request"
- prev_page = str
- "URL for the previous page of results, if applicable"
- next_page = str
- "URL for the next page of results, if applicable"
- def __init__(
- self,
- photos: List[Photo],
- page: int,
- per_page: int,
- total_results: int,
- prev_page: str = "",
- next_page: str = "",
- **kwargs
- ):
- self.photos = photos
- self.page = page
- self.per_page = per_page
- self.total_results = total_results
- self.prev_page = prev_page
- self.next_page = next_page
Advertisement
Add Comment
Please, Sign In to add comment