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

export const AsLowerCaseStepKind = 'HttpAction#AsLowerCase'

/**
 * Reads the input and returns a lower case value of it.
 */
export interface IAsLowerCaseStep extends IHttpStep {
  kind: typeof AsLowerCaseStepKind
}

/**
 * Reads the input and returns a lower case value of it.
 */
export class AsLowerCaseStep extends HttpStep {
  override kind = AsLowerCaseStepKind

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

  override new(init: IAsLowerCaseStep): void {
    super.new(init)
    this.kind = AsLowerCaseStepKind
  }

  checkValidity(): boolean {
    return true
  }

  override toJSON(): IAsLowerCaseStep {
    const result: IAsLowerCaseStep = {
      ...super.toJSON(),
      kind: AsLowerCaseStepKind,
    }
    return result
  }
}
