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

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

The newest version!
// 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;
import java.util.List;

/**
 * A request to send an image notification.
 */
@Fluent
public final class ImageNotificationContent extends NotificationContent {

    /*
     * The type discriminator describing a notification type.
     */
    @Generated
    private CommunicationMessageKind kind = CommunicationMessageKind.IMAGE;

    /*
     * A media url for the file. Required if the type is one of the supported media types, e.g. image
     */
    @Generated
    private final String mediaUrl;

    /**
     * Creates an instance of ImageNotificationContent class.
     *
     * @param channelRegistrationId the channelRegistrationId value to set.
     * @param to the to value to set.
     * @param mediaUrl the mediaUrl value to set.
     */
    @Generated
    public ImageNotificationContent(String channelRegistrationId, List to, String mediaUrl) {
        super(channelRegistrationId, to);
        this.mediaUrl = mediaUrl;
    }

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

    /**
     * Get the mediaUrl property: A media url for the file. Required if the type is one of the supported media types,
     * e.g. image.
     *
     * @return the mediaUrl value.
     */
    @Generated
    public String getMediaUrl() {
        return this.mediaUrl;
    }

    /**
     * {@inheritDoc}
     */
    @Generated
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("channelRegistrationId", getChannelRegistrationId());
        jsonWriter.writeArrayField("to", getTo(), (writer, element) -> writer.writeString(element));
        jsonWriter.writeStringField("mediaUri", this.mediaUrl);
        jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString());
        jsonWriter.writeStringField("caption", this.caption);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of ImageNotificationContent from the JsonReader.
     *
     * @param jsonReader The JsonReader being read.
     * @return An instance of ImageNotificationContent 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 ImageNotificationContent.
     */
    @Generated
    public static ImageNotificationContent fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            String channelRegistrationId = null;
            List to = null;
            String mediaUrl = null;
            CommunicationMessageKind kind = CommunicationMessageKind.IMAGE;
            String caption = null;
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();
                if ("channelRegistrationId".equals(fieldName)) {
                    channelRegistrationId = reader.getString();
                } else if ("to".equals(fieldName)) {
                    to = reader.readArray(reader1 -> reader1.getString());
                } else if ("mediaUri".equals(fieldName)) {
                    mediaUrl = reader.getString();
                } else if ("kind".equals(fieldName)) {
                    kind = CommunicationMessageKind.fromString(reader.getString());
                } else if ("caption".equals(fieldName)) {
                    caption = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }
            ImageNotificationContent deserializedImageNotificationContent
                = new ImageNotificationContent(channelRegistrationId, to, mediaUrl);
            deserializedImageNotificationContent.kind = kind;
            deserializedImageNotificationContent.caption = caption;
            return deserializedImageNotificationContent;
        });
    }

    /*
     * Optional text content.
     */
    @Generated
    private String caption;

    /**
     * Get the caption property: Optional text content.
     *
     * @return the caption value.
     */
    @Generated
    public String getCaption() {
        return this.caption;
    }

    /**
     * Set the caption property: Optional text content.
     *
     * @param caption the caption value to set.
     * @return the ImageNotificationContent object itself.
     */
    @Generated
    public ImageNotificationContent setCaption(String caption) {
        this.caption = caption;
        return this;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy