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

export const AsUpperCaseStepKind = 'HttpAction#AsUpperCase'

/**
 * Reads the input and returns an upper case value of it.
 */
export interface IAsUpperCaseStep extends IHttpStep {
  kind: typeof AsUpperCaseStepKind
}

/**
 * Reads the input and returns an upper case value of it.
 */
export class AsUpperCaseStep extends HttpStep {
  override kind = AsUpperCaseStepKind

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

  override new(init: IAsUpperCaseStep): void {
    super.new(init)
    this.kind = AsUpperCaseStepKind
  }

  checkValidity(): boolean {
    return true
  }

  override toJSON(): IAsUpperCaseStep {
    const result: IAsUpperCaseStep = {
      ...super.toJSON(),
      kind: AsUpperCaseStepKind,
    }
    return result
  }
}
