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
buildAdsApp.PriceItemOperationCreates a PriceItem.
withAmountAdsApp.PriceItemBuilderSets the amount of money of the new price item to the specified value.
withCurrencyCodeAdsApp.PriceItemBuilderSets the currency code of the new price item to the specified value.
withDescriptionAdsApp.PriceItemBuilderSets the description text of the new price item to the specified value.
withFinalUrlAdsApp.PriceItemBuilderSets the final URL of the new price item to the specified value.
withHeaderAdsApp.PriceItemBuilderSets the header text of the new price item to the specified value.
withMobileFinalUrlAdsApp.PriceItemBuilderSets the mobile final URL of the new price item to the specified value.
withUnitTypeAdsApp.PriceItemBuilderSets 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.PriceItemOperationThe 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
amountlongPrice item amount of money in micros.

Return values:

TypeDescription
AdsApp.PriceItemBuilderPrice 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
codeStringPrice item currency code.

Return values:

TypeDescription
AdsApp.PriceItemBuilderPrice 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
descriptionStringPrice item description text.

Return values:

TypeDescription
AdsApp.PriceItemBuilderPrice 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
finalUrlStringThe final URL for the price item.

Return values:

TypeDescription
AdsApp.PriceItemBuilderThe 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
headerStringPrice item header text.

Return values:

TypeDescription
AdsApp.PriceItemBuilderPrice 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
mobileFinalUrlStringThe mobile final URL for the price item.

Return values:

TypeDescription
AdsApp.PriceItemBuilderThe 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
unitTypeStringPrice item unit type.

Return values:

TypeDescription
AdsApp.PriceItemBuilderPrice item builder with the specified unit type.