src/helpers/Image.js
import { stringToSnake } from '../utilities/FormatUtility';
import ImageModel from '../models/Image';
/**
* Helper class representing an image object.
*/
class Image extends ImageModel {
/**
* Default toJSON image format
* @return {Object} - returns json useable for updating images
*/
toJSON() {
const obj = {};
obj.url = this.url;
if (this) {
Object.keys(this).forEach((key) => {
if (['id', 'type', 'url'].indexOf(key) === -1 && key.charAt(0) !== '_') {
obj[stringToSnake(key)] = { url: this[key] };
}
});
}
return obj;
}
}
export default Image;