
com.vendasta.salesorders.v1.internal.Order Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of salesorders.v1 Show documentation
Show all versions of salesorders.v1 Show documentation
Java SDK for service sales-orders
The newest version!
package com.vendasta.salesorders.v1.internal;
import java.util.List;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import com.vendasta.salesorders.v1.generated.SalesOrdersProto;
/**
* Data representing an order form submitted by a salesperson
**/
public final class Order {
private final String orderId;
private final String salespersonId;
private final String partnerId;
private final String businessId;
private final String marketId;
private final List opportunityIds;
private final Status status;
private final Date requestedActivation;
private final String notes;
private final List packages;
private final List customFields;
private final List commonFields;
private final Date created;
private final List productActivations;
private final List addonActivations;
private final List statusHistory;
private final String declinedReason;
private Order (
final String orderId,
final String salespersonId,
final String partnerId,
final String businessId,
final String marketId,
final List opportunityIds,
final Status status,
final Date requestedActivation,
final String notes,
final List packages,
final List customFields,
final List commonFields,
final Date created,
final List productActivations,
final List addonActivations,
final List statusHistory,
final String declinedReason)
{
this.orderId = orderId;
this.salespersonId = salespersonId;
this.partnerId = partnerId;
this.businessId = businessId;
this.marketId = marketId;
this.opportunityIds = opportunityIds;
this.status = status;
this.requestedActivation = requestedActivation;
this.notes = notes;
this.packages = packages;
this.customFields = customFields;
this.commonFields = commonFields;
this.created = created;
this.productActivations = productActivations;
this.addonActivations = addonActivations;
this.statusHistory = statusHistory;
this.declinedReason = declinedReason;
}
/**
* The unique identifier of the order
* @return The final value of orderId on the object
**/
public String getOrderId() {
return this.orderId;
}
/**
* Salesperson who submitted the order
* @return The final value of salespersonId on the object
**/
public String getSalespersonId() {
return this.salespersonId;
}
/**
* The partner the order is being made under
* @return The final value of partnerId on the object
**/
public String getPartnerId() {
return this.partnerId;
}
/**
* The business the order is being made for
* @return The final value of businessId on the object
**/
public String getBusinessId() {
return this.businessId;
}
/**
* The market the order is being made under
* @return The final value of marketId on the object
**/
public String getMarketId() {
return this.marketId;
}
/**
* The opportunities that are being used for the order
* @return The final value of opportunityIds on the object
**/
public List getOpportunityIds() {
return this.opportunityIds;
}
/**
* The current status of the order
* @return The final value of status on the object
**/
public Status getStatus() {
return this.status;
}
/**
* The requested activation date for the order's products
* @return The final value of requestedActivation on the object
**/
public Date getRequestedActivation() {
return this.requestedActivation;
}
/**
* Notes for the partner administrator from the salesperson
* @return The final value of notes on the object
**/
public String getNotes() {
return this.notes;
}
/**
* Packages in the order
* @return The final value of packages on the object
**/
public List getPackages() {
return this.packages;
}
/**
* Custom field answers for the packages
* @return The final value of customFields on the object
**/
public List getCustomFields() {
return this.customFields;
}
/**
* Common field answers for the packages
* @return The final value of commonFields on the object
**/
public List getCommonFields() {
return this.commonFields;
}
/**
* Time the order was submitted by a salesperson
* @return The final value of created on the object
**/
public Date getCreated() {
return this.created;
}
/**
* The list of products with their corresponding activation status
* @return The final value of productActivations on the object
**/
public List getProductActivations() {
return this.productActivations;
}
/**
* The list of addons with their corresponding activation status
* @return The final value of addonActivations on the object
**/
public List getAddonActivations() {
return this.addonActivations;
}
/**
* The historical list of status updates that have taken place on the order
* @return The final value of statusHistory on the object
**/
public List getStatusHistory() {
return this.statusHistory;
}
/**
* The reason the order was declined
* @return The final value of declinedReason on the object
**/
public String getDeclinedReason() {
return this.declinedReason;
}
public static class Builder {
private String orderId;
private String salespersonId;
private String partnerId;
private String businessId;
private String marketId;
private List opportunityIds;
private Status status;
private Date requestedActivation;
private String notes;
private List packages;
private List customFields;
private List commonFields;
private Date created;
private List productActivations;
private List addonActivations;
private List statusHistory;
private String declinedReason;
public Builder() {
this.orderId = "";
this.salespersonId = "";
this.partnerId = "";
this.businessId = "";
this.marketId = "";
this.opportunityIds = new ArrayList();
this.status = null;
this.requestedActivation = null;
this.notes = "";
this.packages = null;
this.customFields = null;
this.commonFields = null;
this.created = null;
this.productActivations = null;
this.addonActivations = null;
this.statusHistory = null;
this.declinedReason = "";
}
/**
* Adds a value to the builder for orderId
* @param orderId Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setOrderId(String orderId) {
this.orderId = orderId;
return this;
}
/**
* Adds a value to the builder for salespersonId
* @param salespersonId Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setSalespersonId(String salespersonId) {
this.salespersonId = salespersonId;
return this;
}
/**
* Adds a value to the builder for partnerId
* @param partnerId Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setPartnerId(String partnerId) {
this.partnerId = partnerId;
return this;
}
/**
* Adds a value to the builder for businessId
* @param businessId Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setBusinessId(String businessId) {
this.businessId = businessId;
return this;
}
/**
* Adds a value to the builder for marketId
* @param marketId Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setMarketId(String marketId) {
this.marketId = marketId;
return this;
}
/**
* Adds a value to the builder for opportunityIds
* @param opportunityIds Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setOpportunityIds(List opportunityIds) {
this.opportunityIds = opportunityIds;
return this;
}
/**
* Adds a value to the builder for status
* @param status Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setStatus(Status status) {
this.status = status;
return this;
}
/**
* Adds a value to the builder for requestedActivation
* @param requestedActivation Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setRequestedActivation(Date requestedActivation) {
this.requestedActivation = requestedActivation;
return this;
}
/**
* Adds a value to the builder for notes
* @param notes Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setNotes(String notes) {
this.notes = notes;
return this;
}
/**
* Adds a value to the builder for packages
* @param packages Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setPackages(List packages) {
this.packages = packages;
return this;
}
/**
* Adds a value to the builder for customFields
* @param customFields Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setCustomFields(List customFields) {
this.customFields = customFields;
return this;
}
/**
* Adds a value to the builder for commonFields
* @param commonFields Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setCommonFields(List commonFields) {
this.commonFields = commonFields;
return this;
}
/**
* Adds a value to the builder for created
* @param created Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setCreated(Date created) {
this.created = created;
return this;
}
/**
* Adds a value to the builder for productActivations
* @param productActivations Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setProductActivations(List productActivations) {
this.productActivations = productActivations;
return this;
}
/**
* Adds a value to the builder for addonActivations
* @param addonActivations Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setAddonActivations(List addonActivations) {
this.addonActivations = addonActivations;
return this;
}
/**
* Adds a value to the builder for statusHistory
* @param statusHistory Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setStatusHistory(List statusHistory) {
this.statusHistory = statusHistory;
return this;
}
/**
* Adds a value to the builder for declinedReason
* @param declinedReason Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setDeclinedReason(String declinedReason) {
this.declinedReason = declinedReason;
return this;
}
/**
* Takes the configuration in the mutable Builder and uses it to instantiate a final instance
* of the Order class
* @return The instantiated final Order
**/
public Order build() {
return new Order(
this.orderId,
this.salespersonId,
this.partnerId,
this.businessId,
this.marketId,
this.opportunityIds,
this.status,
this.requestedActivation,
this.notes,
this.packages,
this.customFields,
this.commonFields,
this.created,
this.productActivations,
this.addonActivations,
this.statusHistory,
this.declinedReason);
}
}
/**
* Returns a Builder for Order, which is a mutable representation of the object. Once the
* client has built up an object they can then create an immutable Order object using the
* build function.
* @return A fresh Builder instance with no values set
**/
public static Builder newBuilder() {
return new Builder();
}
/**
* Provides a human-readable representation of this object. Useful for debugging.
* @return A string representation of the Order instance
**/
public String toString() {
String result = "Order\n";
result += "-> orderId: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.orderId).split("\n"))) + "\n";
result += "-> salespersonId: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.salespersonId).split("\n"))) + "\n";
result += "-> partnerId: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.partnerId).split("\n"))) + "\n";
result += "-> businessId: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.businessId).split("\n"))) + "\n";
result += "-> marketId: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.marketId).split("\n"))) + "\n";
result += "-> opportunityIds: (List)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.opportunityIds).split("\n"))) + "\n";
result += "-> status: (Status)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.status).split("\n"))) + "\n";
result += "-> requestedActivation: (Date)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.requestedActivation).split("\n"))) + "\n";
result += "-> notes: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.notes).split("\n"))) + "\n";
result += "-> packages: (List)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.packages).split("\n"))) + "\n";
result += "-> customFields: (List)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.customFields).split("\n"))) + "\n";
result += "-> commonFields: (List)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.commonFields).split("\n"))) + "\n";
result += "-> created: (Date)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.created).split("\n"))) + "\n";
result += "-> productActivations: (List)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.productActivations).split("\n"))) + "\n";
result += "-> addonActivations: (List)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.addonActivations).split("\n"))) + "\n";
result += "-> statusHistory: (List)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.statusHistory).split("\n"))) + "\n";
result += "-> declinedReason: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.declinedReason).split("\n"))) + "\n";
return result;
}
/**
* Allows for simple conversion between the low-level generated protobuf object to
* Order, which is much more usable.
* @return An instance of Order representing the input proto object
**/
public static Order fromProto(SalesOrdersProto.Order proto) {
Order out = null;
if (proto != null) {
Order.Builder outBuilder = Order.newBuilder()
.setOrderId(proto.getOrderId())
.setSalespersonId(proto.getSalespersonId())
.setPartnerId(proto.getPartnerId())
.setBusinessId(proto.getBusinessId())
.setMarketId(proto.getMarketId())
.setOpportunityIds(proto.getOpportunityIdsList())
.setStatus(Status.fromProto(proto.getStatus()))
.setRequestedActivation(proto.hasRequestedActivation()?new Date(proto.getRequestedActivation().getSeconds() * 1000):null)
.setNotes(proto.getNotes())
.setPackages(Package.fromProtos(proto.getPackagesList()))
.setCustomFields(CustomField.fromProtos(proto.getCustomFieldsList()))
.setCommonFields(CommonField.fromProtos(proto.getCommonFieldsList()))
.setCreated(proto.hasCreated()?new Date(proto.getCreated().getSeconds() * 1000):null)
.setProductActivations(ProductActivation.fromProtos(proto.getProductActivationsList()))
.setAddonActivations(AddonActivation.fromProtos(proto.getAddonActivationsList()))
.setStatusHistory(StatusHistoryItem.fromProtos(proto.getStatusHistoryList()))
.setDeclinedReason(proto.getDeclinedReason());
out = outBuilder.build();
}
return out;
}
/**
* Convenience method for handling lists of proto objects. It calls .fromProto on each one
* and returns a list of the converted results.
* @return A list of Order instances representing the input proto objects
**/
public static List fromProtos(List protos) {
List out = new ArrayList();
for(SalesOrdersProto.Order proto : protos) {
out.add(Order.fromProto(proto));
}
return out;
}
/**
* Allows for simple conversion of an object to the low-level generated protobuf object.
* @return An instance of SalesOrdersProto.Order which is a proto object ready for wire transmission
**/
public SalesOrdersProto.Order toProto() {
Order obj = this;
SalesOrdersProto.Order.Builder outBuilder = SalesOrdersProto.Order.newBuilder();
outBuilder.setOrderId(obj.getOrderId());
outBuilder.setSalespersonId(obj.getSalespersonId());
outBuilder.setPartnerId(obj.getPartnerId());
outBuilder.setBusinessId(obj.getBusinessId());
outBuilder.setMarketId(obj.getMarketId());
outBuilder.addAllOpportunityIds(obj.getOpportunityIds());
outBuilder.setStatus(obj.getStatus() != null?obj.getStatus().toProto():null);
if(obj.getRequestedActivation()!=null){outBuilder.setRequestedActivation(com.google.protobuf.Timestamp.newBuilder().setSeconds(obj.getRequestedActivation().getTime() / 1000).build());}
outBuilder.setNotes(obj.getNotes());
outBuilder.addAllPackages(Package.toProtos(obj.getPackages()));
outBuilder.addAllCustomFields(CustomField.toProtos(obj.getCustomFields()));
outBuilder.addAllCommonFields(CommonField.toProtos(obj.getCommonFields()));
if(obj.getCreated()!=null){outBuilder.setCreated(com.google.protobuf.Timestamp.newBuilder().setSeconds(obj.getCreated().getTime() / 1000).build());}
outBuilder.addAllProductActivations(ProductActivation.toProtos(obj.getProductActivations()));
outBuilder.addAllAddonActivations(AddonActivation.toProtos(obj.getAddonActivations()));
outBuilder.addAllStatusHistory(StatusHistoryItem.toProtos(obj.getStatusHistory()));
outBuilder.setDeclinedReason(obj.getDeclinedReason());
return outBuilder.build();
}
/**
* Convenience method for handling lists of objects. It calls .toProto on each one and
* returns a list of the converted results.
* @return A list of SalesOrdersProto.Order instances representing the input objects.
*/
public static List toProtos(List objects) {
List out = new ArrayList();
if(objects != null) {
for (Order obj : objects) {
out.add(obj!=null?obj.toProto():null);
}
}
return out;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy