All files / src/model PhotoDetails.ts

90% Statements 9/10
100% Branches 0/0
66.67% Functions 2/3
90% Lines 9/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 505x               5x   11x   11x 11x 11x   3x   11x                                                 11x            
import { Util } from '../internal/Util';
 
import { Moment } from 'moment';
 
/**
 * Represents a photo.
 * @module PhotoDetails
 */
export class PhotoDetails {
  public static fromRest(data: any) {
    Util.assertHasProperties(data, 'id');
 
    const ret = new PhotoDetails();
    Util.setProperties(ret, data, 'id', 'animated', 'store_filename', 'md5_hash', 'original_filename', 'uploader');
    Util.setDateProperties(ret, data, 'uploader_time');
    if (data.sizes) {
      Object.assign(ret.sizes, data.sizes);
    }
    return ret;
  }
 
  /** The photo's ID. */
  public id: string;
 
  /** Whether the photo is animated. */
  public animated: boolean;
 
  /** The filename stored on the server. */
  public store_filename: string;
 
  /** The photo's MD5 hash. */
  public md5_hash: string;
 
  /** The original filename. */
  public original_filename: string;
 
  /** The user that uploaded the photo. */
  public uploader: string;
 
  /** When the photo was uploaded. */
  public upload_time: Moment;
 
  /** The sizes available. */
  public sizes: { [key: string]: string } = {};
 
  public toJSON() {
    return this;
  }
}