
com.vendasta.salesorders.v1.internal.StatusHistoryItem 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;
/**
* Represents a status change on the order to determine who it was updated by and what time it was updated
**/
public final class StatusHistoryItem {
private final String userId;
private final Status status;
private final Date created;
private final String email;
private StatusHistoryItem (
final String userId,
final Status status,
final Date created,
final String email)
{
this.userId = userId;
this.status = status;
this.created = created;
this.email = email;
}
/**
* The unique identifier of the user that updated the status
* DEPRECATED: Use the `email` field, and if that is not set, fallback to user_id.
* @return The final value of userId on the object
**/
public String getUserId() {
return this.userId;
}
/**
* The status the order was changed to
* @return The final value of status on the object
**/
public Status getStatus() {
return this.status;
}
/**
* The time the status was created
* @return The final value of created on the object
**/
public Date getCreated() {
return this.created;
}
/**
* The email fo the user that updated the status.
* If this field is not set, fallback to the deprecated `user_id` field.
* @return The final value of email on the object
**/
public String getEmail() {
return this.email;
}
public static class Builder {
private String userId;
private Status status;
private Date created;
private String email;
public Builder() {
this.userId = "";
this.status = null;
this.created = null;
this.email = "";
}
/**
* Adds a value to the builder for userId
* @param userId Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setUserId(String userId) {
this.userId = userId;
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 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 email
* @param email Value to assign to the mutable Builder
* @return The Builder instance so that call chaining works
**/
public Builder setEmail(String email) {
this.email = email;
return this;
}
/**
* Takes the configuration in the mutable Builder and uses it to instantiate a final instance
* of the StatusHistoryItem class
* @return The instantiated final StatusHistoryItem
**/
public StatusHistoryItem build() {
return new StatusHistoryItem(
this.userId,
this.status,
this.created,
this.email);
}
}
/**
* Returns a Builder for StatusHistoryItem, which is a mutable representation of the object. Once the
* client has built up an object they can then create an immutable StatusHistoryItem 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 StatusHistoryItem instance
**/
public String toString() {
String result = "StatusHistoryItem\n";
result += "-> userId: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.userId).split("\n"))) + "\n";
result += "-> status: (Status)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.status).split("\n"))) + "\n";
result += "-> created: (Date)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.created).split("\n"))) + "\n";
result += "-> email: (String)"
+ StringUtils.join("\n ", Arrays.asList(String.valueOf(this.email).split("\n"))) + "\n";
return result;
}
/**
* Allows for simple conversion between the low-level generated protobuf object to
* StatusHistoryItem, which is much more usable.
* @return An instance of StatusHistoryItem representing the input proto object
**/
public static StatusHistoryItem fromProto(SalesOrdersProto.StatusHistoryItem proto) {
StatusHistoryItem out = null;
if (proto != null) {
StatusHistoryItem.Builder outBuilder = StatusHistoryItem.newBuilder()
.setUserId(proto.getUserId())
.setStatus(Status.fromProto(proto.getStatus()))
.setCreated(proto.hasCreated()?new Date(proto.getCreated().getSeconds() * 1000):null)
.setEmail(proto.getEmail());
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 StatusHistoryItem instances representing the input proto objects
**/
public static List fromProtos(List protos) {
List out = new ArrayList();
for(SalesOrdersProto.StatusHistoryItem proto : protos) {
out.add(StatusHistoryItem.fromProto(proto));
}
return out;
}
/**
* Allows for simple conversion of an object to the low-level generated protobuf object.
* @return An instance of SalesOrdersProto.StatusHistoryItem which is a proto object ready for wire transmission
**/
public SalesOrdersProto.StatusHistoryItem toProto() {
StatusHistoryItem obj = this;
SalesOrdersProto.StatusHistoryItem.Builder outBuilder = SalesOrdersProto.StatusHistoryItem.newBuilder();
outBuilder.setUserId(obj.getUserId());
outBuilder.setStatus(obj.getStatus() != null?obj.getStatus().toProto():null);
if(obj.getCreated()!=null){outBuilder.setCreated(com.google.protobuf.Timestamp.newBuilder().setSeconds(obj.getCreated().getTime() / 1000).build());}
outBuilder.setEmail(obj.getEmail());
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.StatusHistoryItem instances representing the input objects.
*/
public static List toProtos(List objects) {
List out = new ArrayList();
if(objects != null) {
for (StatusHistoryItem obj : objects) {
out.add(obj!=null?obj.toProto():null);
}
}
return out;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy