Builder for [Price](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_price) objects.

Example usage:

```
// Create a price builder.
var priceBuilder = AdsApp.extensions().newPriceBuilder();

// Create a price operation.
var priceOperation = priceBuilder
  .withPriceType("BRANDS")             // required
  .withPriceQualifier("AVERAGE")       // optional
  .withLanguage("en")                  // required
  .addPriceItem(priceItem)             // between 3-8 price items required
  .build();

// Optional: examine the outcome. The call to isSuccessful()
// will block until the operation completes.
if (priceOperation.isSuccessful()) {
  // Get the result.
  var price = priceOperation.getResult();
} else {
  // Handle the errors.
  var errors = priceOperation.getErrors();
}
```

### Methods:

| Member | Type | Description |
|---|---|---|
| [addPriceItem(priceItem)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#addPriceItem_priceItem) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Adds a price item to the price. |
| [build(buildLegacy)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#build_buildLegacy) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_priceoperation` | Creates a [Price](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_price). |
| [withEndDate(date)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#withEndDate_date) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Sets the price's end date from either an object containing year, month, and day fields, or an 8-digit string in `YYYYMMDD` format. |
| [withLanguage(language)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#withLanguage_language) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Sets the language of the price. |
| [withMobilePreferred(isMobilePreferred)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#withMobilePreferred_isMobilePreferred) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Sets the price's device preference to mobile or clears it. |
| [withPriceQualifier(priceQualifier)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#withPriceQualifier_priceQualifier) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Sets the price qualifier of the price. |
| [withPriceType(priceType)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#withPriceType_priceType) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Sets the price type of the price. |
| [withSchedules(schedules)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#withSchedules_schedules) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Sets the price scheduling. |
| [withStartDate(date)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#withStartDate_date) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Sets the price's start date from either an object containing year, month, and day fields, or an 8-digit string in `YYYYMMDD` format. |
| [withTrackingTemplate(trackingTemplate)](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder#withTrackingTemplate_trackingTemplate) | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | Sets the tracking template of the price. |

## `addPriceItem(priceItem)`

Adds a price item to the price. The minimum number of items allowed is 3 and the maximum number is 8. Before calling `build()` the price should contain the right amount of price items.

### Arguments:

| Name | Type | Description |
|---|---|---|
| priceItem | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_priceitem` | The price item to add to the price. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the price item added. |

## `build(buildLegacy)`

Creates a [Price](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_price). Returns a [PriceOperation](https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_priceoperation) that can be used to get the new price (or access any associated errors if creation failed).

Defaults to building the type of price that is currently
serving. If there are upgraded prices, then an upgraded
price will be built by default. If there are only legacy
prices, then a legacy price will be built
by default. If there are neither, then an upgraded price will
be built by default.

### Arguments:

| Name | Type | Description |
|---|---|---|
| buildLegacy | `boolean` | If `true`, builds a legacy price. If `false`, builds an upgraded price. If unspecified, defaults to building whichever type is currently serving. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_priceoperation` | The associated price operation. |

## `withEndDate(date)`

Sets the price's end date from either an object containing year, month, and day fields, or an 8-digit string in `YYYYMMDD` format. This field is optional.

For instance, `priceBuilder.withEndDate("20130503");` is equivalent to `priceBuilder.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

> [!WARNING]
> **Deprecated.**

### Arguments:

| Name | Type | Description |
|---|---|---|
| date | `Object` | The new price end date. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the specified end date. |

## `withLanguage(language)`

Sets the language of the price. This field is required. Supported language codes are:

- de
- en
- es
- es-419
- fr
- it
- ja
- nl
- pl
- pt-BR
- pt-PT
- ru
- sv

### Arguments:

| Name | Type | Description |
|---|---|---|
| language | `String` | The code for the language of the price. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the specified language. |

## `withMobilePreferred(isMobilePreferred)`

Sets the price's device preference to mobile or clears it. This field is optional and defaults to `false`.

> [!WARNING]
> **Deprecated.**

### Arguments:

| Name | Type | Description |
|---|---|---|
| isMobilePreferred | `boolean` | Whether or not this price 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 |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the specified mobile preference. |

## `withPriceQualifier(priceQualifier)`

Sets the price qualifier of the price. This field is required and must be one of `['FROM', 'UP_TO', 'AVERAGE']`

### Arguments:

| Name | Type | Description |
|---|---|---|
| priceQualifier | `String` | The qualifier of the price. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the specified qualifier. |

## `withPriceType(priceType)`

Sets the price type of the price. This field is required and must be one of `['BRANDS', 'EVENTS', 'LOCATIONS', 'NEIGHBORHOODS',
'PRODUCT_CATEGORIES', 'PRODUCT_TIERS', 'SERVICES', 'SERVICE_CATEGORIES',
'SERVICE_TIERS']`

### Arguments:

| Name | Type | Description |
|---|---|---|
| priceType | `String` | The type of the price. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the specified type. |

## `withSchedules(schedules)`

Sets the price scheduling. Scheduling of a price allows you to control the days of week and times of day during which the price will show alongside your ads.

Passing in an empty array clears the scheduling field, causing the price to run at all times.

The following example sets the price 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
 };

priceBuilder.withSchedules([mondayMorning, tuesdayMorning]);
```

> [!WARNING]
> **Deprecated.**

### Arguments:

| Name | Type | Description |
|---|---|---|
| schedules | `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_extensionschedule` | The new price schedules. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the specified schedules. |

## `withStartDate(date)`

Sets the price's start date from either an object containing year, month, and day fields, or an 8-digit string in `YYYYMMDD` format. This field is optional.

For instance, `priceBuilder.withStartDate("20130503");` is equivalent to `priceBuilder.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 price's end date,

> [!WARNING]
> **Deprecated.**

### Arguments:

| Name | Type | Description |
|---|---|---|
| date | `Object` | The new price start date. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the specified start date. |

## `withTrackingTemplate(trackingTemplate)`

Sets the tracking template of the price. To clear this field, set its value to an empty string.

### Arguments:

| Name | Type | Description |
|---|---|---|
| trackingTemplate | `String` | The tracking template of the price. |

### Return values:

| Type | Description |
|---|---|
| `https://developers.google.com/google-ads/scripts/docs/reference/adsapp/adsapp_pricebuilder` | A price builder with the specified tracking template. |