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

io.sphere.sdk.orders.OrderImportDraftBuilder Maven / Gradle / Ivy

The newest version!
package io.sphere.sdk.orders;

import com.neovisionaries.i18n.CountryCode;
import io.sphere.sdk.carts.TaxedPrice;
import io.sphere.sdk.customergroups.CustomerGroup;
import io.sphere.sdk.models.*;

import javax.money.MonetaryAmount;
import java.time.Instant;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

public class OrderImportDraftBuilder extends Base implements Builder {
    private Optional orderNumber = Optional.empty();
    private Optional customerId = Optional.empty();
    private Optional customerEmail = Optional.empty();
    private List lineItems = Collections.emptyList();
    private List customLineItems = Collections.emptyList();
    private MonetaryAmount totalPrice;
    private Optional taxedPrice = Optional.empty();
    private Optional
shippingAddress = Optional.empty(); private Optional
billingAddress = Optional.empty(); private Optional> customerGroup = Optional.empty(); private Optional country = Optional.empty(); private OrderState orderState; private Optional shipmentState = Optional.empty(); private Optional paymentState = Optional.empty(); private Optional shippingInfo = Optional.empty(); private Optional completedAt = Optional.empty(); private OrderImportDraftBuilder(final MonetaryAmount totalPrice, final OrderState orderState) { this.totalPrice = totalPrice; this.orderState = orderState; } /** * String that unique identifies an order. It can be used to create more human-readable (in contrast to ID) identifier for the order. It should be unique within a project. * @param orderNumber ID to set * @return this builder */ public OrderImportDraftBuilder orderNumber(final Optional orderNumber) { this.orderNumber = orderNumber; return this; } /** * String that unique identifies an order. It can be used to create more human-readable (in contrast to ID) identifier for the order. It should be unique within a project. * @param orderNumber ID to set * @return this builder */ public OrderImportDraftBuilder orderNumber(final String orderNumber) { return orderNumber(Optional.of(orderNumber)); } public OrderImportDraftBuilder customerId(final Optional customerId) { this.customerId = customerId; return this; } public OrderImportDraftBuilder customerId(final String customerId) { return customerId(Optional.of(customerId)); } public OrderImportDraftBuilder customerEmail(final Optional customerEmail) { this.customerEmail = customerEmail; return this; } public OrderImportDraftBuilder customerEmail(final String customerEmail) { return customerEmail(Optional.of(customerEmail)); } public OrderImportDraftBuilder lineItems(final List lineItems) { this.lineItems = lineItems; return this; } public OrderImportDraftBuilder customLineItems(final List customLineItems) { this.customLineItems = customLineItems; return this; } public OrderImportDraftBuilder totalPrice(final MonetaryAmount totalPrice) { this.totalPrice = totalPrice; return this; } public OrderImportDraftBuilder taxedPrice(final TaxedPrice taxedPrice) { return taxedPrice(Optional.of(taxedPrice)); } public OrderImportDraftBuilder taxedPrice(final Optional taxedPrice) { this.taxedPrice = taxedPrice; return this; } public OrderImportDraftBuilder shippingAddress(final Address shippingAddress) { return shippingAddress(Optional.of(shippingAddress)); } public OrderImportDraftBuilder shippingAddress(final Optional
shippingAddress) { this.shippingAddress = shippingAddress; return this; } public OrderImportDraftBuilder billingAddress(final Optional
billingAddress) { this.billingAddress = billingAddress; return this; } public OrderImportDraftBuilder billingAddress(final Address billingAddress) { return billingAddress(Optional.of(billingAddress)); } public OrderImportDraftBuilder customerGroup(final Optional> customerGroup) { this.customerGroup = customerGroup; return this; } public OrderImportDraftBuilder customerGroup(final Referenceable customerGroup) { return customerGroup(Optional.of(customerGroup.toReference())); } public OrderImportDraftBuilder country(final Optional country) { this.country = country; return this; } public OrderImportDraftBuilder country(final CountryCode country) { return country(Optional.of(country)); } public OrderImportDraftBuilder orderState(final OrderState orderState) { this.orderState = orderState; return this; } public OrderImportDraftBuilder shipmentState(final Optional shipmentState) { this.shipmentState = shipmentState; return this; } public OrderImportDraftBuilder shipmentState(final ShipmentState shipmentState) { return shipmentState(Optional.of(shipmentState)); } public OrderImportDraftBuilder paymentState(final Optional paymentState) { this.paymentState = paymentState; return this; } public OrderImportDraftBuilder paymentState(final PaymentState paymentState) { return paymentState(Optional.of(paymentState)); } public OrderImportDraftBuilder shippingInfo(final Optional shippingInfo) { this.shippingInfo = shippingInfo; return this; } public OrderImportDraftBuilder shippingInfo(final OrderShippingInfo shippingInfo) { return shippingInfo(Optional.of(shippingInfo)); } public OrderImportDraftBuilder completedAt(final Optional completedAt) { this.completedAt = completedAt; return this; } public OrderImportDraftBuilder completedAt(final Instant completedAt) { return completedAt(Optional.of(completedAt)); } /** * Creates a builder for {@link OrderImportDraft} with at least one line item. * You can add {@link io.sphere.sdk.carts.CustomLineItem}s with {@link #customLineItems(java.util.List)}. * * @param totalPrice the total price of the order * @param orderState the state of the order * @param lineItems a list of line items with at least one element * @return a new builder */ public static OrderImportDraftBuilder ofLineItems(final MonetaryAmount totalPrice, final OrderState orderState, final List lineItems) { return new OrderImportDraftBuilder(totalPrice, orderState).lineItems(lineItems); } /** * Creates a builder for {@link OrderImportDraft} with at least one custom line item. * You can add {@link io.sphere.sdk.carts.LineItem}s with {@link #lineItems(java.util.List)}. * * @param totalPrice the total price of the order * @param orderState the state of the order * @param customLineItems a list of custom line items with at least one element * @return a new builder */ public static OrderImportDraftBuilder ofCustomLineItems(final MonetaryAmount totalPrice, final OrderState orderState, final List customLineItems) { return new OrderImportDraftBuilder(totalPrice, orderState).customLineItems(customLineItems); } @Override public OrderImportDraft build() { return new OrderImportDraftImpl(billingAddress, orderNumber, customerId, customerEmail, lineItems, customLineItems, totalPrice, taxedPrice, shippingAddress, customerGroup, country, orderState, shipmentState, paymentState, shippingInfo, completedAt); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy