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

com.azure.communication.messages.models.SendMessageResult 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.Generated;
import com.azure.core.annotation.Immutable;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;

/**
 * Result of the send message operation.
 */
@Immutable
public final class SendMessageResult implements JsonSerializable {

    /*
     * Receipts of the send message operation.
     */
    @Generated
    private final List receipts;

    /**
     * Creates an instance of SendMessageResult class.
     *
     * @param receipts the receipts value to set.
     */
    @Generated
    private SendMessageResult(List receipts) {
        this.receipts = receipts;
    }

    /**
     * Get the receipts property: Receipts of the send message operation.
     *
     * @return the receipts value.
     */
    @Generated
    public List getReceipts() {
        return this.receipts;
    }

    /**
     * {@inheritDoc}
     */
    @Generated
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeArrayField("receipts", this.receipts, (writer, element) -> writer.writeJson(element));
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of SendMessageResult from the JsonReader.
     *
     * @param jsonReader The JsonReader being read.
     * @return An instance of SendMessageResult 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 SendMessageResult.
     */
    @Generated
    public static SendMessageResult fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            List receipts = null;
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();
                if ("receipts".equals(fieldName)) {
                    receipts = reader.readArray(reader1 -> MessageReceipt.fromJson(reader1));
                } else {
                    reader.skipChildren();
                }
            }
            return new SendMessageResult(receipts);
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy