Class CardService

КардСервис

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 .

Методы

Метод Тип возврата Краткое описание
newAction() Action Создает новое Action .
newActionResponseBuilder() ActionResponseBuilder Создает новый ActionResponseBuilder .
newAttachment() Attachment Создает новое Attachment .
newAuthorizationAction() AuthorizationAction Создает новое AuthorizationAction .
newAuthorizationException() AuthorizationException Создает новое AuthorizationException .
newBorderStyle() BorderStyle Создает новый BorderStyle .
newButtonSet() ButtonSet Создает новый ButtonSet .
newCalendarEventActionResponseBuilder() CalendarEventActionResponseBuilder Создает новый CalendarEventActionResponseBuilder .
newCardAction() CardAction Создает новое CardAction .
newCardBuilder() CardBuilder Создает новый CardBuilder .
newCardHeader() CardHeader Создает новый CardHeader .
newCardSection() CardSection Создает новый CardSection .
newComposeActionResponseBuilder() ComposeActionResponseBuilder Создает новый ComposeActionResponseBuilder .
newDatePicker() DatePicker Создает новый DatePicker .
newDateTimePicker() DateTimePicker Создает новый DateTimePicker .
newDecoratedText() DecoratedText Создает новый DecoratedText .
newDivider() Divider Создает новый Divider .
newDriveItemsSelectedActionResponseBuilder() DriveItemsSelectedActionResponseBuilder Создает новый DriveItemsSelectedActionResponseBuilder .
newEditorFileScopeActionResponseBuilder() EditorFileScopeActionResponseBuilder Создает новый EditorFileScopeActionResponseBuilder .
newFixedFooter() FixedFooter Создает новый FixedFooter .
newGrid() Grid Создает новую Grid .
newGridItem() GridItem Создает новый GridItem .
newIconImage() IconImage Создает новый IconImage .
newImage() Image Создает новое Image .
newImageButton() ImageButton Создает новый ImageButton .
newImageComponent() ImageComponent Создает новый ImageComponent .
newImageCropStyle() ImageCropStyle Создает новый ImageCropStyle .
newKeyValue() KeyValue Создает новое KeyValue .
newNavigation() Navigation Создает новую Navigation .
newNotification() Notification Создает новое Notification .
newOpenLink() OpenLink Создает новый OpenLink .
newSelectionInput() SelectionInput Создает новый SelectionInput .
newSuggestions() Suggestions Создает новые Suggestions .
newSuggestionsResponseBuilder() SuggestionsResponseBuilder Создает новый SuggestionsResponseBuilder .
newSwitch() Switch Создает новый Switch .
newTextButton() TextButton Создает новый TextButton .
newTextInput() TextInput Создает новый TextInput .
newTextParagraph() TextParagraph Создает новый TextParagraph .
newTimePicker() TimePicker Создает новый TimePicker .
newUniversalActionResponseBuilder() UniversalActionResponseBuilder Создает новый UniversalActionResponseBuilder .
newUpdateDraftActionResponseBuilder() UpdateDraftActionResponseBuilder Создает новый UpdateDraftActionResponseBuilder .
newUpdateDraftBccRecipientsAction() UpdateDraftBccRecipientsAction Создает новое UpdateDraftBccRecipientsAction ;
newUpdateDraftBodyAction() UpdateDraftBodyAction Создает новый UpdateDraftBodyAction .
newUpdateDraftCcRecipientsAction() UpdateDraftCcRecipientsAction Создает новый UpdateDraftCcRecipientsAction .
newUpdateDraftSubjectAction() UpdateDraftSubjectAction Создает новый UpdateDraftSubjectAction .
newUpdateDraftToRecipientsAction() UpdateDraftToRecipientsAction Создает новое UpdateDraftToRecipientsAction .

Подробная документация

newAction()

Создает новое Action .

Возвращаться

Action — пустое действие.


newActionResponseBuilder()

Создает новый ActionResponseBuilder .

Возвращаться

ActionResponseBuilder — пустой построитель ActionResponse.


newAttachment()

Создает новое Attachment .

Возвращаться

Attachment — пустое вложение.


newAuthorizationAction()

Создает новое AuthorizationAction .

Возвращаться

AuthorizationAction — пустое AuthorizationAction.


newAuthorizationException()

Создает новое AuthorizationException .

Возвращаться

AuthorizationException — пустое исключение AuthorizationException.


newBorderStyle()

Создает новый BorderStyle .

Возвращаться

BorderStyle — пустой BorderStyle.


newButtonSet()

Создает новый ButtonSet .

Возвращаться

ButtonSet — пустой ButtonSet.


newCalendarEventActionResponseBuilder()

Создает новый CalendarEventActionResponseBuilder .

Возвращаться

CalendarEventActionResponseBuilder — пустой CalendarEventActionResponseBuilder .


newCardAction()

Создает новое CardAction .

Возвращаться

CardAction — пустое CardAction.


newCardBuilder()

Создает новый CardBuilder .

Возвращаться

CardBuilder — пустой конструктор карт.


newCardHeader()

Создает новый CardHeader .

Возвращаться

CardHeader — пустой CardHeader.


newCardSection()

Создает новый CardSection .

Возвращаться

CardSection — Пустой CardSection.


newComposeActionResponseBuilder()

Создает новый ComposeActionResponseBuilder .

Возвращаться

ComposeActionResponseBuilder — пустой построитель ComposeActionResponse.


newDatePicker()

Создает новый DatePicker .

Возвращаться

DatePicker — пустой DatePicker.


newDateTimePicker()

Создает новый DateTimePicker .

Возвращаться

DateTimePicker — пустой DateTimePicker.


newDecoratedText()

Создает новый DecoratedText .

Возвращаться

DecoratedText — пустой декорированныйтекст.


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()


newEditorFileScopeActionResponseBuilder()

Создает новый EditorFileScopeActionResponseBuilder .

Возвращаться

EditorFileScopeActionResponseBuilder — Пустой EditorFileScopeActionResponseBuilder .


newFixedFooter()

Создает новый FixedFooter .

Возвращаться

FixedFooter — пустой фиксированный нижний колонтитул.


newGrid()

Создает новую Grid .

Возвращаться

Grid — пустая сетка.


newGridItem()

Создает новый GridItem .

Возвращаться

GridItem — пустой элемент GridItem.


newIconImage()

Создает новый IconImage .

Возвращаться

IconImage — пустое изображение значка.


newImage()

Создает новое Image .

Возвращаться

Image — пустое изображение.


newImageButton()

Создает новый ImageButton .

Возвращаться

ImageButton — Пустой ImageButton.


newImageComponent()

Создает новый ImageComponent .

Возвращаться

ImageComponent — пустой ImageComponent.


newImageCropStyle()

Создает новый ImageCropStyle .

Возвращаться

ImageCropStyle — пустой ImageCropStyle.


newKeyValue()

Создает новое KeyValue .

Возвращаться

KeyValue — пустое значение KeyValue.


newNavigation()

Создает новую Navigation .

Возвращаться

Navigation — пустая навигация.


newNotification()

Создает новое Notification .

Возвращаться

Notification — пустое уведомление.


Создает новый OpenLink .

Возвращаться

OpenLink — пустая OpenLink.


newSelectionInput()

Создает новый SelectionInput .

Возвращаться

SelectionInput — пустой SelectionInput.


newSuggestions()

Создает новые Suggestions .

Возвращаться

Suggestions — пустое поле «Предложения».


newSuggestionsResponseBuilder()

Создает новый SuggestionsResponseBuilder .

Возвращаться

SuggestionsResponseBuilder — пустой конструктор OffersResponse.


newSwitch()

Создает новый Switch .

Возвращаться

Switch — пустой переключатель.


newTextButton()

Создает новый TextButton .

Возвращаться

TextButton — Пустой TextButton.


newTextInput()

Создает новый TextInput .

Возвращаться

TextInput — пустой TextInput.


newTextParagraph()

Создает новый TextParagraph .

Возвращаться

TextParagraph — пустой TextParagraph.


newTimePicker()

Создает новый TimePicker .

Возвращаться

TimePicker — пустой TimePicker.


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.