Class CardService

CardService

CardService, Google Workspace Eklentileri gibi farklı Google genişletilebilirlik ürünlerinde kullanılan genel kartlar oluşturabilmenizi sağlar.

Aşağıda bir eklenti kartı örneği verilmiştir.

return CardService.newCardBuilder()
         .setHeader(CardService.newCardHeader().setTitle("CardTitle"))
         .build();

Dilerseniz aşağıdaki gibi birden fazla Kartı da döndürebilirsiniz:

return [
  CardService.newCardBuilder().build(),
  CardService.newCardBuilder().build(),
  CardService.newCardBuilder().build()
]

Aşağıda başlık, metin, resim ve menü öğesi içeren bir kartı nasıl tanımlayabileceğiniz gösterilmektedir:

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

Sohbet uygulamaları kartı örneği.

const cardHeader = CardService.newCardHeader()
    .setTitle("Sasha")
    .setSubtitle("Software Engineer")
    .setImageUrl('https://developers.google.com/chat/images/quickstart-app-avatar.png')
    .setImageStyle(CardService.ImageStyle.CIRCLE)
    .setImageAltText("Avatar for Sasha");

const cardSection = CardService.newCardSection()
    .setHeader("Contact Info")
    .setCollapsible(true)
    .setNumUncollapsibleWidgets(1)
    .addWidget(
       CardService.newDecoratedText()
         .setStartIcon(CardService.newIconImage().setIcon(CardService.Icon.EMAIL))
         .setText("sasha@example.com"))
    .addWidget(
       CardService.newDecoratedText()
          .setStartIcon(CardService.newIconImage().setIcon(CardService.Icon.PERSON))
          .setText("<font color=\"#80e27e\">Online</font>"))
    .addWidget(
       CardService.newDecoratedText()
          .setStartIcon(CardService.newIconImage().setIcon(CardService.Icon.PHONE))
          .setText("+1 (555) 555-1234"))
    .addWidget(
       CardService.newButtonSet()
          .addButton(CardService.newTextButton()
           .setText("Share")
           .setOpenLink(CardService.newOpenLink().setUrl("https://example.com/share")))
          .addButton(CardService.newTextButton()
           .setText("Edit")
           .setOnClickAction(
         CardService.newAction().setFunctionName("goToView").setParameters({viewType:"EDIT"}))))

const card = CardService.newCardBuilder()
    .setHeader(cardHeader)
    .addSection(cardSection)
    .build();

Özellikler

ÖzellikTürAçıklama
BorderTypeBorderTypeBorderType sıralaması.
ComposedEmailTypeComposedEmailTypeComposedEmailType sıralaması.
ContentTypeContentTypeContentType sıralaması.
GridItemLayoutGridItemLayoutGridItemLayout sıralaması.
HorizontalAlignmentHorizontalAlignmentHorizontalAlignment sıralaması.
IconIconIcon sıralaması.
ImageCropTypeImageCropTypeImageCropType sıralaması.
ImageStyleImageStyleImageStyle sıralaması.
LoadIndicatorLoadIndicatorLoadIndicator sıralaması.
OnCloseOnCloseOnClose sıralaması.
OpenAsOpenAsOpenAs sıralaması.
SelectionInputTypeSelectionInputTypeSelectionInputType sıralaması.
TextButtonStyleTextButtonStyleTextButtonStyle sıralaması.
UpdateDraftBodyTypeUpdateDraftBodyTypeUpdateDraftBodyType sıralaması.

Yöntemler

