import { Categories , IStickerConfig , IStickerOptions } from '../../Types' ; import Utils from '../../Utils' ; export default class StickerMetadata implements IStickerOptions { public crop = false ; public full = false ; constructor ( public pack = '' , public author = '' , public categories = [ ] , public id = Utils . generateStickerID ( ) ) { } static from = ( object ) : StickerMetadata => { return new StickerMetadata ( object . pack , object . author , object . categories , object . id ) ; } ; public setPack = ( title ) : this => { this . pack = title ; return this ; } ; public setAuthor = ( author ) : this => { this . author = author ; return this ; } ; public setId = ( id ) : this => { this . id = id ; return this ; } ; public setCrop = ( value ) : this => { this . crop = value ; this . full = ! value ; return this ; } ; public setFull = ( value ) : this => { this . crop = ! value ; this . full = value ; return this ; } ; public setCategories = ( categories ) : this => { this . categories = ( typeof categories === 'string' ? categories . split ( ',' ) . map ( ( emoji ) => emoji . trim ( ) ) : categories ) as Categories [ ] ; return this ; } ; public toJSON = ( ) : IStickerConfig => { const obj = { } ; Object . keys ( this ) . filter ( ( key ) => typeof this [ key as keyof this ] !== 'function' ) . forEach ( ( key ) => ( obj [ key ] = this [ key as keyof IStickerConfig ] as IStickerConfig [ keyof IStickerConfig ] ) ) ; return obj as IStickerConfig ; } ; }