How to use the google-libphonenumber.PhoneNumber function in google-libphonenumber

To help you get started, we’ve selected a few google-libphonenumber examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jovotech / jovo-framework / examples / typescript / components / src / components / GetPhoneNumber / src / handler.ts View on Github external
if (phoneNumberSequenceCount === 1) {
                    this.$speech.t('component-GetPhoneNumber.sequence-question');
                    this.$reprompt.t('component-GetPhoneNumber.sequence-reprompt');
    
                    return this.ask(this.$speech, this.$reprompt);
                }
                else if (phoneNumberSequenceCount === 2) {
                    this.$speech.t('component-GetPhoneNumber.sequence-last-digits-question');
                    this.$reprompt.t('component-GetPhoneNumber.sequence-last-digits-reprompt');
    
                    return this.ask(this.$speech, this.$reprompt);
                }
                else {
                    // validate phone number
                    const region = this.$request!.getLocale().split('-')[1]; // e.g. "en-US" -> "US"
                    let phoneNumber: PhoneNumber = new PhoneNumber();
                    try {
                        phoneNumber = phoneNumberUtilInstance.parse(this.$session.$data.COMPONENT_GetPhoneNumber.phoneNumberRaw, region);
                    } catch (error) {
                        return invalidNumber(this);
                    }
                
                    if (!phoneNumberUtilInstance.isValidNumber(phoneNumber)) {
                        return invalidNumber(this);
                    }
    
                    const formattedPhoneNumber = formatPhoneNumber(phoneNumber);
    
                    this.$components.GetPhoneNumber.data.phoneNumber = formattedPhoneNumber;
            
                    return sendComponentResponse(this, 'SUCCESSFUL');
                }
github jovotech / jovo-framework / examples / javascript / components / src / components / jovo-component-get-phone-number / src / handler.js View on Github external
sequence = sequence.toString();
                }
                this.$session.$data.COMPONENT_GetPhoneNumber.phoneNumberRaw += sequence;
                if (phoneNumberSequenceCount === 1) {
                    this.$speech.t('component-GetPhoneNumber.sequence-question');
                    this.$reprompt.t('component-GetPhoneNumber.sequence-reprompt');
                    return this.ask(this.$speech, this.$reprompt);
                }
                else if (phoneNumberSequenceCount === 2) {
                    this.$speech.t('component-GetPhoneNumber.sequence-last-digits-question');
                    this.$reprompt.t('component-GetPhoneNumber.sequence-last-digits-reprompt');
                    return this.ask(this.$speech, this.$reprompt);
                }
                else {
                    const region = this.$request.getLocale().split('-')[1];
                    let phoneNumber = new PhoneNumber();
                    try {
                        phoneNumber = phoneNumberUtilInstance.parse(this.$session.$data.COMPONENT_GetPhoneNumber.phoneNumberRaw, region);
                    }
                    catch (error) {
                        return invalidNumber(this);
                    }
                    if (!phoneNumberUtilInstance.isValidNumber(phoneNumber)) {
                        return invalidNumber(this);
                    }
                    const formattedPhoneNumber = formatPhoneNumber(phoneNumber);
                    this.$components.GetPhoneNumber.data.phoneNumber = formattedPhoneNumber;
                    return sendComponentResponse(this, 'SUCCESSFUL');
                }
            },
            NoIntent() {