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

package com.azure.resourcemanager.edgeorder.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.exception.ManagementError;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Order item details. */
@Fluent
public final class OrderItemDetails {
    @JsonIgnore private final ClientLogger logger = new ClientLogger(OrderItemDetails.class);

    /*
     * Unique identifier for configuration.
     */
    @JsonProperty(value = "productDetails", required = true)
    private ProductDetails productDetails;

    /*
     * Order item type.
     */
    @JsonProperty(value = "orderItemType", required = true)
    private OrderItemType orderItemType;

    /*
     * Current Order item Status
     */
    @JsonProperty(value = "currentStage", access = JsonProperty.Access.WRITE_ONLY)
    private StageDetails currentStage;

    /*
     * Order item status history
     */
    @JsonProperty(value = "orderItemStageHistory", access = JsonProperty.Access.WRITE_ONLY)
    private List<StageDetails> orderItemStageHistory;

    /*
     * Customer notification Preferences
     */
    @JsonProperty(value = "preferences")
    private Preferences preferences;

    /*
     * Forward Package Shipping details
     */
    @JsonProperty(value = "forwardShippingDetails", access = JsonProperty.Access.WRITE_ONLY)
    private ForwardShippingDetails forwardShippingDetails;

    /*
     * Reverse Package Shipping details
     */
    @JsonProperty(value = "reverseShippingDetails", access = JsonProperty.Access.WRITE_ONLY)
    private ReverseShippingDetails reverseShippingDetails;

    /*
     * Additional notification email list
     */
    @JsonProperty(value = "notificationEmailList")
    private List<String> notificationEmailList;

    /*
     * Cancellation reason.
     */
    @JsonProperty(value = "cancellationReason", access = JsonProperty.Access.WRITE_ONLY)
    private String cancellationReason;

    /*
     * Describes whether the order item is cancellable or not.
     */
    @JsonProperty(value = "cancellationStatus", access = JsonProperty.Access.WRITE_ONLY)
    private OrderItemCancellationEnum cancellationStatus;

    /*
     * Describes whether the order item is deletable or not.
     */
    @JsonProperty(value = "deletionStatus", access = JsonProperty.Access.WRITE_ONLY)
    private ActionStatusEnum deletionStatus;

    /*
     * Return reason.
     */
    @JsonProperty(value = "returnReason", access = JsonProperty.Access.WRITE_ONLY)
    private String returnReason;

    /*
     * Describes whether the order item is returnable or not.
     */
    @JsonProperty(value = "returnStatus", access = JsonProperty.Access.WRITE_ONLY)
    private OrderItemReturnEnum returnStatus;

    /*
     * Parent RP details - this returns only the first or default parent RP
     * from the entire list
     */
    @JsonProperty(value = "managementRpDetails", access = JsonProperty.Access.WRITE_ONLY)
    private ResourceProviderDetails managementRpDetails;

    /*
     * List of parent RP details supported for configuration.
     */
    @JsonProperty(value = "managementRpDetailsList", access = JsonProperty.Access.WRITE_ONLY)
    private List<ResourceProviderDetails> managementRpDetailsList;

    /*
     * Top level error for the job.
     */
    @JsonProperty(value = "error", access = JsonProperty.Access.WRITE_ONLY)
    private ManagementError error;

    /**
     * Get the productDetails property: Unique identifier for configuration.
     *
     * @return the productDetails value.
     */
    public ProductDetails productDetails() {
        return this.productDetails;
    }

    /**
     * Set the productDetails property: Unique identifier for configuration.
     *
     * @param productDetails the productDetails value to set.
     * @return the OrderItemDetails object itself.
     */
    public OrderItemDetails withProductDetails(ProductDetails productDetails) {
        this.productDetails = productDetails;
        return this;
    }

    /**
     * Get the orderItemType property: Order item type.
     *
     * @return the orderItemType value.
     */
    public OrderItemType orderItemType() {
        return this.orderItemType;
    }

    /**
     * Set the orderItemType property: Order item type.
     *
     * @param orderItemType the orderItemType value to set.
     * @return the OrderItemDetails object itself.
     */
    public OrderItemDetails withOrderItemType(OrderItemType orderItemType) {
        this.orderItemType = orderItemType;
        return this;
    }

