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

com.azure.resourcemanager.billing.models.RefundTransactionDetails Maven / Gradle / Ivy

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

package com.azure.resourcemanager.billing.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 refund details of a transaction.
 */
@Fluent
public class RefundTransactionDetails implements JsonSerializable {
    /*
     * The amount of refund requested.
     */
    private RefundTransactionDetailsAmountRequested amountRequested;

    /*
     * The amount refunded.
     */
    private RefundTransactionDetailsAmountRefunded amountRefunded;

    /*
     * The ID of refund operation.
     */
    private String refundOperationId;

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

    /**
     * Get the amountRequested property: The amount of refund requested.
     * 
     * @return the amountRequested value.
     */
    public RefundTransactionDetailsAmountRequested amountRequested() {
        return this.amountRequested;
    }

    /**
     * Set the amountRequested property: The amount of refund requested.
     * 
     * @param amountRequested the amountRequested value to set.
     * @return the RefundTransactionDetails object itself.
     */
    public RefundTransactionDetails withAmountRequested(RefundTransactionDetailsAmountRequested amountRequested) {
        this.amountRequested = amountRequested;
        return this;
    }

    /**
     * Get the amountRefunded property: The amount refunded.
     * 
     * @return the amountRefunded value.
     */
    public RefundTransactionDetailsAmountRefunded amountRefunded() {
        return this.amountRefunded;
    }

    /**
     * Set the amountRefunded property: The amount refunded.
     * 
     * @param amountRefunded the amountRefunded value to set.
     * @return the RefundTransactionDetails object itself.
     */
    public RefundTransactionDetails withAmountRefunded(RefundTransactionDetailsAmountRefunded amountRefunded) {
        this.amountRefunded = amountRefunded;
        return this;
    }

    /**
     * Get the refundOperationId property: The ID of refund operation.
     * 
     * @return the refundOperationId value.
     */
    public String refundOperationId() {
        return this.refundOperationId;
    }

    /**
     * Set the refundOperationId property: The ID of refund operation.
     * 
     * @param refundOperationId the refundOperationId value to set.
     * @return the RefundTransactionDetails object itself.
     */
    public RefundTransactionDetails withRefundOperationId(String refundOperationId) {
        this.refundOperationId = refundOperationId;
        return this;
    }

    /**
     * Validates the instance.
     * 
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (amountRequested() != null) {
            amountRequested().validate();
        }
        if (amountRefunded() != null) {
            amountRefunded().validate();
        }
    }

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

    /**
     * Reads an instance of RefundTransactionDetails from the JsonReader.
     * 
     * @param jsonReader The JsonReader being read.
     * @return An instance of RefundTransactionDetails if the JsonReader was pointing to an instance of it, or null if
     * it was pointing to JSON null.
     * @throws IOException If an error occurs while reading the RefundTransactionDetails.
     */
    public static RefundTransactionDetails fromJson(JsonReader jsonReader) throws IOException {
        return jsonReader.readObject(reader -> {
            RefundTransactionDetails deserializedRefundTransactionDetails = new RefundTransactionDetails();
            while (reader.nextToken() != JsonToken.END_OBJECT) {
                String fieldName = reader.getFieldName();
                reader.nextToken();

                if ("amountRequested".equals(fieldName)) {
                    deserializedRefundTransactionDetails.amountRequested
                        = RefundTransactionDetailsAmountRequested.fromJson(reader);
                } else if ("amountRefunded".equals(fieldName)) {
                    deserializedRefundTransactionDetails.amountRefunded
                        = RefundTransactionDetailsAmountRefunded.fromJson(reader);
                } else if ("refundOperationId".equals(fieldName)) {
                    deserializedRefundTransactionDetails.refundOperationId = reader.getString();
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedRefundTransactionDetails;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy