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

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.edgeorder.models.AddressDetails;
import com.azure.resourcemanager.edgeorder.models.OrderItemDetails;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

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

    /*
     * Represents order item details.
     */
    @JsonProperty(value = "orderItemDetails", required = true)
    private OrderItemDetails orderItemDetails;

    /*
     * Represents shipping and return address for order item
     */
    @JsonProperty(value = "addressDetails", required = true)
    private AddressDetails addressDetails;

    /*
     * Start time of order item
     */
    @JsonProperty(value = "startTime", access = JsonProperty.Access.WRITE_ONLY)
    private OffsetDateTime startTime;

    /*
     * Id of the order to which order item belongs to
     */
    @JsonProperty(value = "orderId", required = true)
    private String orderId;

    /**
     * Get the orderItemDetails property: Represents order item details.
     *
     * @return the orderItemDetails value.
     */
    public OrderItemDetails orderItemDetails() {
        return this.orderItemDetails;
    }

    /**
     * Set the orderItemDetails property: Represents order item details.
     *
     * @param orderItemDetails the orderItemDetails value to set.
     * @return the OrderItemProperties object itself.
     */
    public OrderItemProperties withOrderItemDetails(OrderItemDetails orderItemDetails) {
        this.orderItemDetails = orderItemDetails;
        return this;
    }

    /**
     * Get the addressDetails property: Represents shipping and return address for order item.
     *
     * @return the addressDetails value.
     */
    public AddressDetails addressDetails() {
        return this.addressDetails;
    }

    /**
     * Set the addressDetails property: Represents shipping and return address for order item.
     *
     * @param addressDetails the addressDetails value to set.
     * @return the OrderItemProperties object itself.
     */
    public OrderItemProperties withAddressDetails(AddressDetails addressDetails) {
        this.addressDetails = addressDetails;
        return this;
    }

    /**
     * Get the startTime property: Start time of order item.
     *
     * @return the startTime value.
     */
    public OffsetDateTime startTime() {
        return this.startTime;
    }

    /**
     * Get the orderId property: Id of the order to which order item belongs to.
     *
     * @return the orderId value.
     */
    public String orderId() {
        return this.orderId;
    }

    /**
     * Set the orderId property: Id of the order to which order item belongs to.
     *
     * @param orderId the orderId value to set.
     * @return the OrderItemProperties object itself.
     */
    public OrderItemProperties withOrderId(String orderId) {
        this.orderId = orderId;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (orderItemDetails() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property orderItemDetails in model OrderItemProperties"));
        } else {
            orderItemDetails().validate();
        }
        if (addressDetails() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException(
                        "Missing required property addressDetails in model OrderItemProperties"));
        } else {
            addressDetails().validate();
        }
        if (orderId() == null) {
            throw logger
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property orderId in model OrderItemProperties"));
        }
    }
}