    /**
     * Get the currentStage property: Current Order item Status.
     *
     * @return the currentStage value.
     */
    public StageDetails currentStage() {
        return this.currentStage;
    }

    /**
     * Get the orderItemStageHistory property: Order item status history.
     *
     * @return the orderItemStageHistory value.
     */
    public List<StageDetails> orderItemStageHistory() {
        return this.orderItemStageHistory;
    }

    /**
     * Get the preferences property: Customer notification Preferences.
     *
     * @return the preferences value.
     */
    public Preferences preferences() {
        return this.preferences;
    }

    /**
     * Set the preferences property: Customer notification Preferences.
     *
     * @param preferences the preferences value to set.
     * @return the OrderItemDetails object itself.
     */
    public OrderItemDetails withPreferences(Preferences preferences) {
        this.preferences = preferences;
        return this;
    }

    /**
     * Get the forwardShippingDetails property: Forward Package Shipping details.
     *
     * @return the forwardShippingDetails value.
     */
    public ForwardShippingDetails forwardShippingDetails() {
        return this.forwardShippingDetails;
    }

    /**
     * Get the reverseShippingDetails property: Reverse Package Shipping details.
     *
     * @return the reverseShippingDetails value.
     */
    public ReverseShippingDetails reverseShippingDetails() {
        return this.reverseShippingDetails;
    }

    /**
     * Get the notificationEmailList property: Additional notification email list.
     *
     * @return the notificationEmailList value.
     */
    public List<String> notificationEmailList() {
        return this.notificationEmailList;
    }

    /**
     * Set the notificationEmailList property: Additional notification email list.
     *
     * @param notificationEmailList the notificationEmailList value to set.
     * @return the OrderItemDetails object itself.
     */
    public OrderItemDetails withNotificationEmailList(List<String> notificationEmailList) {
        this.notificationEmailList = notificationEmailList;
        return this;
    }

    /**
     * Get the cancellationReason property: Cancellation reason.
     *
     * @return the cancellationReason value.
     */
    public String cancellationReason() {
        return this.cancellationReason;
    }

    /**
     * Get the cancellationStatus property: Describes whether the order item is cancellable or not.
     *
     * @return the cancellationStatus value.
     */
    public OrderItemCancellationEnum cancellationStatus() {
        return this.cancellationStatus;
    }

    /**
     * Get the deletionStatus property: Describes whether the order item is deletable or not.
     *
     * @return the deletionStatus value.
     */
    public ActionStatusEnum deletionStatus() {
        return this.deletionStatus;
    }

    /**
     * Get the returnReason property: Return reason.
     *
     * @return the returnReason value.
     */
    public String returnReason() {
        return this.returnReason;
    }

    /**
     * Get the returnStatus property: Describes whether the order item is returnable or not.
     *
     * @return the returnStatus value.
     */
    public OrderItemReturnEnum returnStatus() {
        return this.returnStatus;
    }

    /**
     * Get the managementRpDetails property: Parent RP details - this returns only the first or default parent RP from
     * the entire list.
     *
     * @return the managementRpDetails value.
     */
    public ResourceProviderDetails managementRpDetails() {
        return this.managementRpDetails;
    }

    /**
     * Get the managementRpDetailsList property: List of parent RP details supported for configuration.
     *
     * @return the managementRpDetailsList value.
     */
    public List<ResourceProviderDetails> managementRpDetailsList() {
        return this.managementRpDetailsList;
    }

    /**
     * Get the error property: Top level error for the job.
     *
     * @return the error value.
     */
    public ManagementError error() {
        return this.error;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (productDetails() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property productDetails in model OrderItemDetails"));
        } else {
            productDetails().validate();
        }
        if (orderItemType() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property orderItemType in model OrderItemDetails"));
        }
        if (currentStage() != null) {
            currentStage().validate();
        }
        if (orderItemStageHistory() != null) {
            orderItemStageHistory().forEach(e -> e.validate());
        }
        if (preferences() != null) {
            preferences().validate();
        }
        if (forwardShippingDetails() != null) {
            forwardShippingDetails().validate();
        }
        if (reverseShippingDetails() != null) {
            reverseShippingDetails().validate();
        }
        if (managementRpDetails() != null) {
            managementRpDetails().validate();
        }
        if (managementRpDetailsList() != null) {
            managementRpDetailsList().forEach(e -> e.validate());
        }
    }
}
