All files / node-sdk/models/bxml/verbs Gather.ts

100% Statements 11/11
50% Branches 1/2
100% Functions 4/4
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 49 50 51 52 53 54 55 56 57 58 59 6010x     10x                                                       10x                 3x             10x 5x             10x 3x   10x  
import { NestableVerb } from '../NestableVerb';
import { PlayAudio } from './PlayAudio';
import { SpeakSentence } from './SpeakSentence';
import { SSML_REGEX } from '../Root';
import { XMLWriterOptions } from 'xmlbuilder2/lib/interfaces';
 
type AudioVerbs = Array<PlayAudio | SpeakSentence>;
 
export interface GatherAttributes {
    gatherUrl?: string;
    gatherMethod?: string;
    gatherFallbackUrl?: string;
    gatherFallbackMethod?: string;
    username?: string;
    password?: string;
    fallbackUsername?: string;
    fallbackPassword?: string;
    tag?: string;
    terminatingDigits?: string;
    maxDigits?: number;
    interDigitTimeout?: number;
    firstDigitTimeout?: number;
    repeatCount?: number;
}
 
/**
 * @export
 * @class Gather
 * @extends {NestableVerbVerb}
 * Represents a Gather verb
 */
export class Gather extends NestableVerb {
    attributes: GatherAttributes;
 
    /**
     * Creates an instance of Gather
     * @param {GatherAttributes} attributes The attributes to add to the element
     * @param {PlayAudio | SpeakSentence | AudioVerbs} audioVerbs The audio verbs to be played
     */
    constructor(attributes?: GatherAttributes, audioVerbs?: PlayAudio | SpeakSentence | AudioVerbs) {
        super('Gather', undefined, attributes, audioVerbs);
    }
 
    /**
     * Return BXML representation of this element
     * @param options XML Serialization options
     */
    toBxml(options?: XMLWriterOptions): string {
        return this.generateXml().toString(options).replace(SSML_REGEX, '<$1>');
    }
 
    /**
     * Add an audio verb or verbs to the gather
     * @param {PlayAudio | SpeakSentence | AudioVerbs} audioVerbs The audio verb or verbs to add
     */
    addAudioVerbs(audioVerbs: PlayAudio | SpeakSentence | AudioVerbs): void {
        this.nestedVerbs = this.nestedVerbs.concat(audioVerbs);
    }
}