AdsApp.​PriceItemBuilder

Builder for PriceItem objects.

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:

MemberTypeDescription
build AdsApp.PriceItemOperation Creates a PriceItem.
withAmount AdsApp.PriceItemBuilder Sets the amount of money of the new price item to the specified value.
withCurrencyCode AdsApp.PriceItemBuilder Sets the currency code of the new price item to the specified value.
withDescription AdsApp.PriceItemBuilder Sets the description text of the new price item to the specified value.
withFinalUrl AdsApp.PriceItemBuilder Sets the final URL of the new price item to the specified value.
withHeader AdsApp.PriceItemBuilder Sets the header text of the new price item to the specified value.
withMobileFinalUrl AdsApp.PriceItemBuilder Sets the mobile final URL of the new price item to the specified value.
withUnitType 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:

TypeDescription
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:

NameTypeDescription
amount long Price item amount of money in micros.

Return values:

TypeDescription
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:

NameTypeDescription
code String Price item currency code.

Return values:

TypeDescription
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:

NameTypeDescription
description String Price item description text.

Return values:

TypeDescription
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:

NameTypeDescription
finalUrl String The final URL for the price item.

Return values:

TypeDescription
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:

NameTypeDescription
header String Price item header text.

Return values:

TypeDescription
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:

NameTypeDescription
mobileFinalUrl String The mobile final URL for the price item.

Return values:

TypeDescription
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:

NameTypeDescription
unitType String Price item unit type.

Return values:

TypeDescription
AdsApp.PriceItemBuilder Price item builder with the specified unit type.