AI-generated Key Takeaways
-
PriceItemBuilder is used to create PriceItem objects in AdsApp scripts.
-
Several methods are available to configure the price item, including setting the header, description, amount, currency code, unit type, and final URLs.
-
The build() method creates the PriceItem and returns a PriceItemOperation to check the outcome and access the resulting PriceItem or errors.
-
Specific fields like header, description, amount, currency code, and unit type are required before building the PriceItem.
Example usage:
// Create a price item builder . var priceItemBuilder = AdsApp . extensions () . newPriceItemBuilder (); // Create a price item operation . var priceItemOperation = priceItemBuilder . withHeader ( "Kid's Haircut" ) // required . withDescription ( "Girls and boys" ) // required . withAmount ( 10 ) // required . withCurrencyCode ( "USD" ) // required . withUnitType ( "PER_WEEK" ) // required . withFinalUrl ( "http://www.example.com/" ) // required . build (); // Optional : examine the outcome . The call to isSuccessful () // will block until the operation completes . if ( priceItemOperation . isSuccessful ()) { // Get the result . var priceItem = priceItemOperation . getResult (); } else { // Handle the errors . var errors = priceItemOperation . getErrors (); }
Methods:
| Member | Type | Description |
|---|---|---|
AdsApp.PriceItemOperation
|
Creates a PriceItem . | |
AdsApp.PriceItemBuilder
|
Sets the amount of money of the new price item to the specified value. | |
AdsApp.PriceItemBuilder
|
Sets the currency code of the new price item to the specified value. | |
AdsApp.PriceItemBuilder
|
Sets the description text of the new price item to the specified value. | |
AdsApp.PriceItemBuilder
|
Sets the final URL of the new price item to the specified value. | |
AdsApp.PriceItemBuilder
|
Sets the header text of the new price item to the specified value. | |
AdsApp.PriceItemBuilder
|
Sets the mobile final URL of the new price item to the specified value. | |
AdsApp.PriceItemBuilder
|
Sets the unit type of the new price item to the specified value. |
build()
Creates a PriceItem
. Returns a
PriceItemOperation that can be used to get the new price item (or access
any associated errors if creation failed). Return values:
| Type | Description |
|---|---|
AdsApp.PriceItemOperation
|
The associated price item operation. |
withAmount(amount)
Sets the amount of money of the new price item to the specified value.
Required before building. Arguments:
| Name | Type | Description |
|---|---|---|
|
amount
|
long
|
Price item amount of money in micros. |
Return values:
| Type | Description |
|---|---|
AdsApp.PriceItemBuilder
|
Price item builder with the specified amount of money in micros. |
withCurrencyCode(code)
Sets the currency code of the new price item to the specified value.
Required before building. See the API
reference
for currency codes. Arguments:
| Name | Type | Description |
|---|---|---|
|
code
|
String
|
Price item currency code. |
Return values:
| Type | Description |
|---|---|
AdsApp.PriceItemBuilder
|
Price item builder with the specified currency code. |
withDescription(description)
Sets the description text of the new price item to the specified value.
Required before building. Arguments:
| Name | Type | Description |
|---|---|---|
|
description
|
String
|
Price item description text. |
Return values:
| Type | Description |
|---|---|
AdsApp.PriceItemBuilder
|
Price item builder with the specified description text. |
withFinalUrl(finalUrl)
Sets the final URL of the new price item to the specified value. The final URL represents the actual landing page for your price item. The final URL must be the URL of the page that the user ends up on after clicking on your ad, once all the redirects have taken place.
See Using Upgraded URLs for more information.
Arguments:
| Name | Type | Description |
|---|---|---|
|
finalUrl
|
String
|
The final URL for the price item. |
Return values:
| Type | Description |
|---|---|
AdsApp.PriceItemBuilder
|
The price item builder with the specified final URL. |
withHeader(header)
Sets the header text of the new price item to the specified value. Required
before building. Arguments:
| Name | Type | Description |
|---|---|---|
|
header
|
String
|
Price item header text. |
Return values:
| Type | Description |
|---|---|
AdsApp.PriceItemBuilder
|
Price item builder with the specified header text. |
withMobileFinalUrl(mobileFinalUrl)
Sets the mobile final URL of the new price item to the specified
value. The mobile final URL represents the actual landing page for your price item on a mobile device. The final mobile URL must be the URL of the page that the user ends up on after clicking on your ad on a mobile device, once all the redirects have taken place.
See Using Upgraded URLs for more information.
Arguments:
| Name | Type | Description |
|---|---|---|
|
mobileFinalUrl
|
String
|
The mobile final URL for the price item. |
Return values:
| Type | Description |
|---|---|
AdsApp.PriceItemBuilder
|
The price item builder with the specified final URL. |
withUnitType(unitType)
Sets the unit type of the new price item to the specified value. Required
before building. The unit type defines the rate that describes the price
and must be one of ['PER_HOUR', 'PER_DAY', 'PER_WEEK', 'PER_MONTH',
'PER_YEAR', 'PER_NIGHT']
. Arguments:
| Name | Type | Description |
|---|---|---|
|
unitType
|
String
|
Price item unit type. |
Return values:
| Type | Description |
|---|---|
AdsApp.PriceItemBuilder
|
Price item builder with the specified unit type. |