YöntemDönüş türüKısa açıklama
newAction()ActionYeni bir Action oluşturur.
newActionResponseBuilder()ActionResponseBuilderYeni bir ActionResponseBuilder oluşturur.
newActionStatus()ActionStatusYeni bir ActionStatus oluşturur.
newAttachment()AttachmentYeni bir Attachment oluşturur.
newAuthorizationAction()AuthorizationActionYeni bir AuthorizationAction oluşturur.
newAuthorizationException()AuthorizationExceptionYeni bir AuthorizationException oluşturur.
newBorderStyle()BorderStyleYeni bir BorderStyle oluşturur.
newButtonSet()ButtonSetYeni bir ButtonSet oluşturur.
newCalendarEventActionResponseBuilder()CalendarEventActionResponseBuilderYeni bir CalendarEventActionResponseBuilder oluşturur.
newCardAction()CardActionYeni bir CardAction oluşturur.
newCardBuilder()CardBuilderYeni bir CardBuilder oluşturur.
newCardHeader()CardHeaderYeni bir CardHeader oluşturur.
newCardSection()CardSectionYeni bir CardSection oluşturur.
newCardWithId()CardWithIdYeni bir CardWithId oluşturur.
newChatActionResponse()ChatActionResponseYeni bir ChatActionResponse oluşturur.
newChatResponseBuilder()ChatResponseBuilderYeni bir ChatResponseBuilder oluşturur.
newColumn()ColumnYeni bir Column oluşturur.
newColumns()ColumnsYeni bir Columns grubu oluşturur.
newComposeActionResponseBuilder()ComposeActionResponseBuilderYeni bir ComposeActionResponseBuilder oluşturur.
newDatePicker()DatePickerYeni bir DatePicker oluşturur.
newDateTimePicker()DateTimePickerYeni bir DateTimePicker oluşturur.
newDecoratedText()DecoratedTextYeni bir DecoratedText oluşturur.
newDialog()DialogYeni bir Dialog oluşturur.
newDialogAction()DialogActionYeni bir DialogAction oluşturur.
newDivider()DividerYeni bir Divider oluşturur.
newDriveItemsSelectedActionResponseBuilder()DriveItemsSelectedActionResponseBuilderYeni bir DriveItemsSelectedActionResponseBuilder oluşturur.
newEditorFileScopeActionResponseBuilder()EditorFileScopeActionResponseBuilderYeni bir EditorFileScopeActionResponseBuilder oluşturur.
newFixedFooter()FixedFooterYeni bir FixedFooter oluşturur.
newGrid()GridYeni bir Grid oluşturur.
newGridItem()GridItemYeni bir GridItem oluşturur.
newIconImage()IconImageYeni bir IconImage oluşturur.
newImage()ImageYeni bir Image oluşturur.
newImageButton()ImageButtonYeni bir ImageButton oluşturur.
newImageComponent()ImageComponentYeni bir ImageComponent oluşturur.
newImageCropStyle()ImageCropStyleYeni bir ImageCropStyle oluşturur.
newKeyValue()KeyValueYeni bir KeyValue oluşturur.
newLinkPreview()LinkPreviewYeni bir LinkPreview oluşturur.
newNavigation()NavigationYeni bir Navigation oluşturur.
newNotification()NotificationYeni bir Notification oluşturur.
newOpenLink()OpenLinkYeni bir OpenLink oluşturur.
newSelectionInput()SelectionInputYeni bir SelectionInput oluşturur.
newSuggestions()SuggestionsYeni bir Suggestions oluşturur.
newSuggestionsResponseBuilder()SuggestionsResponseBuilderYeni bir SuggestionsResponseBuilder oluşturur.
newSwitch()SwitchYeni bir Switch oluşturur.
newTextButton()TextButtonYeni bir TextButton oluşturur.
newTextInput()TextInputYeni bir TextInput oluşturur.
newTextParagraph()TextParagraphYeni bir TextParagraph oluşturur.
newTimePicker()TimePickerYeni bir TimePicker oluşturur.
newUniversalActionResponseBuilder()UniversalActionResponseBuilderYeni bir UniversalActionResponseBuilder oluşturur.
newUpdateDraftActionResponseBuilder()UpdateDraftActionResponseBuilderYeni bir UpdateDraftActionResponseBuilder oluşturur.
newUpdateDraftBccRecipientsAction()UpdateDraftBccRecipientsActionYeni bir UpdateDraftBccRecipientsAction oluşturur;
newUpdateDraftBodyAction()UpdateDraftBodyActionYeni bir UpdateDraftBodyAction oluşturur.
newUpdateDraftCcRecipientsAction()UpdateDraftCcRecipientsActionYeni bir UpdateDraftCcRecipientsAction oluşturur.
newUpdateDraftSubjectAction()UpdateDraftSubjectActionYeni bir UpdateDraftSubjectAction oluşturur.
newUpdateDraftToRecipientsAction()UpdateDraftToRecipientsActionYeni bir UpdateDraftToRecipientsAction oluşturur.

