import { SearchBaseClass } from "../../helpers/search"; export interface UnsplashResult { id: string; alt_description: string; description: string; // color: string; urls: { regular: string; thumb: string; }; user: { name: string; profile_image: { small: string; }; }; } export default class Unsplash extends SearchBaseClass { constructor(apiKey: string) { super({ apiKey, name: "unsplash", icon: ``, color: "#333", poweredByUrl: "https://unsplash.com", popularEndpoint: (apiKey: string) => `https://api.unsplash.com/photos?client_id=${apiKey}`, searchEndpoint: (apiKey: string, query: string) => `https://api.unsplash.com/search/photos?client_id=${ this.apiKey }&page=1&query=${encodeURIComponent(query)}`, getButton: (image: UnsplashResult) => `
${image.user.name}
`, getSearchResults: (response: { results: UnsplashResult[] }) => response.results, getPopularResults: (response: UnsplashResult[]) => response, }); } }