@goteborgco/open-api-js-client
Version:
Official JavaScript client for the Göteborg & Co GraphQL API
74 lines (73 loc) • 1.72 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Media = void 0;
const MediaSizes_1 = require("./MediaSizes");
class Media {
constructor(data) {
this.id = data.id;
this.credit = data.credit;
this.caption = data.caption;
this.alt_text = data.alt_text;
this.media_type = data.media_type;
this.mime_type = data.mime_type;
this.sizes = new MediaSizes_1.MediaSizes(data.sizes || {});
}
/**
* Get the ID of the media
* @returns The media ID
*/
getId() {
return this.id;
}
/**
* Get the credit information
* @returns The credit text or undefined
*/
getCredit() {
return this.credit;
}
/**
* Get the caption text
* @returns The caption text or undefined
*/
getCaption() {
return this.caption;
}
/**
* Get the alternative text
* @returns The alt text or undefined
*/
getAltText() {
return this.alt_text;
}
/**
* Get the media type
* @returns The media type or undefined
*/
getMediaType() {
return this.media_type;
}
/**
* Get the MIME type
* @returns The MIME type or undefined
*/
getMimeType() {
return this.mime_type;
}
/**
* Get the sizes of the media
* @returns The media sizes object
*/
getSizes() {
return this.sizes;
}
/**
* Get the URL for a specific size
* @param size The desired size
* @returns The URL for the requested size or undefined
*/
getUrl(size = 'full') {
return this.sizes[size]?.source_url;
}
}
exports.Media = Media;