All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.communication.messages.models.MessageTemplateQuickAction Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.
package com.azure.communication.messages.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.annotation.Generated;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
 * The message template's quick action value information.
 */
@Fluent
public final class MessageTemplateQuickAction extends MessageTemplateValue {

    /*
     * The type discriminator describing a template parameter type.
     */
    @Generated
    private MessageTemplateValueKind kind = MessageTemplateValueKind.QUICK_ACTION;

    /*
     * The [Optional] quick action text
     */
    @Generated
    private String text;

    /*
     * The [Optional] quick action payload
     */
    @Generated
    private String payload;

    /**
     * Creates an instance of MessageTemplateQuickAction class.
     *
     * @param refValue the refValue value to set.
     */
    @Generated
    public MessageTemplateQuickAction(String refValue) {
        super(refValue);
    }

    /**
     * Get the kind property: The type discriminator describing a template parameter type.
     *
     * @return the kind value.
     */
    @Generated
    @Override
    public MessageTemplateValueKind getKind() {
        return this.kind;
    }

    /**
     * Get the text property: The [Optional] quick action text.
     *
     * @return the text value.
     */
    @Generated
    public String getText() {
        return this.text;
    }

    /**
     * Set the text property: The [Optional] quick action text.
     *
     * @param text the text value to set.
     * @return the MessageTemplateQuickAction object itself.
     */
    @Generated
    public MessageTemplateQuickAction setText(String text) {
        this.text = text;
        return this;
    }

    /**
     * Get the payload property: The [Optional] quick action payload.
     *
     * @return the payload value.
     */
    @Generated
    public String getPayload() {
        return this.payload;
    }

    /**
     * Set the payload property: The [Optional] quick action payload.
     *
     * @param payload the payload value to set.
     * @return the MessageTemplateQuickAction object itself.
     */
    @Generated
    public MessageTemplateQuickAction setPayload(String payload) {
        this.payload = payload;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Generated
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("name", getRefValue());
        jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
        jsonWriter.writeStringField("text", this.text);
        jsonWriter.writeStringField("payload", this.payload);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of MessageTemplateQuickAction from the JsonReader.
     *
     * @param jsonReader The JsonReader being read.
     * @return An instance of MessageTemplateQuickAction if the JsonReader was pointing to an instance of it, or null if
     * it was pointing to JSON null.
     * @throws IllegalStateException If the deserialized JSON object was missing any required properties.
     * @throws IOException If an error occurs while reading the MessageTemplateQuickAction.
     */
    @Generated
    public static MessageTemplateQuickAction fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            String refValue = null;
            MessageTemplateValueKind kind = MessageTemplateValueKind.QUICK_ACTION;
            String text = null;
            String payload = null;
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();
                if ("name".equals(fieldName)) {
                    refValue = reader.getString();
                } else if ("kind".equals(fieldName)) {
                    kind = MessageTemplateValueKind.fromString(reader.getString());
                } else if ("text".equals(fieldName)) {
                    text = reader.getString();
                } else if ("payload".equals(fieldName)) {
                    payload = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }
            MessageTemplateQuickAction deserializedMessageTemplateQuickAction
                = new MessageTemplateQuickAction(refValue);
            deserializedMessageTemplateQuickAction.kind = kind;
            deserializedMessageTemplateQuickAction.text = text;
            deserializedMessageTemplateQuickAction.payload = payload;
            return deserializedMessageTemplateQuickAction;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy