import { HttpStep, IHttpStep } from '../../HttpStep.js'

export const AsNumberStepKind = 'HttpAction#AsNumber'

/**
 * Reads the input and returns is as a number.
 */
export interface IAsNumberStep extends IHttpStep {
  kind: typeof AsNumberStepKind
}

/**
 * Reads the input and returns is as a number.
 */
export class AsNumberStep extends HttpStep {
  override kind = AsNumberStepKind

  constructor(init?: IAsNumberStep) {
    super()
    if (typeof init === 'object') {
      this.new(init)
    }
  }

  override new(init: IAsNumberStep): void {
    super.new(init)
    this.kind = AsNumberStepKind
  }

  checkValidity(): boolean {
    return true
  }

  override toJSON(): IAsNumberStep {
    const result: IAsNumberStep = {
      ...super.toJSON(),
      kind: AsNumberStepKind,
    }
    return result
  }
}
