All files JenkinsHealthReport.ts

100% Statements 15/15
100% Branches 10/10
100% Functions 3/3
100% Lines 15/15
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    2x     12x 12x 12x     23x 23x 13x   23x 13x   23x 13x   23x 13x   23x 13x                                              
 
import { IJenkinsHealthReport } from './jenkins-api-ts-typings';
 
export class JenkinsHealthReport implements IJenkinsHealthReport {
    jsonData:           JSON;
    
    _class:             string;
    description:        string;
    iconClassName:      string;
    iconUrl:            string;
    score:              number;
    
    getJsonData(): string {
        return JSON.stringify(this.jsonData);
    }
    
    public fromJsonString(json: string): void {
        let data:JSON = JSON.parse(json);
        this.jsonData = data;
        
        this.fromJson(data);
    }
    
    public fromJson(data: JSON): void {
        this.jsonData = data;
        
        if(data.hasOwnProperty("_class")) {
            this._class = (data as any)["_class"];
        }
        
        if(data.hasOwnProperty("description")) {
            this.description = (data as any)["description"];
        }
        
        if(data.hasOwnProperty("iconClassName")) {
            this.iconClassName = (data as any)["iconClassName"];
        }
        
        if(data.hasOwnProperty("iconUrl")) {
            this.iconUrl = (data as any)["iconUrl"];
        }
        
        if(data.hasOwnProperty("score")) {
            this.score = (data as any)["score"];
        }
    }
    
}