UNPKG

@goteborgco/open-api-js-client

Version:

Official JavaScript client for the Göteborg & Co GraphQL API

47 lines (46 loc) 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MediaSizes = void 0; const Image_1 = require("./Image"); /** * Represents different sizes of a media item */ class MediaSizes { constructor(data) { this.medium = data.medium ? new Image_1.Image(data.medium) : undefined; this.thumbnail = data.thumbnail ? new Image_1.Image(data.thumbnail) : undefined; this.large = data.large ? new Image_1.Image(data.large) : undefined; this.full = data.full ? new Image_1.Image(data.full) : undefined; } /** * Get a specific size * @param size The size to get * @returns The image data for the requested size or undefined */ getSize(size) { return this[size]; } /** * Get the URL for a specific size * @param size The size to get the URL for * @returns The URL for the requested size or undefined */ getUrl(size) { return this[size]?.source_url; } /** * Get the dimensions for a specific size * @param size The size to get dimensions for * @returns The dimensions for the requested size or undefined */ getDimensions(size) { const image = this[size]; if (!image) return undefined; return { width: image.width, height: image.height }; } } exports.MediaSizes = MediaSizes;