Source: job-result-dto.js

import JobRecordDTO from './job-record-dto.js'
import JobRunDTO from './job-run-dto.js'

/**
 *
 */
class JobResultDTO {
  /**
   *
   * @param {any} json
   */
  constructor (json) {
    this.json = json
  }

  /**
   * @type {string}
   */
  get annotation () {
    return this.json.annotation
  }

  /**
   * @type {string}
   */
  get id () {
    return this.json.id
  }

  /**
   * @type {JobRecordDTO}
   */
  get record () {
    return new JobRecordDTO(this.json.record)
  }

  /**
   * @type {any[]}
   */
  get responses () {
    return this.json.responses
  }

  /**
   * @type {any}
   */
  get run () {
    return new JobRunDTO(this.json.run)
  }

  /**
   * @type {string}
   */
  get status () {
    if (this.annotation === 'OVERRIDE') {
      return this.json.status === 'FAIL' ? 'PASS' : 'FAIL'
    }
    return this.json.status
  }

  /**
   * @type {string}
   */
  get timestamp () {
    return this.json.timestamp
  }

  /**
   * @type {Object<string, any>}
   */
  get values () {
    return this.json.values
  }

  /**
   * @param {string} name
   * @returns {any}
   */
  value (name) {
    console.info(`loooking for value: ${name} in values: ${JSON.stringify(this.values, null, 2)}`)
    return this.values[name]
  }

  /**
   * @param {string} name
   * @returns {string}
   */
  valueAsString (name) {
    return this.values[name]
  }
}

export default JobResultDTO