CardService предоставляет возможность создавать общие карты, используемые в различных продуктах расширения Google, таких как надстройки Google Workspace .
return CardService.newCardBuilder() .setHeader(CardService.newCardHeader().setTitle("CardTitle")) .build();
Или вы можете вернуть несколько карточек следующим образом:
return [ CardService.newCardBuilder().build(), CardService.newCardBuilder().build(), CardService.newCardBuilder().build() ]
Ниже показано, как можно определить карточку с заголовком, текстом, изображением и пунктом меню:
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(); }
Характеристики
Свойство | Тип | Описание |
---|---|---|
BorderType | BorderType | Перечисление BorderType . |
ComposedEmailType | ComposedEmailType | Перечисление ComposedEmailType . |
ContentType | ContentType | Перечисление ContentType . |
GridItemLayout | GridItemLayout | Перечисление GridItemLayout . |
HorizontalAlignment | HorizontalAlignment | Перечисление HorizontalAlignment . |
Icon | Icon | Перечисление Icon . |
ImageCropType | ImageCropType | Перечисление ImageCropType . |
ImageStyle | ImageStyle | Перечисление ImageStyle . |
LoadIndicator | LoadIndicator | Перечисление LoadIndicator . |
OnClose | OnClose | Перечисление OnClose . |
OpenAs | OpenAs | Перечисление OpenAs . |
SelectionInputType | SelectionInputType | Перечисление SelectionInputType . |
TextButtonStyle | TextButtonStyle | Перечисление TextButtonStyle . |
UpdateDraftBodyType | UpdateDraftBodyType | Перечисление UpdateDraftBodyType . |
Методы
Подробная документация
newActionResponseBuilder()
Создает новый ActionResponseBuilder
.
Возвращаться
ActionResponseBuilder
— пустой построитель ActionResponse.
newAttachment()
newAuthorizationAction()
newAuthorizationException()
Создает новое AuthorizationException
.
Возвращаться
AuthorizationException
— пустое исключение AuthorizationException.
newBorderStyle()
newCalendarEventActionResponseBuilder()
Создает новый CalendarEventActionResponseBuilder
.
Возвращаться
CalendarEventActionResponseBuilder
— пустой CalendarEventActionResponseBuilder
.
newCardAction()
newCardBuilder()
newCardHeader()
newCardSection()
newComposeActionResponseBuilder()
Создает новый ComposeActionResponseBuilder
.
Возвращаться
ComposeActionResponseBuilder
— пустой построитель ComposeActionResponse.
newDatePicker()
newDateTimePicker()
newDecoratedText()
newDivider()
Создает новый 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; }
Возвращаться
Divider
— Делитель.
newDriveItemsSelectedActionResponseBuilder()
Создает новый DriveItemsSelectedActionResponseBuilder
.
Возвращаться
DriveItemsSelectedActionResponseBuilder
— пустой DriveItemsSelectedActionResponseBuilder
.
newEditorFileScopeActionResponseBuilder()
Создает новый EditorFileScopeActionResponseBuilder
.
Возвращаться
EditorFileScopeActionResponseBuilder
— Пустой EditorFileScopeActionResponseBuilder
.
newImageButton()
newImageComponent()
newImageCropStyle()
newNotification()
newSelectionInput()
newSuggestions()
newSuggestionsResponseBuilder()
Создает новый SuggestionsResponseBuilder
.
Возвращаться
SuggestionsResponseBuilder
— пустой конструктор OffersResponse.
newTextButton()
newTextParagraph()
newTimePicker()
newUniversalActionResponseBuilder()
Создает новый UniversalActionResponseBuilder
.
Возвращаться
UniversalActionResponseBuilder
— пустой построитель UniversalActionResponse.
newUpdateDraftActionResponseBuilder()
Создает новый UpdateDraftActionResponseBuilder
.
Возвращаться
UpdateDraftActionResponseBuilder
— пустой UpdateDraftActionResponseBuilder.
newUpdateDraftBccRecipientsAction()
Создает новое UpdateDraftBccRecipientsAction
;
Возвращаться
UpdateDraftBccRecipientsAction
— пустое UpdateDraftBccRecipientsAction.
newUpdateDraftBodyAction()
Создает новый UpdateDraftBodyAction
.
Возвращаться
UpdateDraftBodyAction
— пустое UpdateDraftBodyAction.
newUpdateDraftCcRecipientsAction()
Создает новый UpdateDraftCcRecipientsAction
.
Возвращаться
UpdateDraftCcRecipientsAction
— пустое UpdateDraftCcRecipientsAction.
newUpdateDraftSubjectAction()
Создает новый UpdateDraftSubjectAction
.
Возвращаться
UpdateDraftSubjectAction
— пустое UpdateDraftSubjectAction.
newUpdateDraftToRecipientsAction()
Создает новое UpdateDraftToRecipientsAction
.
Возвращаться
UpdateDraftToRecipientsAction
— пустое UpdateDraftToRecipientsAction.