lib/google_api/chat/v1/model/google_apps_card_v1_action.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.GoogleAppsCardV1Action do
  @moduledoc """
  An action that describes the behavior when the form is submitted. For example, you can invoke an Apps Script script to handle the form. If the action is triggered, the form values are sent to the server. [Google Workspace Add-ons and Chat apps](https://developers.google.com/workspace/extend):

  ## Attributes

  *   `function` (*type:* `String.t`, *default:* `nil`) - A custom function to invoke when the containing element is clicked or othrwise activated. For example usage, see [Read form data](https://developers.google.com/workspace/chat/read-form-data).
  *   `interaction` (*type:* `String.t`, *default:* `nil`) - Optional. Required when opening a [dialog](https://developers.google.com/workspace/chat/dialogs). What to do in response to an interaction with a user, such as a user clicking a button in a card message. If unspecified, the app responds by executing an `action`—like opening a link or running a function—as normal. By specifying an `interaction`, the app can respond in special interactive ways. For example, by setting `interaction` to `OPEN_DIALOG`, the app can open a [dialog](https://developers.google.com/workspace/chat/dialogs). When specified, a loading indicator isn't shown. If specified for an add-on, the entire card is stripped and nothing is shown in the client. [Google Chat apps](https://developers.google.com/workspace/chat):
  *   `loadIndicator` (*type:* `String.t`, *default:* `nil`) - Specifies the loading indicator that the action displays while making the call to the action.
  *   `parameters` (*type:* `list(GoogleApi.Chat.V1.Model.GoogleAppsCardV1ActionParameter.t)`, *default:* `nil`) - List of action parameters.
  *   `persistValues` (*type:* `boolean()`, *default:* `nil`) - Indicates whether form values persist after the action. The default value is `false`. If `true`, form values remain after the action is triggered. To let the user make changes while the action is being processed, set [`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) to `NONE`. For [card messages](https://developers.google.com/workspace/chat/api/guides/v1/messages/create#create) in Chat apps, you must also set the action's [`ResponseType`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages#responsetype) to `UPDATE_MESSAGE` and use the same [`card_id`](https://developers.google.com/workspace/chat/api/reference/rest/v1/spaces.messages#CardWithId) from the card that contained the action. If `false`, the form values are cleared when the action is triggered. To prevent the user from making changes while the action is being processed, set [`LoadIndicator`](https://developers.google.com/workspace/add-ons/reference/rpc/google.apps.card.v1#loadindicator) to `SPINNER`.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :function => String.t() | nil,
          :interaction => String.t() | nil,
          :loadIndicator => String.t() | nil,
          :parameters => list(GoogleApi.Chat.V1.Model.GoogleAppsCardV1ActionParameter.t()) | nil,
          :persistValues => boolean() | nil
        }

  field(:function)
  field(:interaction)
  field(:loadIndicator)
  field(:parameters, as: GoogleApi.Chat.V1.Model.GoogleAppsCardV1ActionParameter, type: :list)
  field(:persistValues)
end

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

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