gas-types-detailed
Version:
Detailed Google Apps Script Type Definitions. Forked from Definitely Typed @types/google-apps-script. Adds full documentation and urls.
1,164 lines (1,056 loc) • 146 kB
TypeScript
// Type definitions for Google Apps Script 2023-10-28
// Project: https://developers.google.com/apps-script/
// Definitions by: motemen <https://github.com/motemen/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="google-apps-script.types.d.ts" />
/// <reference path="google-apps-script.conference-data.d.ts" />
/// <reference path="google-apps-script.gmail.d.ts" />
declare namespace GoogleAppsScript {
namespace Card {
/**
* An action that enables interactivity within UI elements. The action does not happen directly on
* the client but rather invokes an Apps Script callback function
* with optional parameters.
*
* var image = CardService.newImage()
* .setOnClickAction(CardService.newAction()
* .setFunctionName("handleImageClick")
* .setParameters({imageSrc: 'carImage'}));
*/
interface Action {
/**
* Sets the name of the callback function to be called. Required.
* https://developers.google.com/apps-script/reference/card-service/action#setFunctionName(String)
* @param functionName The name of the function. You can use functions from included libraries, such as Library.libFunction1.
*/
setFunctionName(functionName: string): Action;
/**
* Sets the loading indicator that displays while the action is in progress.
* https://developers.google.com/apps-script/reference/card-service/action#setLoadIndicator(LoadIndicator)
* @param loadIndicator The indicator to display.
*/
setLoadIndicator(loadIndicator: LoadIndicator): Action;
/**
* Allows custom parameters to be passed to the callback function. Optional.
* https://developers.google.com/apps-script/reference/card-service/action#setParameters(Object)
* @param parameters Both keys and values must be strings.
*/
setParameters(parameters: any): Action;
/** @deprecated DO NOT USE */ setMethodName(functionName: string): Action;
}
/**
* The response object that may be returned from a callback function (e.g., a form response handler)
* to perform one or more actions on the client. Some combinations of actions are not supported.
*
* // An action that opens a link
* var actionResponse = CardService.newActionResponseBuilder()
* .setOpenLink(CardService.newOpenLink()
* .setUrl("https://www.google.com"))
* .build();
*
* // An action that shows a notification.
* var actionResponse = CardService.newActionResponseBuilder()
* .setNotification(CardService.newNotification()
* .setText("Some info to display to user"))
* .build();
*
* // An action that shows an additional card. It also sets a flag to indicate that the original
* // state data has changed.
*
* var cardBuilder = CardService.newCardBuilder();
* // Build card ...
* var actionResponse = CardService.newActionResponseBuilder()
* .setNavigation(CardService.newNavigation()
* .pushCard(cardBuilder.build()))
* .setStateChanged(true)
* .build();
*/
interface ActionResponse {
/**
* Prints the JSON representation of this object. This is for debugging only.
* https://developers.google.com/apps-script/reference/card-service/action-response#printJson()
*/
printJson(): string;
}
/**
* A builder for ActionResponse objects.
*/
interface ActionResponseBuilder {
/**
* Builds the current action response and validates it.
* https://developers.google.com/apps-script/reference/card-service/action-response-builder#build()
*/
build(): ActionResponse;
/**
* Sets the response to a Navigation action.
* https://developers.google.com/apps-script/reference/card-service/action-response-builder#setNavigation(Navigation)
* @param navigation The Navigation to use.
*/
setNavigation(navigation: Navigation): ActionResponseBuilder;
/**
* Sets the notification to display when the action is activated.
* https://developers.google.com/apps-script/reference/card-service/action-response-builder#setNotification(Notification)
* @param notification The Notification to use.
*/
setNotification(notification: Notification): ActionResponseBuilder;
/**
* Sets the URL to navigate to when the action is activated.
* https://developers.google.com/apps-script/reference/card-service/action-response-builder#setOpenLink(OpenLink)
* @param openLink The OpenLink to use.
*/
setOpenLink(openLink: OpenLink): ActionResponseBuilder;
/**
* Sets a flag to indicate that this action changed the existing data state. For example, if the
* action created a task or updated contact information. When this flag is set to true, services
* such as Gmail can attempt to clear any cached state data associated with this action.
* https://developers.google.com/apps-script/reference/card-service/action-response-builder#setStateChanged(Boolean)
* @param stateChanged Whether this action has changed the existing state data. Defaults to false.
*/
setStateChanged(stateChanged: boolean): ActionResponseBuilder;
}
/**
* Represents an attachment created by an add-on. This can be used within the context of different
* Google extensibility products to generate new attachments, such as for Calendar events.
*
* var attachment = CardService.newAttachment()
* .setResourceUrl("https://fakeresourceurl.com")
* .setTitle("Attachment title")
* .setMimeType("text/html")
* .setIconUrl("https://fakeresourceurl.com/iconurl.png");
*/
interface Attachment {
/**
* Sets the icon URL for the attachment.
* https://developers.google.com/apps-script/reference/card-service/attachment#setIconUrl(String)
* @param iconUrl The URL address of the attachment icon.
*/
setIconUrl(iconUrl: string): Attachment;
/**
* Sets the MIME type for the attachment.
* https://developers.google.com/apps-script/reference/card-service/attachment#setMimeType(String)
* @param mimeType The MIME type of the content in the attachment resource.
*/
setMimeType(mimeType: string): Attachment;
/**
* Sets the resource URL for the attachment.
* https://developers.google.com/apps-script/reference/card-service/attachment#setResourceUrl(String)
* @param resourceUrl The URL address of a resource.
*/
setResourceUrl(resourceUrl: string): Attachment;
/**
* Sets the title for the attachment.
* https://developers.google.com/apps-script/reference/card-service/attachment#setTitle(String)
* @param title The title of the attachment.
*/
setTitle(title: string): Attachment;
}
/**
* An authorization action that will send the user to the AuthorizationUrl when clicked.
*
* CardService.newAuthorizationAction()
* .setAuthorizationUrl("http://google.com/");
*/
interface AuthorizationAction {
/**
* Sets the authorization URL that user is taken to from the authorization prompt. Required.
* https://developers.google.com/apps-script/reference/card-service/authorization-action#setAuthorizationUrl(String)
* @param authorizationUrl The authorization URL to set.
*/
setAuthorizationUrl(authorizationUrl: string): AuthorizationAction;
}
/**
* An error that can be returned to trigger an authorization card to be shown to the user.
*
* CardService.newAuthorizationException()
* .setAuthorizationUrl("http://auth.com/")
* .setResourceDisplayName("Example Resource")
* .throwException();
*/
interface AuthorizationException {
/**
* Prints the JSON representation of this object. This is for debugging only.
* https://developers.google.com/apps-script/reference/card-service/authorization-exception#printJson()
*/
printJson(): string;
/**
* Sets the authorization URL that user is taken to from the authorization prompt. Required.
* https://developers.google.com/apps-script/reference/card-service/authorization-exception#setAuthorizationUrl(String)
* @param authUrl The authorization URL to set.
*/
setAuthorizationUrl(authUrl: string): AuthorizationException;
/**
* The name of a function to call to generate a custom authorization prompt. Optional.
* https://developers.google.com/apps-script/reference/card-service/authorization-exception#setCustomUiCallback(String)
* @param callback The name of the function that generates a custom authorization prompt.
*/
setCustomUiCallback(callback: string): AuthorizationException;
/**
* Sets the name that is displayed to the user when asking for authorization. Required.
* https://developers.google.com/apps-script/reference/card-service/authorization-exception#setResourceDisplayName(String)
* @param name The display name.
*/
setResourceDisplayName(name: string): AuthorizationException;
/**
* Triggers this exception to be thrown.
* https://developers.google.com/apps-script/reference/card-service/authorization-exception#throwException()
*/
throwException(): void;
}
/**
* A class that represents a complete border style that can be applied to widgets.
*/
interface BorderStyle {
/**
* Sets the corner radius of the border, for example 8.
* https://developers.google.com/apps-script/reference/card-service/border-style#setCornerRadius(Integer)
* @param radius The corner radius to be applied to the border.
*/
setCornerRadius(radius: Integer): BorderStyle;
/**
* Sets the color of the border.
* https://developers.google.com/apps-script/reference/card-service/border-style#setStrokeColor(String)
* @param color The color in #RGB format to be applied to the border.
*/
setStrokeColor(color: string): BorderStyle;
/**
* Sets the type of the border.
* https://developers.google.com/apps-script/reference/card-service/border-style#setType(BorderType)
* @param type The border type.
*/
setType(type: BorderType): BorderStyle;
}
/**
* An enum that represents the border types that can be applied to widgets.
*/
enum BorderType { NO_BORDER, STROKE }
/**
* A base class for all buttons.
*/
interface Button {
/**
* Sets an authorization action that opens a URL to the authorization flow when the object is
* clicked. This opens the URL in a new window. When the user finishes the authorization flow and
* returns to the application, the add-on reloads.
*
*
* A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set.
*
*
* // ...
*
* var action = CardService.newAuthorizationAction().setAuthorizationUrl('url');
* CardService.newTextButton().setText('Authorize').setAuthorizationAction(action);
* https://developers.google.com/apps-script/reference/card-service/button#setAuthorizationAction(AuthorizationAction)
* @param action The object that specifies the authorization action to take when this element is clicked.
*/
setAuthorizationAction(action: AuthorizationAction): Button;
/**
* Sets an action that composes a draft email when the object is clicked. A UI object can only
* have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action),
* setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set.
*
*
* The Action parameter must specify a callback function that returns a ComposeActionResponse object configured using ComposeActionResponseBuilder.setGmailDraft(draft).
*
*
*
*
* https://developers.google.com/apps-script/reference/card-service/button#setComposeAction(Action,ComposedEmailType)
* @param action The object that specifies the compose action to take when this element is clicked.
* @param composedEmailType An enum value that specifies whether the composed draft is a standalone or reply draft.
*/
setComposeAction(action: Action, composedEmailType: ComposedEmailType): Button;
/**
* Sets an action that executes when the object is clicked. A UI object can only have one of
* setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set.
*
*
* The Action parameter must specify a callback function that returns a ActionResponse object.
*
*
* // ...
*
* var action = CardService.newAction().setFunctionName('notificationCallback');
* CardService.newTextButton().setText('Create notification').setOnClickAction(action);
*
* // ...
*
* function notificationCallback() {
* return CardService.newActionResponseBuilder()
* .setNotification(CardService.newNotification()
* .setText("Some info to display to user"))
* .build();
* }
* https://developers.google.com/apps-script/reference/card-service/button#setOnClickAction(Action)
* @param action The action to take when this element is clicked.
*/
setOnClickAction(action: Action): Button;
/**
* Sets an action that opens a URL in a tab when the object is clicked. Use this function when the
* URL needs to be built or when you need to take other actions in additon to creating the OpenLink object. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or
* setComposeAction(action, composedEmailType) set.
*
*
* The Action parameter must specify a callback function that returns a ActionResponse object configured using ActionResponseBuilder.setOpenLink(openLink).
*
*
* // ...
*
* var action = CardService.newAction().setFunctionName('openLinkCallback');
* CardService.newTextButton().setText('Open Link').setOnClickOpenLinkAction(action);
*
* // ...
*
* function openLinkCallback() {
* return CardService.newActionResponseBuilder()
* .setOpenLink(CardService.newOpenLink()
* .setUrl('https://www.google.com'))
* .build();
* }
* https://developers.google.com/apps-script/reference/card-service/button#setOnClickOpenLinkAction(Action)
* @param action The object that specifies the open link action to take when this element is clicked.
*/
setOnClickOpenLinkAction(action: Action): Button;
/**
* Sets a URL to be opened when the object is clicked. Use this function when the URL is already
* known and only needs to be opened. A UI object can only have one of setOpenLink(openLink),
* setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action),
* or setComposeAction(action, composedEmailType) set.
* https://developers.google.com/apps-script/reference/card-service/button#setOpenLink(OpenLink)
* @param openLink An OpenLink object describing the URL to open.
*/
setOpenLink(openLink: OpenLink): Button;
}
/**
* Holds a set of Button objects that are displayed in a row.
*
* var textButton = CardService.newTextButton();
* // Finish building the text button...
*
* var imageButton = CardService.newImageButton();
* // Finish building the image button...
*
* var buttonSet = CardService.newButtonSet()
* .addButton(textButton)
* .addButton(imageButton);
*/
interface ButtonSet {
/**
* Adds a button.
* https://developers.google.com/apps-script/reference/card-service/button-set#addButton(Button)
* @param button The button to add.
*/
addButton(button: Button): ButtonSet;
}
/**
* Represents a response that makes changes to the calendar event that the user is currently editing
* in reaction to an action taken in the UI, such as a button click.
*
* // A CalendarEventActionResponse that adds two attendees to an event.
* var calendarEventActionResponse = CardService.newCalendarEventActionResponseBuilder()
* .addAttendees(["user1@example.com", "user2@example.com"])
* .build();
*/
interface CalendarEventActionResponse {
/**
* Prints the JSON representation of this object. This is for debugging only.
* https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response#printJson()
*/
printJson(): string;
}
/**
* A builder for CalendarEventActionResponse objects.
*/
interface CalendarEventActionResponseBuilder {
/**
* Specifies that the response should add the attachments to the Calendar event when the
* associated UI action is taken.
* https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response-builder#addAttachments(Attachment)
* @param attachments An array of Attachments to add.
*/
addAttachments(attachments: Attachment[]): CalendarEventActionResponseBuilder;
/**
* Specifies that the response should add the indicated attendees to the Calendar event when the
* associated UI action is taken.
* https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response-builder#addAttendees(String)
* @param emails An array of email addresses to add to the event.
*/
addAttendees(emails: string[]): CalendarEventActionResponseBuilder;
/**
* Builds the current Calendar event action response and validates it.
* https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response-builder#build()
*/
build(): CalendarEventActionResponse;
/**
* Specifies that the response should set the indicated conference data to the Calendar event when
* the associated UI action is taken.
* https://developers.google.com/apps-script/reference/card-service/calendar-event-action-response-builder#setConferenceData(ConferenceData)
* @param conferenceData Conference data to set to the event, created by an add on.
*/
setConferenceData(conferenceData: Conference_Data.ConferenceData): CalendarEventActionResponseBuilder;
}
/**
* A context card that represents a single view in the
* UI.
*
* var cardSection = CardService.newCardSection();
* // Finish building the card section ...
*
* var card = CardService.newCardBuilder()
* .setName("Card name")
* .setHeader(CardService.newCardHeader().setTitle("Card title"))
* .addSection(cardSection)
* .build();
*/
interface Card {
/**
* Prints the JSON representation of this object. This is for debugging only.
* https://developers.google.com/apps-script/reference/card-service/card#printJson()
*/
printJson(): string;
}
/**
* A clickable menu item that is added to the card header menu.
*
* var action = CardService.newAction();
* // Finish building the action...
*
* var cardAction = CardService.newCardAction()
* .setText("Card action")
* .setOnClickAction(action);
*/
interface CardAction {
/**
* Sets an authorization action that opens a URL to the authorization flow when the object is
* clicked. This opens the URL in a new window. When the user finishes the authorization flow and
* returns to the application, the add-on reloads.
*
*
* A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set.
*
*
* // ...
*
* var action = CardService.newAuthorizationAction().setAuthorizationUrl('url');
* CardService.newTextButton().setText('Authorize').setAuthorizationAction(action);
* https://developers.google.com/apps-script/reference/card-service/card-action#setAuthorizationAction(AuthorizationAction)
* @param action The object that specifies the authorization action to take when this element is clicked.
*/
setAuthorizationAction(action: AuthorizationAction): CardAction;
/**
* Sets an action that composes a draft email when the object is clicked. A UI object can only
* have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action),
* setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set.
*
*
* The Action parameter must specify a callback function that returns a ComposeActionResponse object configured using ComposeActionResponseBuilder.setGmailDraft(draft).
*
*
*
*
* https://developers.google.com/apps-script/reference/card-service/card-action#setComposeAction(Action,ComposedEmailType)
* @param action The object that specifies the compose action to take when this element is clicked.
* @param composedEmailType An enum value that specifies whether the composed draft is a standalone or reply draft.
*/
setComposeAction(action: Action, composedEmailType: ComposedEmailType): CardAction;
/**
* Sets an action that executes when the object is clicked. A UI object can only have one of
* setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or setComposeAction(action, composedEmailType) set.
*
*
* The Action parameter must specify a callback function that returns a ActionResponse object.
*
*
* // ...
*
* var action = CardService.newAction().setFunctionName('notificationCallback');
* CardService.newTextButton().setText('Create notification').setOnClickAction(action);
*
* // ...
*
* function notificationCallback() {
* return CardService.newActionResponseBuilder()
* .setNotification(CardService.newNotification()
* .setText("Some info to display to user"))
* .build();
* }
* https://developers.google.com/apps-script/reference/card-service/card-action#setOnClickAction(Action)
* @param action The action to take when this element is clicked.
*/
setOnClickAction(action: Action): CardAction;
/**
* Sets an action that opens a URL in a tab when the object is clicked. Use this function when the
* URL needs to be built or when you need to take other actions in additon to creating the OpenLink object. A UI object can only have one of setOpenLink(openLink), setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action), or
* setComposeAction(action, composedEmailType) set.
*
*
* The Action parameter must specify a callback function that returns a ActionResponse object configured using ActionResponseBuilder.setOpenLink(openLink).
*
*
* // ...
*
* var action = CardService.newAction().setFunctionName('openLinkCallback');
* CardService.newTextButton().setText('Open Link').setOnClickOpenLinkAction(action);
*
* // ...
*
* function openLinkCallback() {
* return CardService.newActionResponseBuilder()
* .setOpenLink(CardService.newOpenLink()
* .setUrl('https://www.google.com'))
* .build();
* }
* https://developers.google.com/apps-script/reference/card-service/card-action#setOnClickOpenLinkAction(Action)
* @param action The object that specifies the open link action to take when this element is clicked.
*/
setOnClickOpenLinkAction(action: Action): CardAction;
/**
* Sets a URL to be opened when the object is clicked. Use this function when the URL is already
* known and only needs to be opened. A UI object can only have one of setOpenLink(openLink),
* setOnClickAction(action), setOnClickOpenLinkAction(action), setAuthorizationAction(action),
* or setComposeAction(action, composedEmailType) set.
* https://developers.google.com/apps-script/reference/card-service/card-action#setOpenLink(OpenLink)
* @param openLink An OpenLink object describing the URL to open.
*/
setOpenLink(openLink: OpenLink): CardAction;
/**
* Sets the menu text for this action.
* https://developers.google.com/apps-script/reference/card-service/card-action#setText(String)
* @param text The menu item text.
*/
setText(text: string): CardAction;
}
/**
* A builder for Card objects.
*/
interface CardBuilder {
/**
* Adds a CardAction to this Card.
* https://developers.google.com/apps-script/reference/card-service/card-builder#addCardAction(CardAction)
* @param cardAction The CardAction to use.
*/
addCardAction(cardAction: CardAction): CardBuilder;
/**
* Adds a section to this card. You can't add more than 100 sections to a card.
* https://developers.google.com/apps-script/reference/card-service/card-builder#addSection(CardSection)
* @param section The CardSection to use.
*/
addSection(section: CardSection): CardBuilder;
/**
* Builds the current card and validates it.
* https://developers.google.com/apps-script/reference/card-service/card-builder#build()
*/
build(): Card;
/**
* Sets the display style for this card.
*
*
* If the display style is set to DisplayStyle.REPLACE, the card is shown by replacing
* the view of top card in the card stack.
*
*
* If the display style is set to DisplayStyle.PEEK, the header of the card appears at
* the bottom of the sidebar, partially covering the current top card of the stack. Clicking the
* header pops the card into the card stack. If the card has no header, a generated header is used
* instead.
*
*
*
* DisplayStyle only works for card returned from contextual trigger function.
* https://developers.google.com/apps-script/reference/card-service/card-builder#setDisplayStyle(DisplayStyle)
* @param displayStyle The DisplayStyle to set.
*/
setDisplayStyle(displayStyle: DisplayStyle): CardBuilder;
/**
* Sets a fixed footer for this card.
* https://developers.google.com/apps-script/reference/card-service/card-builder#setFixedFooter(FixedFooter)
* @param fixedFooter The FixedFooter to use.
*/
setFixedFooter(fixedFooter: FixedFooter): CardBuilder;
/**
* Sets the header for this card.
* https://developers.google.com/apps-script/reference/card-service/card-builder#setHeader(CardHeader)
* @param cardHeader The CardHeader to use.
*/
setHeader(cardHeader: CardHeader): CardBuilder;
/**
* Sets the name for this card. The name can be used for navigation.
* https://developers.google.com/apps-script/reference/card-service/card-builder#setName(String)
* @param name The name.
*/
setName(name: string): CardBuilder;
/**
* Sets the peek card header.
*
*
* The peek card is set on the first card returned from a contextual trigger function. It is
* used as a descriptive placeholder widget so that users can navigate from a homepage stack to
* the contextual stack.
* https://developers.google.com/apps-script/reference/card-service/card-builder#setPeekCardHeader(CardHeader)
* @param peekCardHeader The CardHeader to set.
*/
setPeekCardHeader(peekCardHeader: CardHeader): CardBuilder;
}
/**
* The header of a Card.
*
* var cardHeader = CardService.newCardHeader()
* .setTitle("Card header title")
* .setSubtitle("Card header subtitle")
* .setImageStyle(CardService.ImageStyle.CIRCLE)
* .setImageUrl("https://image.png");
*/
interface CardHeader {
/**
* Sets the alternative text for the header image.
* https://developers.google.com/apps-script/reference/card-service/card-header#setImageAltText(String)
* @param imageAltText The alternative text for the header image.
*/
setImageAltText(imageAltText: string): CardHeader;
/**
* Sets the cropping of the icon in the card header. Defaults to no crop. Optional.
* https://developers.google.com/apps-script/reference/card-service/card-header#setImageStyle(ImageStyle)
* @param imageStyle The style setting.
*/
setImageStyle(imageStyle: ImageStyle): CardHeader;
/**
* Sets the image to use in the header by providing its URL or data string.
*
*
* The provided URL can either be a publicly accessible URL or a base64 encoded image string.
* To obtain the latter, you can use the following code to create an encoded image string from an
* image in your Google Drive, then store that string for later use with setImageUrl(imageUrl). This method prevents the need for your add-on to access a publicly
* available image URL:
*
*
* // The following assumes you have the image to use in Google Drive and have its ID.
* var imageBytes = DriveApp.getFileById(imageID).getBlob().getBytes();
* var encodedImageURL = "data:image/jpeg;base64," + Utilities.base64Encode(imageBytes);
*
* // You can store encodeImageURL and use it as a parameter to CardHeader.setImageUrl(imageUrl).
* https://developers.google.com/apps-script/reference/card-service/card-header#setImageUrl(String)
* @param imageUrl The URL address of a hosted image to use, or an encoded image string.
*/
setImageUrl(imageUrl: string): CardHeader;
/**
* Sets the subtitle of the card header. Optional.
* https://developers.google.com/apps-script/reference/card-service/card-header#setSubtitle(String)
* @param subtitle The header subtitle text.
*/
setSubtitle(subtitle: string): CardHeader;
/**
* Sets the title of the card header. Required.
* https://developers.google.com/apps-script/reference/card-service/card-header#setTitle(String)
* @param title The header text.
*/
setTitle(title: string): CardHeader;
}
/**
* A card section holds groups of widgets and provides visual separation between them.
*
* var image = CardService.newImage();
* // Build image ...
* var textParagraph = CardService.newTextParagraph();
* // Build text paragraph ...
*
* var cardSection = CardService.newCardSection()
* .setHeader("Section header")
* .addWidget(image)
* .addWidget(textParagraph);
*/
interface CardSection {
/**
* Adds the given widget to this section. Widgets are shown in the order they were added. You
* can't add more than 100 widgets to a card section.
* https://developers.google.com/apps-script/reference/card-service/card-section#addWidget(Widget)
* @param widget A widget to add to the section.
*/
addWidget(widget: Widget): CardSection;
/**
* Sets whether the section can be collapsed.
* https://developers.google.com/apps-script/reference/card-service/card-section#setCollapsible(Boolean)
* @param collapsible The collapsible setting.
*/
setCollapsible(collapsible: boolean): CardSection;
/**
* Sets the header of the section. Optional.
* https://developers.google.com/apps-script/reference/card-service/card-section#setHeader(String)
* @param header The header text.
*/
setHeader(header: string): CardSection;
/**
* Sets the number of widgets that are still shown when this section is collapsed. The widgets
* shown are always the first ones that were added.
* https://developers.google.com/apps-script/reference/card-service/card-section#setNumUncollapsibleWidgets(Integer)
* @param numUncollapsibleWidgets The number of widgets to show.
*/
setNumUncollapsibleWidgets(numUncollapsibleWidgets: Integer): CardSection;
}
/**
* CardService provides the ability to create generic cards used across different Google
* extensibility products, such as Google Workspace Add-ons.
*
* return CardService.newCardBuilder()
* .setHeader(CardService.newCardHeader().setTitle("CardTitle"))
* .build();
*
* Or you can return multiple Cards like so:
*
* return [
* CardService.newCardBuilder().build(),
* CardService.newCardBuilder().build(),
* CardService.newCardBuilder().build()
* ]
*
* The following shows how you could define a card with a header, text, an image and a menu item:
*
* function createWidgetDemoCard() {
* return CardService
* .newCardBuilder()
* .setHeader(
* CardService.newCardHeader()
* .setTitle('Widget demonstration')
* .setSubtitle('Check out these widgets')
* .setImageStyle(CardService.ImageStyle.SQUARE)
* .setImageUrl(
* 'https://www.example.com/images/headerImage.png'))
* .addSection(
* CardService.newCardSection()
* .setHeader('Simple widgets') // optional
* .addWidget(CardService.newTextParagraph().setText(
* 'These widgets are display-only. ' +
* 'A text paragraph can have multiple lines and ' +
* 'formatting.'))
* .addWidget(CardService.newImage().setImageUrl(
* 'https://www.example.com/images/mapsImage.png')))
* .addCardAction(CardService.newCardAction().setText('Gmail').setOpenLink(
* CardService.newOpenLink().setUrl('https://mail.google.com/mail')))
* .build();
* }
*/
interface CardService {
BorderType: typeof BorderType;
ComposedEmailType: typeof ComposedEmailType;
ContentType: typeof ContentType;
GridItemLayout: typeof GridItemLayout;
HorizontalAlignment: typeof HorizontalAlignment;
Icon: typeof Icon;
ImageCropType: typeof ImageCropType;
ImageStyle: typeof ImageStyle;
LoadIndicator: typeof LoadIndicator;
OnClose: typeof OnClose;
OpenAs: typeof OpenAs;
SelectionInputType: typeof SelectionInputType;
TextButtonStyle: typeof TextButtonStyle;
UpdateDraftBodyType: typeof UpdateDraftBodyType;
/**
* Creates a new Action.
* https://developers.google.com/apps-script/reference/card-service/card-service#newAction()
*/
newAction(): Action;
/**
* Creates a new ActionResponseBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newActionResponseBuilder()
*/
newActionResponseBuilder(): ActionResponseBuilder;
/**
* Creates a new Attachment.
* https://developers.google.com/apps-script/reference/card-service/card-service#newAttachment()
*/
newAttachment(): Attachment;
/**
* Creates a new AuthorizationAction.
* https://developers.google.com/apps-script/reference/card-service/card-service#newAuthorizationAction()
*/
newAuthorizationAction(): AuthorizationAction;
/**
* Creates a new AuthorizationException.
* https://developers.google.com/apps-script/reference/card-service/card-service#newAuthorizationException()
*/
newAuthorizationException(): AuthorizationException;
/**
* Creates a new BorderStyle.
* https://developers.google.com/apps-script/reference/card-service/card-service#newBorderStyle()
*/
newBorderStyle(): BorderStyle;
/**
* Creates a new ButtonSet.
* https://developers.google.com/apps-script/reference/card-service/card-service#newButtonSet()
*/
newButtonSet(): ButtonSet;
/**
* Creates a new CalendarEventActionResponseBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newCalendarEventActionResponseBuilder()
*/
newCalendarEventActionResponseBuilder(): CalendarEventActionResponseBuilder;
/**
* Creates a new CardAction.
* https://developers.google.com/apps-script/reference/card-service/card-service#newCardAction()
*/
newCardAction(): CardAction;
/**
* Creates a new CardBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newCardBuilder()
*/
newCardBuilder(): CardBuilder;
/**
* Creates a new CardHeader.
* https://developers.google.com/apps-script/reference/card-service/card-service#newCardHeader()
*/
newCardHeader(): CardHeader;
/**
* Creates a new CardSection.
* https://developers.google.com/apps-script/reference/card-service/card-service#newCardSection()
*/
newCardSection(): CardSection;
/**
* Creates a new ComposeActionResponseBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newComposeActionResponseBuilder()
*/
newComposeActionResponseBuilder(): ComposeActionResponseBuilder;
/**
* Creates a new DatePicker.
* https://developers.google.com/apps-script/reference/card-service/card-service#newDatePicker()
*/
newDatePicker(): DatePicker;
/**
* Creates a new DateTimePicker.
* https://developers.google.com/apps-script/reference/card-service/card-service#newDateTimePicker()
*/
newDateTimePicker(): DateTimePicker;
/**
* Creates a new DecoratedText.
* https://developers.google.com/apps-script/reference/card-service/card-service#newDecoratedText()
*/
newDecoratedText(): DecoratedText;
/**
* Creates a new Divider. The following sample builds a simple card with 2 paragraphs
* separated by a divider.
*
*
* function buildCard() {
* let cardSection1TextParagraph1 = CardService.newTextParagraph()
* .setText('Hello world!');
*
* let cardSection1Divider1 = CardService.newDivider();
*
* let cardSection1TextParagraph2 = CardService.newTextParagraph()
* .setText('Hello world!');
*
* let cardSection1 = CardService.newCardSection()
* .addWidget(cardSection1TextParagraph1)
* .addWidget(cardSection1Divider1)
* .addWidget(cardSection1TextParagraph2);
*
* let card = CardService.newCardBuilder()
* .addSection(cardSection1)
* .build();
*
* return card;
* }
* https://developers.google.com/apps-script/reference/card-service/card-service#newDivider()
*/
newDivider(): Divider;
/**
* Creates a new DriveItemsSelectedActionResponseBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newDriveItemsSelectedActionResponseBuilder()
*/
newDriveItemsSelectedActionResponseBuilder(): DriveItemsSelectedActionResponseBuilder;
/**
* Creates a new EditorFileScopeActionResponseBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newEditorFileScopeActionResponseBuilder()
*/
newEditorFileScopeActionResponseBuilder(): EditorFileScopeActionResponseBuilder;
/**
* Creates a new FixedFooter.
* https://developers.google.com/apps-script/reference/card-service/card-service#newFixedFooter()
*/
newFixedFooter(): FixedFooter;
/**
* Creates a new Grid.
* https://developers.google.com/apps-script/reference/card-service/card-service#newGrid()
*/
newGrid(): Grid;
/**
* Creates a new GridItem.
* https://developers.google.com/apps-script/reference/card-service/card-service#newGridItem()
*/
newGridItem(): GridItem;
/**
* Creates a new IconImage.
* https://developers.google.com/apps-script/reference/card-service/card-service#newIconImage()
*/
newIconImage(): IconImage;
/**
* Creates a new Image.
* https://developers.google.com/apps-script/reference/card-service/card-service#newImage()
*/
newImage(): Image;
/**
* Creates a new ImageButton.
* https://developers.google.com/apps-script/reference/card-service/card-service#newImageButton()
*/
newImageButton(): ImageButton;
/**
* Creates a new ImageComponent.
* https://developers.google.com/apps-script/reference/card-service/card-service#newImageComponent()
*/
newImageComponent(): ImageComponent;
/**
* Creates a new ImageCropStyle.
* https://developers.google.com/apps-script/reference/card-service/card-service#newImageCropStyle()
*/
newImageCropStyle(): ImageCropStyle;
/**
* Creates a new KeyValue.
* https://developers.google.com/apps-script/reference/card-service/card-service#newKeyValue()
*/
newKeyValue(): KeyValue;
/**
* Creates a new Navigation.
* https://developers.google.com/apps-script/reference/card-service/card-service#newNavigation()
*/
newNavigation(): Navigation;
/**
* Creates a new Notification.
* https://developers.google.com/apps-script/reference/card-service/card-service#newNotification()
*/
newNotification(): Notification;
/**
* Creates a new OpenLink.
* https://developers.google.com/apps-script/reference/card-service/card-service#newOpenLink()
*/
newOpenLink(): OpenLink;
/**
* Creates a new SelectionInput.
* https://developers.google.com/apps-script/reference/card-service/card-service#newSelectionInput()
*/
newSelectionInput(): SelectionInput;
/**
* Creates a new Suggestions.
* https://developers.google.com/apps-script/reference/card-service/card-service#newSuggestions()
*/
newSuggestions(): Suggestions;
/**
* Creates a new SuggestionsResponseBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newSuggestionsResponseBuilder()
*/
newSuggestionsResponseBuilder(): SuggestionsResponseBuilder;
/**
* Creates a new Switch.
* https://developers.google.com/apps-script/reference/card-service/card-service#newSwitch()
*/
newSwitch(): Switch;
/**
* Creates a new TextButton.
* https://developers.google.com/apps-script/reference/card-service/card-service#newTextButton()
*/
newTextButton(): TextButton;
/**
* Creates a new TextInput.
* https://developers.google.com/apps-script/reference/card-service/card-service#newTextInput()
*/
newTextInput(): TextInput;
/**
* Creates a new TextParagraph.
* https://developers.google.com/apps-script/reference/card-service/card-service#newTextParagraph()
*/
newTextParagraph(): TextParagraph;
/**
* Creates a new TimePicker.
* https://developers.google.com/apps-script/reference/card-service/card-service#newTimePicker()
*/
newTimePicker(): TimePicker;
/**
* Creates a new UniversalActionResponseBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newUniversalActionResponseBuilder()
*/
newUniversalActionResponseBuilder(): UniversalActionResponseBuilder;
/**
* Creates a new UpdateDraftActionResponseBuilder.
* https://developers.google.com/apps-script/reference/card-service/card-service#newUpdateDraftActionResponseBuilder()
*/
newUpdateDraftActionResponseBuilder(): UpdateDraftActionResponseBuilder;
/**
* Creates a new UpdateDraftBccRecipientsAction;
* https://developers.google.com/apps-script/reference/card-service/card-service#newUpdateDraftBccRecipientsAction()
*/
newUpdateDraftBccRecipientsAction(): UpdateDraftBccRecipientsAction;
/**
* Creates a new UpdateDraftBodyAction.
* https://developers.google.com/apps-script/reference/card-service/card-service#newUpdateDraftBodyAction()
*/
newUpdateDraftBodyAction(): UpdateDraftBodyAction;
/**
* Creates a new UpdateDraftCcRecipientsAction.
* https://developers.google.com/apps-script/reference/card-service/card-service#newUpdateDraftCcRecipientsAction()
*/
newUpdateDraftCcRecipientsAction(): UpdateDraftCcRecipientsAction;
/**
* Creates a new UpdateDraftSubjectAction.
* https://developers.google.com/apps-script/reference/card-service/card-service#newUpdateDraftSubjectAction()
*/
newUpdateDraftSubjectAction(): UpdateDraftSubjectAction;
/**
* Creates a new UpdateDraftToRecipientsAction.
* https://developers.google.com/apps-script/reference/card-service/card-service#newUpdateDraftToRecipientsAction()
*/
newUpdateDraftToRecipientsAction(): UpdateDraftToRecipientsAction;
}
/**
* The response object that may be returned from a callback method for compose action in a Gmail add-on.
*
* Note: This object isn't related to compose actions that are
* used to extend the compose UI. Rather,
* this object is a response to an Action that composes draft messages when a specific UI element is
* selected.
*
* var composeActionResponse = CardService.newComposeActionResponseBuilder()
* .setGmailDraft(GmailApp.createDraft("recipient", "subject", "body"))
* .build();
*/
interface ComposeActionResponse {
/**
* Prints the JSON representation of this object. This is for debugging only.
* https://developers.google.com/apps-script/reference/card-service/compose-action-response#printJson()
*/
printJson(): string;
}
/**
* A builder for ComposeActionResponse objects.
*
* Note: This object isn't related to compose actions that are
* used to extend the compose UI. Rather,
* this builder creates responses to an Action that composes draft messages when a specific
* UI element is selected.
*/
interface ComposeActionResponseBuilder {
/**
* Builds the current compose action response and validates it.
* https://developers.google.com/apps-script/reference/card-service/compose-action-response-builder#build()
*/
build(): ComposeActionResponse;
/**
* Sets the draft GmailMessage created
* using GmailMessage.createDraftReply(body) or
* similar functions.
* https://developers.google.com/apps-script/reference/card-service/compose-action-response-builder#setGmailDraft(GmailDraft)
* @param draft The GmailDraft to use.
*/
setGmailDraft(draft: Gmail.GmailDraft): ComposeActionResponseBuilder;
}
/**
* An enum value that specifies whether the composed email is a standalone or reply draft.
*/
enum ComposedEmailType { REPLY_AS_DRAFT, STANDALONE_DRAFT }
/**
* An enum value that specifies the content type of the content generated by a UpdateDraftActionResponse.
*/
enum ContentType { TEXT, MUTABLE_HTML, IMMUTABLE_HTML }
/**
* An input field that allows inputing a date.
*
* var dateTimePicker = CardService.newDatePicker()
* .setTitle("Enter the date.")
* .setFieldName("date_field")
* // Set default value as Jan 1, 2018 UTC. Either a nu