Ayrıntılı belgeler

newAction()

Yeni bir Action oluşturur.

Return

Action — Boş bir İşlem.


newActionResponseBuilder()

Yeni bir ActionResponseBuilder oluşturur.

Return

ActionResponseBuilder: Boş bir ActionResponse oluşturucu.


newActionStatus()

Yeni bir ActionStatus oluşturur.

Yalnızca Google Chat uygulamalarında kullanılabilir. Google Workspace Eklentileri için kullanılamaz.

const actionStatus = CardService.newActionStatus()
    .setStatusCode(CardService.Status.OK)
    .setUserFacingMessage('Success');

Return

ActionStatus — Boş bir ActionStatus.


newAttachment()

Yeni bir Attachment oluşturur.

Return

Attachment - Boş bir ek.


newAuthorizationAction()

Yeni bir AuthorizationAction oluşturur.

Return

AuthorizationAction — Boş bir AuthorizationAction.


newAuthorizationException()

Yeni bir AuthorizationException oluşturur.

Return

AuthorizationException — Boş bir AuthorizationException.


newBorderStyle()

Yeni bir BorderStyle oluşturur.

Return

BorderStyle — Boş bir BorderStyle.


newButtonSet()

Yeni bir ButtonSet oluşturur.

Return

ButtonSet — Boş bir ButtonSet.


newCalendarEventActionResponseBuilder()


newCardAction()

Yeni bir CardAction oluşturur.

Return

CardAction — Boş bir CardAction.


newCardBuilder()

Yeni bir CardBuilder oluşturur.

Return

CardBuilder — Boş bir Kart oluşturucu.


newCardHeader()

Yeni bir CardHeader oluşturur.

Return

CardHeader — Boş bir CardHeader.


newCardSection()

Yeni bir CardSection oluşturur.

Return

CardSection — Boş bir CardSection.


newCardWithId()

Yeni bir CardWithId oluşturur. Bu, Google Chat mesajında kart göndermek için kullanılır. Kart kimliği, birden fazla kart gönderirken kullanılan bir mesajdaki kartın benzersiz tanımlayıcısıdır.

Yalnızca Google Chat uygulamalarında kullanılabilir. Google Workspace Eklentileri için kullanılamaz.

const cardSection = CardService.newCardSection();
cardSection.addWidget(
    CardService.newTextParagraph().setText('This is a text paragraph widget.'));

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title'))
    .addSection(cardSection)
    .build();

const cardWithId = CardService.newCardWithId()
    .setCardId('card_id')
    .setCard(card);

Return

CardWithId — Boş bir CardWithId.


newChatActionResponse()

Yeni bir ChatActionResponse oluşturur.

Yalnızca Google Chat uygulamalarında kullanılabilir. Google Workspace Eklentileri için kullanılamaz.

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title')).build();
const dialog = CardService.newDialog()
    .setBody(card);

const dialogAction = CardService.newDialogAction()
    .setDialog(dialog)

const chatActionResponse = CardService.newChatActionResponse()
    .setResponseType(CardService.ResponseType.DIALOG)
    .setDialogAction(dialogAction);

Return

ChatActionResponse — Boş bir ChatActionResponse.


newChatResponseBuilder()

Yeni bir ChatResponseBuilder oluşturur.

Yalnızca Google Chat uygulamalarında kullanılabilir. Google Workspace Eklentileri için kullanılamaz.

const cardSection = CardService.newCardSection();
cardSection.addWidget(
    CardService.newTextParagraph().setText('This is a text paragraph widget.'));

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title'))
    .addSection(cardSection)
    .build();

const cardWithId = CardService.newCardWithId()
    .setCardId('card_id')
    .setCard(card);

const chatResponse = CardService.newChatResponseBuilder()
    .addCardsV2(cardWithId)
    .build();

Return

ChatResponseBuilder — Boş bir ChatResponseBuilder.


newColumn()

Yeni bir Column oluşturur.

Google Chat uygulamaları ve Google Workspace Eklentileri için kullanılabilir.

const columnWidget = CardService.newTextParagraph();
const column = CardService.newColumn()
    .setHorizontalSizeStyle(CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE)
    .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER)
    .setVerticalAlignment(CardService.VerticalAlignment.CENTER)
    .addWidget(columnWidget);

Return

Column — Boş bir sütun.


newColumns()

Yeni bir Columns grubu oluşturur.

Google Chat uygulamaları ve Google Workspace Eklentileri için kullanılabilir.

const firstColumn = CardService.newColumn()
    .setHorizontalSizeStyle(CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE)
    .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER)
    .setVerticalAlignment(CardService.VerticalAlignment.CENTER);
const secondColumn = CardService.newColumn()
    .setHorizontalSizeStyle(CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE)
    .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER)
    .setVerticalAlignment(CardService.VerticalAlignment.CENTER);
const columns = CardService.newColumns()
    .addColumn(column)
    .addColumn(secondColumn)
    .setWrapStyle(CardService.WrapStyle.WRAP);

Return

Columns — Boş bir sütun grubu.


newComposeActionResponseBuilder()

Yeni bir ComposeActionResponseBuilder oluşturur.

Return

ComposeActionResponseBuilder — Boş bir ComposeActionResponse oluşturucu.


newDatePicker()

Yeni bir DatePicker oluşturur.

Return

DatePicker — Boş bir DateChooseer.


newDateTimePicker()

Yeni bir DateTimePicker oluşturur.

Return

DateTimePicker — Boş bir DateTimeChooseer.


newDecoratedText()

Yeni bir DecoratedText oluşturur.

Return

DecoratedText — Boş bir DecoratedText.


newDialog()

Yeni bir Dialog oluşturur.

Yalnızca Google Chat uygulamalarında kullanılabilir. Google Workspace Eklentileri için kullanılamaz.

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title')).build();

// Sets the card of the dialog.
const dialog = CardService.newDialog()
    .setBody(card);

Return

Dialog — Boş bir Dialog.


newDialogAction()

Yeni bir DialogAction oluşturur.

Yalnızca Google Chat uygulamalarında kullanılabilir. Google Workspace Eklentileri için kullanılamaz.

const card = CardService.newCardBuilder()
    .setHeader(CardService.newCardHeader().setTitle('Card title')).build();
const dialog = CardService.newDialog()
    .setBody(card);

const dialogAction = CardService.newDialogAction()
    .setDialog(dialog)

Return

DialogAction — Boş bir DialogAction.


newDivider()

Yeni bir Divider oluşturur. Aşağıdaki örnekte, ayırıcıyla ayrılmış 2 paragraftan oluşan basit bir kart oluşturulmuştur.

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;
}

Return

Divider — Bölen.


newDriveItemsSelectedActionResponseBuilder()


newEditorFileScopeActionResponseBuilder()


newFixedFooter()

Yeni bir FixedFooter oluşturur.

Return

FixedFooter — Boş bir FixedFooter.


newGrid()

Yeni bir Grid oluşturur.

Return

Grid — Boş bir Izgara.


newGridItem()

Yeni bir GridItem oluşturur.

Return

GridItem: Boş bir GridItem.


newIconImage()

Yeni bir IconImage oluşturur.

Return

IconImage — Boş simge resmi.


newImage()

Yeni bir Image oluşturur.

Return

