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

com.azure.communication.callautomation.implementation.models.CommunicationErrorResponse Maven / Gradle / Ivy

Go to download

This package contains clients and data structures used to make call with Azure Communication Call Automation Service. For this release, see notes - https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/communication/azure-communication-callautomation/README.md and https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/communication/azure-communication-callautomation/CHANGELOG.md.

The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.communication.callautomation.implementation.models;

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

/**
 * The Communication Services error.
 */
@Fluent
public final class CommunicationErrorResponse implements JsonSerializable {
    /*
     * The Communication Services error.
     */
    private CommunicationError error;

    /**
     * Creates an instance of CommunicationErrorResponse class.
     */
    public CommunicationErrorResponse() {
    }

    /**
     * Get the error property: The Communication Services error.
     * 
     * @return the error value.
     */
    public CommunicationError getError() {
        return this.error;
    }

    /**
     * Set the error property: The Communication Services error.
     * 
     * @param error the error value to set.
     * @return the CommunicationErrorResponse object itself.
     */
    public CommunicationErrorResponse setError(CommunicationError error) {
        this.error = error;
        return this;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeJsonField("error", this.error);
        return jsonWriter.writeEndObject();
    }

    /**
     * Reads an instance of CommunicationErrorResponse from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of CommunicationErrorResponse 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 CommunicationErrorResponse.
     */
    public static CommunicationErrorResponse fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            CommunicationErrorResponse deserializedCommunicationErrorResponse = new CommunicationErrorResponse();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("error".equals(fieldName)) {
                    deserializedCommunicationErrorResponse.error = CommunicationError.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedCommunicationErrorResponse;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy