You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
1.0 KiB

import "reflect-metadata"
import { Expose, Type } from 'class-transformer'
export class ExampleItem {
id: number;
text: string;
meta: object;
@Expose({ name: 'annotation_approver' })
annotationApprover: boolean | null;
@Expose({ name: 'comment_count' })
commentCount: number;
@Expose({ name: 'filename' })
fileUrl: string;
@Expose({ name: 'is_confirmed' })
isConfirmed: boolean;
get url() {
const l = this.fileUrl.indexOf('media/')
const r = this.fileUrl.indexOf('media/', l + 1)
return this.fileUrl.slice(0, l) + this.fileUrl.slice(r)
}
get filename() {
const items = this.fileUrl.split('/')
return items[items.length - 1]
}
toObject(): Object {
return {
id: this.id,
text: this.text,
meta: this.meta,
annotation_approver: this.annotationApprover,
comment_count: this.commentCount
}
}
}
export class ExampleItemList {
count: number;
next: string | null;
prev: string | null;
@Type(() => ExampleItem)
@Expose({ name: 'results' })
items: ExampleItem[];
}