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

com.vendasta.salesorders.v1.internal.CreateSalesOrderRequest Maven / Gradle / Ivy

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.ApiProto;

/**
 * Containing information to create a new order
 **/
public final class CreateSalesOrderRequest {




	private final String salespersonId;
	private final String partnerId;
	private final String businessId;
	private final String marketId;
	private final List opportunityIds;
	private final Date requestedActivation;
	private final String notes;
	private final List packages;
	private final List customFields;
	private final List commonFields;
	

	private CreateSalesOrderRequest (
		final String salespersonId,
		final String partnerId,
		final String businessId,
		final String marketId,
		final List opportunityIds,
		final Date requestedActivation,
		final String notes,
		final List packages,
		final List customFields,
		final List commonFields)
		
	{
		this.salespersonId = salespersonId;
		this.partnerId = partnerId;
		this.businessId = businessId;
		this.marketId = marketId;
		this.opportunityIds = opportunityIds;
		this.requestedActivation = requestedActivation;
		this.notes = notes;
		this.packages = packages;
		this.customFields = customFields;
		this.commonFields = commonFields;
		
	}
	
	/**
	 * ID of the salesperson that submitted the order
      * @return The final value of salespersonId on the object
	 **/
	public String getSalespersonId() {
		return this.salespersonId;
	}
	
	/**
	 * ID of the partner that the order belongs to
      * @return The final value of partnerId on the object
	 **/
	public String getPartnerId() {
		return this.partnerId;
	}
	
	/**
	 * ID of the business that the order is for
      * @return The final value of businessId on the object
	 **/
	public String getBusinessId() {
		return this.businessId;
	}
	
	/**
	 * ID of the market that the order belongs to
      * @return The final value of marketId on the object
	 **/
	public String getMarketId() {
		return this.marketId;
	}
	
	/**
	 * Opportunity id(s) that the order is fulfilling
      * @return The final value of opportunityIds on the object
	 **/
	public List getOpportunityIds() {
		return this.opportunityIds;
	}
	
	/**
	 * Time submitted by a salesperson that indicates when an administrator should activate the products on the order
      * @return The final value of requestedActivation on the object
	 **/
	public Date getRequestedActivation() {
		return this.requestedActivation;
	}
	
	/**
	 * Additional notes written by a salesperson
      * @return The final value of notes on the object
	 **/
	public String getNotes() {
		return this.notes;
	}
	
	/**
	 * Data for the package(s) information
      * @return The final value of packages on the object
	 **/
	public List getPackages() {
		return this.packages;
	}
	
	/**
	 * A list of additional unique information pertaining to an individual product
      * @return The final value of customFields on the object
	 **/
	public List getCustomFields() {
		return this.customFields;
	}
	
	/**
	 * A list of additional information that is shared across multiple products
      * @return The final value of commonFields on the object
	 **/
	public List getCommonFields() {
		return this.commonFields;
	}
	

	public static class Builder {
		private String salespersonId;
		private String partnerId;
		private String businessId;
		private String marketId;
		private List opportunityIds;
		private Date requestedActivation;
		private String notes;
		private List packages;
		private List customFields;
		private List commonFields;
		
		public Builder() {
			this.salespersonId = "";
			this.partnerId = "";
			this.businessId = "";
			this.marketId = "";
			this.opportunityIds = new ArrayList();
			this.requestedActivation = null;
			this.notes = "";
			this.packages = null;
			this.customFields = null;
			this.commonFields = null;
			
		}
		
		/**
		  * 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 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;
		}
		
		/**
		  * Takes the configuration in the mutable Builder and uses it to instantiate a final instance
		  * of the CreateSalesOrderRequest class
		  * @return The instantiated final CreateSalesOrderRequest
		 **/
		public CreateSalesOrderRequest build() {
			return new CreateSalesOrderRequest(
				this.salespersonId,
				this.partnerId,
				this.businessId,
				this.marketId,
				this.opportunityIds,
				this.requestedActivation,
				this.notes,
				this.packages,
				this.customFields,
				this.commonFields);
		}
	}

	/**
	 * Returns a Builder for CreateSalesOrderRequest, which is a mutable representation of the object.  Once the
	 * client has built up an object they can then create an immutable CreateSalesOrderRequest 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 CreateSalesOrderRequest instance
	 **/
	 public String toString() {
		 String result = "CreateSalesOrderRequest\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 += "-> 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"; 
		 
		 return result;
	 }
	/**
	* Allows for simple conversion between the low-level generated protobuf object to
	* CreateSalesOrderRequest, which is much more usable.
	* @return An instance of CreateSalesOrderRequest representing the input proto object
	**/
	public static CreateSalesOrderRequest fromProto(ApiProto.CreateSalesOrderRequest proto) {
		CreateSalesOrderRequest out = null;
		if (proto != null) {
			CreateSalesOrderRequest.Builder outBuilder = CreateSalesOrderRequest.newBuilder()
			.setSalespersonId(proto.getSalespersonId())
			.setPartnerId(proto.getPartnerId())
			.setBusinessId(proto.getBusinessId())
			.setMarketId(proto.getMarketId())
			.setOpportunityIds(proto.getOpportunityIdsList())
			.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()));
			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 CreateSalesOrderRequest instances representing the input proto objects
	**/
	public static List fromProtos(List protos) {
		List out = new ArrayList();
		for(ApiProto.CreateSalesOrderRequest proto : protos) {
			out.add(CreateSalesOrderRequest.fromProto(proto));
		}
		return out;
	}

	/**
	 * Allows for simple conversion of an object to the low-level generated protobuf object.
	 * @return An instance of ApiProto.CreateSalesOrderRequest which is a proto object ready for wire transmission
	 **/
	 public ApiProto.CreateSalesOrderRequest toProto() {
		 CreateSalesOrderRequest obj = this;
		 ApiProto.CreateSalesOrderRequest.Builder outBuilder = ApiProto.CreateSalesOrderRequest.newBuilder();
		 outBuilder.setSalespersonId(obj.getSalespersonId());
		 outBuilder.setPartnerId(obj.getPartnerId());
		 outBuilder.setBusinessId(obj.getBusinessId());
		 outBuilder.setMarketId(obj.getMarketId());
		 outBuilder.addAllOpportunityIds(obj.getOpportunityIds());
		 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()));
		 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 ApiProto.CreateSalesOrderRequest instances representing the input objects.
	  */
	public static List toProtos(List objects) {
		List out = new ArrayList();
		if(objects != null) {
			for (CreateSalesOrderRequest obj : objects) {
				out.add(obj!=null?obj.toProto():null);
			}
		}
		return out;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy