InsertWidget

A builder for InsertWidget objects. Developers cans insert a widget into a card by passing a
`https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#` to `https://developers.google.com/apps-script/reference/add-ons-response-service/modify-card`


Only available for Google Workspace add-ons that extend Google Workspace Studio.

Sample usage:

```javascript
const newWidget = CardService.newDecoratedText().setText('New Widget');

const insertWidget = AddOnsResponseService.newInsertWidget()
                                          .insertAboveWidget('sample_id')
                                          .setWidget(newWidget);

const modifyCard = AddOnsResponseService.newModifyCard().setInsertWidget(insertWidget);
```

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#insertAboveWidget(String)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#` | Sets the widget ID, and the new widget is inserted above the widget with the given ID. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#insertBelowWidget(String)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#` | Sets the widget ID, and the new widget is inserted below the widget with the given ID. |
| `https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#setWidget(Widget)` | `https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#` | Sets the `https://developers.google.com/apps-script/reference/card-service/widget.html` to be inserted. |

## Detailed documentation

### `insertAboveWidget(widgetId)`

Sets the widget ID, and the new widget is inserted above the widget with the given ID. An error
is thrown if the widget ID is not found.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `widgetId` | `String` | The ID of the widget to insert above. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#` --- The insert widget object, for chaining.

*** ** * ** ***

### `insertBelowWidget(widgetId)`

Sets the widget ID, and the new widget is inserted below the widget with the given ID. An error
is thrown if the widget ID is not found.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `widgetId` | `String` | The ID of the widget to insert below. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#` --- The insert widget object, for chaining.

*** ** * ** ***

### `setWidget(widget)`

Sets the `https://developers.google.com/apps-script/reference/card-service/widget.html` to be inserted. An error is thrown if there is a existing widget with
the same ID.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `widget` | `https://developers.google.com/apps-script/reference/card-service/widget.html` | The widget to be inserted. |

#### Return


`https://developers.google.com/apps-script/reference/add-ons-response-service/insert-widget#` --- The insert widget object, for chaining.