// 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.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** A billing instruction used during invoice generation. */
@Fluent
public final class InstructionProperties {
    /*
     * The amount budgeted for this billing instruction.
     */
    @JsonProperty(value = "amount", required = true)
    private float amount;

    /*
     * The date this billing instruction goes into effect.
     */
    @JsonProperty(value = "startDate", required = true)
    private OffsetDateTime startDate;

    /*
     * The date this billing instruction is no longer in effect.
     */
    @JsonProperty(value = "endDate", required = true)
    private OffsetDateTime endDate;

    /*
     * The date this billing instruction was created.
     */
    @JsonProperty(value = "creationDate")
    private OffsetDateTime creationDate;

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

    /**
     * Get the amount property: The amount budgeted for this billing instruction.
     *
     * @return the amount value.
     */
    public float amount() {
        return this.amount;
    }

    /**
     * Set the amount property: The amount budgeted for this billing instruction.
     *
     * @param amount the amount value to set.
     * @return the InstructionProperties object itself.
     */
    public InstructionProperties withAmount(float amount) {
        this.amount = amount;
        return this;
    }

    /**
     * Get the startDate property: The date this billing instruction goes into effect.
     *
     * @return the startDate value.
     */
    public OffsetDateTime startDate() {
        return this.startDate;
    }

    /**
     * Set the startDate property: The date this billing instruction goes into effect.
     *
     * @param startDate the startDate value to set.
     * @return the InstructionProperties object itself.
     */
    public InstructionProperties withStartDate(OffsetDateTime startDate) {
        this.startDate = startDate;
        return this;
    }

    /**
     * Get the endDate property: The date this billing instruction is no longer in effect.
     *
     * @return the endDate value.
     */
    public OffsetDateTime endDate() {
        return this.endDate;
    }

    /**
     * Set the endDate property: The date this billing instruction is no longer in effect.
     *
     * @param endDate the endDate value to set.
     * @return the InstructionProperties object itself.
     */
    public InstructionProperties withEndDate(OffsetDateTime endDate) {
        this.endDate = endDate;
        return this;
    }

    /**
     * Get the creationDate property: The date this billing instruction was created.
     *
     * @return the creationDate value.
     */
    public OffsetDateTime creationDate() {
        return this.creationDate;
    }

    /**
     * Set the creationDate property: The date this billing instruction was created.
     *
     * @param creationDate the creationDate value to set.
     * @return the InstructionProperties object itself.
     */
    public InstructionProperties withCreationDate(OffsetDateTime creationDate) {
        this.creationDate = creationDate;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (startDate() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property startDate in model InstructionProperties"));
        }
        if (endDate() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property endDate in model InstructionProperties"));
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(InstructionProperties.class);
}