Image — Boş bir Resim.


newImageButton()

Yeni bir ImageButton oluşturur.

Return

ImageButton — Boş bir ImageButton.


newImageComponent()

Yeni bir ImageComponent oluşturur.

Return

ImageComponent — Boş bir ImageComponent.


newImageCropStyle()

Yeni bir ImageCropStyle oluşturur.

Return

ImageCropStyle — Boş bir ImageKırpma Stili.


newKeyValue()

Yeni bir KeyValue oluşturur.

Return

KeyValue — Boş bir Anahtar/Değer Çifti.


newLinkPreview()

Yeni bir LinkPreview oluşturur.

const decoratedText = CardService.newDecoratedText()
    .setTopLabel('Hello')
    .setText('Hi!');

const cardSection = CardService.newCardSection()
    .addWidget(decoratedText);

const card = CardService.newCardBuilder()
    .addSection(cardSection)
    .build();

const linkPreview = CardService.newLinkPreview()
    .setPreviewCard(card)
    .setTitle('Smart chip title');

Return

LinkPreview — Boş bir LinkPreview.


newNavigation()

Yeni bir Navigation oluşturur.

Return

Navigation — Boş bir Gezinme menüsü.


newNotification()

Yeni bir Notification oluşturur.

Return

Notification — Boş bir Bildirim.


Yeni bir OpenLink oluşturur.

Return

OpenLink — Boş bir OpenLink.


newSelectionInput()

Yeni bir SelectionInput oluşturur.

Return

SelectionInput — Boş bir Seçim Girişi.


newSuggestions()

Yeni bir Suggestions oluşturur.

Return

Suggestions — Boş Öneriler.


newSuggestionsResponseBuilder()

Yeni bir SuggestionsResponseBuilder oluşturur.

Return

SuggestionsResponseBuilder: Boş bir SuggestionsResponse oluşturucusu.


newSwitch()

Yeni bir Switch oluşturur.

Return

Switch — Boş bir Switch.


newTextButton()

Yeni bir TextButton oluşturur.

Return

TextButton — Boş bir TextButton.


newTextInput()

Yeni bir TextInput oluşturur.

Return

TextInput — Boş bir Metin Girişi.


newTextParagraph()

Yeni bir TextParagraph oluşturur.

Return

TextParagraph — Boş bir TextParagraf.


newTimePicker()

Yeni bir TimePicker oluşturur.

Return

TimePicker — Boş bir TimeSelecter.


newUniversalActionResponseBuilder()

Yeni bir UniversalActionResponseBuilder oluşturur.

Return

UniversalActionResponseBuilder — Boş bir UniversalActionResponse oluşturucu.


newUpdateDraftActionResponseBuilder()

Yeni bir UpdateDraftActionResponseBuilder oluşturur.

Return

UpdateDraftActionResponseBuilder — Boş bir UpdateDraftActionResponseBuilder öğesi.


newUpdateDraftBccRecipientsAction()

Yeni bir UpdateDraftBccRecipientsAction oluşturur;

Return

UpdateDraftBccRecipientsAction — Boş bir UpdateDraftBccAlıcılarİşlemi.


newUpdateDraftBodyAction()

Yeni bir UpdateDraftBodyAction oluşturur.

Return

UpdateDraftBodyAction — Boş bir UpdateDraftBodyAction.


newUpdateDraftCcRecipientsAction()

Yeni bir UpdateDraftCcRecipientsAction oluşturur.

Return

UpdateDraftCcRecipientsAction — Boş bir UpdateDraftCcRecipientsİşlemi.


newUpdateDraftSubjectAction()

Yeni bir UpdateDraftSubjectAction oluşturur.

Return

UpdateDraftSubjectAction — Boş bir UpdateDraftSubjectAction.


newUpdateDraftToRecipientsAction()

Yeni bir UpdateDraftToRecipientsAction oluşturur.

Return

UpdateDraftToRecipientsAction — Boş bir UpdateDraftToRecipientsAction değeri.