Page Summary
-
PhoneNumberBuilder is used to create PhoneNumber objects.
-
The
build()method creates a PhoneNumberOperation which can be used to get the result or errors. -
Required methods are
withCountry()to set the country code andwithPhoneNumber()to set the phone number. -
Optional methods include setting mobile preference, start and end dates, and schedules.
-
Some methods like
withCallOnly(),withEndDate(),withMobilePreferred(), andwithStartDate()are deprecated.
Example usage:
// Create a phone number builder . var phoneNumberBuilder = AdsApp . extensions () . newPhoneNumberBuilder (); // Create a phone number operation . var phoneNumberOperation = phoneNumberBuilder . withCountry ( "US" ) // required . withPhoneNumber ( "1234567891" ) // required . withMobilePreferred ( true ) // optional . build (); // Optional : examine the outcome . The call to isSuccessful () // will block until the operation completes . if ( phoneNumberOperation . isSuccessful ()) { // Get the result . var phoneNumber = phoneNumberOperation . getResult (); } else { // Handle the errors . var errors = phoneNumberOperation . getErrors (); }
Methods:
| Member | Type | Description |
|---|---|---|
AdsApp.PhoneNumberOperation
|
Creates a PhoneNumber . | |
AdsApp.PhoneNumberBuilder
|
If set to true
, only the advertiser's phone number will get
displayed. |
|
AdsApp.PhoneNumberBuilder
|
Sets the two character country code of the advertiser's phone number. | |
AdsApp.PhoneNumberBuilder
|
Sets the phone number's end date from either an object containing
year, month, and day fields, or an 8-digit string in YYYYMMDD
format. |
|
AdsApp.PhoneNumberBuilder
|
Sets the phone number's device preference to mobile or clears it. | |
AdsApp.PhoneNumberBuilder
|
Sets the advertiser's phone number that gets appended to the ad. | |
AdsApp.PhoneNumberBuilder
|
Sets the phone number scheduling. | |
AdsApp.PhoneNumberBuilder
|
Sets the phone number's start date from either an object containing
year, month, and day fields, or an 8-digit string in YYYYMMDD
format. |
build(buildLegacy)
Creates a PhoneNumber
.
Returns a PhoneNumberOperation
that can be used to get the new phone number (or access any
associated errors if creation failed). Defaults to building the type of phone number that is currently serving. If there are upgraded phone numbers, then an upgraded phone number will be built by default. If there are only legacy phone numbers, then a legacy phone number will be built by default. If there are neither, then an upgraded phone number will be built by default.
Arguments:
| Name | Type | Description |
|---|---|---|
|
buildLegacy
|
boolean
|
If true
, builds a legacy phone number. If false
, builds an upgraded phone number. If
unspecified, defaults to building whichever type is currently serving. |
Return values:
| Type | Description |
|---|---|
AdsApp.PhoneNumberOperation
|
The associated phone number operation. |
withCallOnly(callOnly)
If set to withCallOnly(callOnly)
true
, only the advertiser's phone number will get
displayed. If set to false
, the link to the advertiser's
website will be shown as well.
Arguments:
| Name | Type | Description |
|---|---|---|
|
callOnly
|
boolean
|
The value for call only setting. |
Return values:
| Type | Description |
|---|---|
AdsApp.PhoneNumberBuilder
|
A phone number builder with the specified value for call only. |
withCountry(country)
Sets the two character country code of the advertiser's phone number. This
field is required. Arguments:
| Name | Type | Description |
|---|---|---|
|
country
|
String
|
The country code for the phone number. |
Return values:
| Type | Description |
|---|---|
AdsApp.PhoneNumberBuilder
|
A phone number builder with the specified country code. |
withEndDate(date)
Sets the phone number's end date from either an object containing
year, month, and day fields, or an 8-digit string in withEndDate(date)
YYYYMMDD
format. This field is optional. For instance, phoneNumberBuilder.withEndDate("20130503");
is equivalent to phoneNumberBuilder.withEndDate({year: 2013, month: 5, day: 3});
.
The change will fail and report an error if:
- the given date is invalid (e.g.,
{year: 2013, month: 5, day: 55}), - the start date now comes after the end date, or
- it's a date in the past
Arguments:
| Name | Type | Description |
|---|---|---|
|
date
|
Object
|
The new phone number end date. |
Return values:
| Type | Description |
|---|---|
AdsApp.PhoneNumberBuilder
|
A phone number builder with the specified end date. |
withMobilePreferred(isMobilePreferred)
Sets the phone number's device preference to mobile or clears it.
This field is optional and defaults to withMobilePreferred(isMobilePreferred)
false
.
Arguments:
| Name | Type | Description |
|---|---|---|
|
isMobilePreferred
|
boolean
|
Whether or not this phone number should be
mobile preferred. If true
is passed in, device preference
will be set to mobile. If false
is passed in, device
preference will be set to none. |
Return values:
| Type | Description |
|---|---|
AdsApp.PhoneNumberBuilder
|
A phone number builder with the specified mobile preference. |
withPhoneNumber(phoneNumber)
Sets the advertiser's phone number that gets appended to the ad. This field
is required. Arguments:
| Name | Type | Description |
|---|---|---|
|
phoneNumber
|
String
|
The phone number as a string. |
Return values:
| Type | Description |
|---|---|
AdsApp.PhoneNumberBuilder
|
A phone number builder with the specified phone number. |
withSchedules(schedules)
Sets the phone number scheduling. Scheduling of a phone number allows you to control the days of week and times of day during which
the phone number will show alongside your ads. Passing in an empty array clears the scheduling field, causing the phone number to run at all times.
The following example sets the phone number to run on Mondays and Tuesday from 8:00 to 11:00.
var mondayMorning = { dayOfWeek : "MONDAY" , startHour : 8 , startMinute : 0 , endHour : 11 , endMinute : 0 }; var tuesdayMorning = { dayOfWeek : "TUESDAY" , startHour : 8 , startMinute : 0 , endHour : 11 , endMinute : 0 }; phoneNumberBuilder . withSchedules ([ mondayMorning , tuesdayMorning ]);
Arguments:
| Name | Type | Description |
|---|---|---|
|
schedules
|
AdsApp.ExtensionSchedule[]
|
The new phone number schedules. |
Return values:
| Type | Description |
|---|---|
AdsApp.PhoneNumberBuilder
|
A phone number builder with the specified schedules. |
withStartDate(date)
Sets the phone number's start date from either an object containing
year, month, and day fields, or an 8-digit string in withStartDate(date)
YYYYMMDD
format. This field is optional. For instance, phoneNumberBuilder.withStartDate("20130503");
is equivalent to phoneNumberBuilder.withStartDate({year: 2013, month: 5, day: 3});
.
The change will fail and report an error if:
- the given date is invalid (e.g.,
{year: 2013, month: 5, day: 55}), - the given date is after the phone number's end date,
Arguments:
| Name | Type | Description |
|---|---|---|
|
date
|
Object
|
The new phone number start date. |
Return values:
| Type | Description |
|---|---|
AdsApp.PhoneNumberBuilder
|
A phone number builder with the specified start date. |

