Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions types/google-apps-script/google-apps-script.card-service.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ declare namespace GoogleAppsScript {
* .setParameters({imageSrc: 'carImage'}));
*/
interface Action {
addRequiredWidget(requiredWidget: string): Action;
setAllWidgetsAreRequired(allWidgetsAreRequired: boolean): Action;
setFunctionName(functionName: string): Action;
setInteraction(interaction: Interaction): Action;
setLoadIndicator(loadIndicator: LoadIndicator): Action;
setParameters(parameters: { [key: string]: string }): Action;
/** @deprecated DO NOT USE */ setMethodName(functionName: string): Action;
setPersistValues(persistValues: boolean): Action;
}

/**
* An enum type that specifies what to do in response to an interaction with a user,
* such as a user clicking a button in a card message.
*/
enum Interaction {
INTERACTION_UNSPECIFIED,
OPEN_DIALOG,
}

/**
* 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.
Expand Down Expand Up @@ -271,6 +284,7 @@ declare namespace GoogleAppsScript {
TextButtonStyle: typeof TextButtonStyle;
UpdateDraftBodyType: typeof UpdateDraftBodyType;
InputType: typeof InputType;
Interaction: typeof Interaction;
newAction(): Action;
newActionResponseBuilder(): ActionResponseBuilder;
newAttachment(): Attachment;
Expand Down
5 changes: 5 additions & 0 deletions types/google-apps-script/test/google-apps-script-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ function timeDriven(e: GoogleAppsScript.Events.TimeDriven) {
}
}

CardService.newAction(); // $ExpectType Action
CardService.newAction().addRequiredWidget(""); // $ExpectType Action
CardService.newAction().setAllWidgetsAreRequired(true); // $ExpectType Action
CardService.newAction().setInteraction(CardService.Interaction.OPEN_DIALOG); // $ExpectType Action

CardService.newTextButton().setAltText("alt text"); // $ExpectType TextButton

CardService.newLinkPreview().setTitle("Smart chip title"); // $ExpectType LinkPreview
Expand Down