lib/google_api/chat/v1/model/google_apps_card_v1_widget.ex

# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.Chat.V1.Model.GoogleAppsCardV1Widget do
  @moduledoc """
  Each card is made up of widgets. A widget is a composite object that can represent one of text, images, buttons, and other object types.

  ## Attributes

  *   `buttonList` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1ButtonList.t`, *default:* `nil`) - A list of buttons. For example, the following JSON creates two buttons. The first is a blue text button and the second is an image button that opens a link: ``` "buttonList": { "buttons": [ { "text": "Edit", "color": { "red": 0, "green": 0, "blue": 1, "alpha": 1 }, "disabled": true, }, { "icon": { "knownIcon": "INVITE", "altText": "check calendar" }, "onClick": { "openLink": { "url": "https://example.com/calendar" } } } ] } ```
  *   `columns` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1Columns.t`, *default:* `nil`) - Displays up to 2 columns. To include more than 2 columns, or to use rows, use the `Grid` widget. For example, the following JSON creates 2 columns that each contain text paragraphs: ``` "columns": { "columnItems": [ { "horizontalSizeStyle": "FILL_AVAILABLE_SPACE", "horizontalAlignment": "CENTER", "verticalAlignment": "CENTER", "widgets": [ { "textParagraph": { "text": "First column text paragraph" } } ] }, { "horizontalSizeStyle": "FILL_AVAILABLE_SPACE", "horizontalAlignment": "CENTER", "verticalAlignment": "CENTER", "widgets": [ { "textParagraph": { "text": "Second column text paragraph" } } ] } ] } ```
  *   `dateTimePicker` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1DateTimePicker.t`, *default:* `nil`) - Displays a widget that lets users input a date, time, or date and time. For example, the following JSON creates a date time picker to schedule an appointment: ``` "dateTimePicker": { "name": "appointment_time", "label": "Book your appointment at:", "type": "DATE_AND_TIME", "valueMsEpoch": "796435200000" } ```
  *   `decoratedText` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1DecoratedText.t`, *default:* `nil`) - Displays a decorated text item. For example, the following JSON creates a decorated text widget showing email address: ``` "decoratedText": { "icon": { "knownIcon": "EMAIL" }, "topLabel": "Email Address", "text": "sasha@example.com", "bottomLabel": "This is a new Email address!", "switchControl": { "name": "has_send_welcome_email_to_sasha", "selected": false, "controlType": "CHECKBOX" } } ```
  *   `divider` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1Divider.t`, *default:* `nil`) - Displays a horizontal line divider between widgets. For example, the following JSON creates a divider: ``` "divider": { } ```
  *   `grid` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1Grid.t`, *default:* `nil`) - Displays a grid with a collection of items. A grid supports any number of columns and items. The number of rows is determined by the upper bounds of the number items divided by the number of columns. A grid with 10 items and 2 columns has 5 rows. A grid with 11 items and 2 columns has 6 rows. [Google Workspace Add-ons and Chat apps](https://developers.google.com/workspace/extend): For example, the following JSON creates a 2 column grid with a single item: ``` "grid": { "title": "A fine collection of items", "columnCount": 2, "borderStyle": { "type": "STROKE", "cornerRadius": 4 }, "items": [ { "image": { "imageUri": "https://www.example.com/image.png", "cropStyle": { "type": "SQUARE" }, "borderStyle": { "type": "STROKE" } }, "title": "An item", "textAlignment": "CENTER" } ], "onClick": { "openLink": { "url": "https://www.example.com" } } } ```
  *   `horizontalAlignment` (*type:* `String.t`, *default:* `nil`) - Specifies whether widgets align to the left, right, or center of a column.
  *   `image` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1Image.t`, *default:* `nil`) - Displays an image. For example, the following JSON creates an image with alternative text: ``` "image": { "imageUrl": "https://developers.google.com/workspace/chat/images/quickstart-app-avatar.png", "altText": "Chat app avatar" } ```
  *   `selectionInput` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1SelectionInput.t`, *default:* `nil`) - Displays a selection control that lets users select items. Selection controls can be checkboxes, radio buttons, switches, or dropdown menus. For example, the following JSON creates a dropdown menu that lets users choose a size: ``` "selectionInput": { "name": "size", "label": "Size" "type": "DROPDOWN", "items": [ { "text": "S", "value": "small", "selected": false }, { "text": "M", "value": "medium", "selected": true }, { "text": "L", "value": "large", "selected": false }, { "text": "XL", "value": "extra_large", "selected": false } ] } ```
  *   `textInput` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1TextInput.t`, *default:* `nil`) - Displays a text box that users can type into. For example, the following JSON creates a text input for an email address: ``` "textInput": { "name": "mailing_address", "label": "Mailing Address" } ``` As another example, the following JSON creates a text input for a programming language with static suggestions: ``` "textInput": { "name": "preferred_programing_language", "label": "Preferred Language", "initialSuggestions": { "items": [ { "text": "C++" }, { "text": "Java" }, { "text": "JavaScript" }, { "text": "Python" } ] } } ```
  *   `textParagraph` (*type:* `GoogleApi.Chat.V1.Model.GoogleAppsCardV1TextParagraph.t`, *default:* `nil`) - Displays a text paragraph. Supports simple HTML formatted text. For more information about formatting text, see [Formatting text in Google Chat apps](https://developers.google.com/workspace/chat/format-messages#card-formatting) and [Formatting text in Google Workspace Add-ons](https://developers.google.com/apps-script/add-ons/concepts/widgets#text_formatting). For example, the following JSON creates a bolded text: ``` "textParagraph": { "text": " *bold text*" } ```
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :buttonList => GoogleApi.Chat.V1.Model.GoogleAppsCardV1ButtonList.t() | nil,
          :columns => GoogleApi.Chat.V1.Model.GoogleAppsCardV1Columns.t() | nil,
          :dateTimePicker => GoogleApi.Chat.V1.Model.GoogleAppsCardV1DateTimePicker.t() | nil,
          :decoratedText => GoogleApi.Chat.V1.Model.GoogleAppsCardV1DecoratedText.t() | nil,
          :divider => GoogleApi.Chat.V1.Model.GoogleAppsCardV1Divider.t() | nil,
          :grid => GoogleApi.Chat.V1.Model.GoogleAppsCardV1Grid.t() | nil,
          :horizontalAlignment => String.t() | nil,
          :image => GoogleApi.Chat.V1.Model.GoogleAppsCardV1Image.t() | nil,
          :selectionInput => GoogleApi.Chat.V1.Model.GoogleAppsCardV1SelectionInput.t() | nil,
          :textInput => GoogleApi.Chat.V1.Model.GoogleAppsCardV1TextInput.t() | nil,
          :textParagraph => GoogleApi.Chat.V1.Model.GoogleAppsCardV1TextParagraph.t() | nil
        }

  field(:buttonList, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1ButtonList)
  field(:columns, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1Columns)
  field(:dateTimePicker, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1DateTimePicker)
  field(:decoratedText, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1DecoratedText)
  field(:divider, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1Divider)
  field(:grid, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1Grid)
  field(:horizontalAlignment)
  field(:image, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1Image)
  field(:selectionInput, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1SelectionInput)
  field(:textInput, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1TextInput)
  field(:textParagraph, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1TextParagraph)
end

defimpl Poison.Decoder, for: GoogleApi.Chat.V1.Model.GoogleAppsCardV1Widget do
  def decode(value, options) do
    GoogleApi.Chat.V1.Model.GoogleAppsCardV1Widget.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.Chat.V1.Model.GoogleAppsCardV1Widget do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end